Skip to content

[BUG] Scrollviews no longer work together after 3.10 #127017

Closed

Description

@MousyBusiness

Is there an existing issue for this?

Steps to reproduce

  1. flutter downgrade 3.7.12
  2. run application and observe the scroll behaviour
  3. flutter upgrade
  4. run the application and observe how the scroll views no longer work

Expected results

Scrollview to behave as they did in 3.7.12

Actual results

Scrollviews no long work correctly

Code sample

import 'dart:math';

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  TextEditingController _controller = TextEditingController();

  @override
  void initState() {
    super.initState();

    _controller.text = """Tweak directional focus traversal by @gspencergoog in 116230
[framework] make ImageFiltered a repaint boundary by @jonahwilliams in 116385
[CP] Fix Snackbar TalkBack regression by @esouthren in 116417
Add widget of the week videos by @tvolkert in 116451
Speed up first asset load by encoding asset manifest in binary rather than JSON by @andrewkolos in 113637
Improve Flex layout comment by @loic-sharma in 116004
Do not parse stack traces in _findResponsibleMethod on Web platforms that use a different format by @jason-simmons in 115500
Support theming CupertinoSwitchs by @guidezpl in 116510
Fix MenuAnchor padding by @gspencergoog in 116573
Add ListenableBuilder with examples by @gspencergoog in 116543
Time picker precursors by @gspencergoog in 116450
Date picker special labeling for currentDate with localization and te… by @harperl-lgtm in 116433
Adds API in semanticsconfiguration to decide how to merge child semanticsConfigurations by @chunhtai in 110730
Revert “Speed up first asset load by encoding asset manifest in binary rather than JSON” by @CaseyHillers in 116662
Reland “Use semantics label for backbutton and closebutton for Android” by @chunhtai in 115776
Revert “Use semantics label for backbutton and closebutton for Android” by @chunhtai in 116675
LookupBoundary by @goderbauer in 116429
Reland “Use semantics label for backbutton and closebutton for Android” by @chunhtai in 116676
Fix wrong position of TabBarIndicator when it’s label size and has label padding by @zmtzawqlp in 116398
Add CupertinoSliverNavigationBar large title magnification on over scroll by @ivirtex in 110127
Update text field input width when there are prefix/suffix icons by @hangyujin in 116690
Add Material 3 support for ListTile - Part 1 by @TahaTesser in 116194
MediaQuery as InheritedModel by @moffatman in 114459
Add LookupBoundary to Material by @goderbauer in 116736
Floating cursor cleanup by @moffatman in 116746
Revert “Adds API in semanticsconfiguration to decide how to merge child semanticsConfigurations” by @CaseyHillers in 116839
More gracefully handle license loading failures by @Hixie in 87841
Taboo the word “simply” from our API documentation. by @Hixie in 116061
Fix NavigationBar ripple for non-default NavigationDestinationLabelBehavior by @TahaTesser in 116888
Add LookupBoundary to Overlay by @goderbauer in 116741
[framework] make opacity widget create a repaint boundary by @j""";
    WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
      _recomputeLongestLine();
      setState(() {});
    });
  }

  String _longestLine = '';

  void _recomputeLongestLine() {
    _longestLine = '';
    final _lines = _controller.text.split('\n');
    final buf = <String>[];

    for (var k = 0; k < _lines.length; k++) {
      buf.add((k + 1).toString());
    }
    // Find longest line
    _longestLine = '';
    for (var line in _lines) {
      if (line.length > _longestLine.length) _longestLine = line;
    }

    print("Longest: ${_longestLine}");
  }

  Widget _buildLongestLinePlaceHolder(double minWidth) {
    return ConstrainedBox(
      constraints: BoxConstraints(
        maxHeight: 0,
        minWidth: max(minWidth, 0),
      ),
      child: Padding(
        padding: const EdgeInsets.only(right: 16),
        child: Text(_longestLine, style: TextStyle(fontSize: 16)),
      ), // Add extra padding
    );
  }

  Widget _wrapInHorizontalScrollView({required Widget child}) {
    return LayoutBuilder(builder: (context, constraints) {
      return SingleChildScrollView(
        clipBehavior: Clip.none,
        scrollDirection: Axis.horizontal,
        child: IntrinsicWidth(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: [
              _buildLongestLinePlaceHolder(constraints.maxWidth),
              child,
            ],
          ),
        ),
      );
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Container(
          height: 600,
          width: 600,
          color: Colors.yellowAccent,
          child: SingleChildScrollView(
            physics: const ClampingScrollPhysics(),
            child: _wrapInHorizontalScrollView(
              child: TextField(
                scrollPhysics: const NeverScrollableScrollPhysics(),
                scrollPadding: EdgeInsets.zero,
                controller: _controller,
                keyboardType: TextInputType.multiline,
                decoration: null,
                maxLines: null,
                enabled: true,
                onChanged: (t) {},
                readOnly: false,
                clipBehavior: Clip.none,
              ),
            ),
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

No response

Flutter Doctor output

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.10.0, on macOS 13.2.1 22D68 darwin-arm64)
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Android Studio (version 2021.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.1)
[✓] VS Code (version 1.78.0)
[✓] Connected device (2 available)
[✓] Network resources

Activity

  1. danagbemava-nc commented on May 17, 2023

    @danagbemava-nc
    Member

    Hi @MousyBusiness, what platform(s) are you experiencing this issue on? Can you also share a recording of what the expected behavior is and what you're experiencing?

    Thank you

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on May 17, 2023
  3. minhx3 commented on May 19, 2023

    @minhx3

    I am facing the same problem, in version 3.7.12 SingleScrollView auto scrolling up when keyboard focus is from 3.10.0 onwards not working

  4. MousyBusiness commented on May 21, 2023

    @MousyBusiness
    Author

    @danagbemava-nc The testing was done on iPad. The video would not be extremely obvious what is happen, as the scroll view simply doesn't work. The expected behaviour is that horizontal and vertical scrolling combined enables the user to pan the text in the x and y axis

  5. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on May 21, 2023
  6. danagbemava-nc commented on May 22, 2023

    @danagbemava-nc
    Member

    Thanks for the details. I can reproduce the issue but only on iOS.

    I tested on macOS, chrome & android and these devices worked just fine. On iOS, this failed on the current stable & master whether or not impeller was used but it worked just fine on stable 3.7.12.

    A few recordings

    iOS

    stable 3.7.12 current stable & master
    PXL_20230522_073625404.ACTIVE.TS.mp4
    PXL_20230522_072824987.TS.mp4

    macOS (Chrome has a similar behavior)

    Screen.Recording.2023-05-22.at.07.24.21.mov

    android

    screen-20230522-073801.mp4
    flutter doctor -v
    [!] Flutter (Channel unknown, 3.7.12, on macOS 13.3.1 22E772610a darwin-arm64, locale en-GB)
        ! Flutter version 3.7.12 on channel unknown at /Users/nexus/dev/sdks/flutter_rc/flutter
          Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
          If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install.
        ! Warning: `flutter` on your path resolves to /Users/nexus/dev/sdks/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutter_rc/flutter. Consider adding /Users/nexus/dev/sdks/flutter_rc/flutter/bin to the front of your path.
        ! Warning: `dart` on your path resolves to /Users/nexus/dev/sdks/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutter_rc/flutter. Consider adding /Users/nexus/dev/sdks/flutter_rc/flutter/bin to the front of your path.
        ! Unknown upstream repository.
          Reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install.
        • Framework revision 4d9e56e694 (5 weeks ago), 2023-04-17 21:47:46 -0400
        • Engine revision 1a65d409c7
        • Dart version 2.19.6
        • DevTools version 2.20.1
        • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-33, build-tools 33.0.0
        • Java binary at: /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9971841/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 14.3)
        • Xcode at /Applications/Xcode-14.3.0.app/Contents/Developer
        • Build 14E222b
        • CocoaPods version 1.12.1
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2022.2)
        • Android Studio at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9971841/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    
    [✓] Android Studio (version 2022.2)
        • Android Studio at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9862592/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.1.2)
        • IntelliJ at /Users/nexus/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
        • Flutter plugin version 73.1.1
        • Dart plugin version 231.9065
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.1.2)
        • IntelliJ at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.9011.34/IntelliJ IDEA.app
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.1.1)
        • IntelliJ at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.8770.65/IntelliJ IDEA.app
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
    
    [✓] VS Code (version 1.78.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.64.0
    
    [✓] Connected device (3 available)
        • Dean’s iPad (mobile) • 00008103-000825C811E3401E • ios            • iOS 16.4.1 20E252
        • macOS (desktop)      • macos                     • darwin-arm64   • macOS 13.3.1 22E772610a darwin-arm64
        • Chrome (web)         • chrome                    • web-javascript • Google Chrome 113.0.5672.126
        ! Error: Dean’s iPad is busy: Fetching debug symbols for Dean’s iPad. Xcode will continue when Dean’s iPad is finished. (code -10)
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    ! Doctor found issues in 1 category.
    
    [✓] Flutter (Channel stable, 3.10.1, on macOS 13.3.1 22E772610a darwin-arm64, locale en-GB)
        • Flutter version 3.10.1 on channel stable at /Users/nexus/dev/sdks/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision d3d8effc68 (5 days ago), 2023-05-16 17:59:05 -0700
        • Engine revision b4fb11214d
        • Dart version 3.0.1
        • DevTools version 2.23.1
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-33, build-tools 33.0.0
        • Java binary at: /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9971841/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 14.3)
        • Xcode at /Applications/Xcode-14.3.0.app/Contents/Developer
        • Build 14E222b
        • CocoaPods version 1.12.1
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2022.2)
        • Android Studio at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9971841/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    
    [✓] Android Studio (version 2022.2)
        • Android Studio at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9862592/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.1.2)
        • IntelliJ at /Users/nexus/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
        • Flutter plugin version 73.1.1
        • Dart plugin version 231.9065
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.1.2)
        • IntelliJ at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.9011.34/IntelliJ IDEA.app
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.1.1)
        • IntelliJ at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.8770.65/IntelliJ IDEA.app
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
    
    [✓] VS Code (version 1.78.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.64.0
    
    [✓] Connected device (4 available)
        • Dean’s iPad (mobile) • 00008103-000825C811E3401E • ios            • iOS 16.4.1 20E252
        • Nexus (mobile)       • 00008020-001875E83A38002E • ios            • iOS 16.4.1 20E252
        • macOS (desktop)      • macos                     • darwin-arm64   • macOS 13.3.1 22E772610a darwin-arm64
        • Chrome (web)         • chrome                    • web-javascript • Google Chrome 113.0.5672.126
    
    [✓] Network resources
        • All expected network resources are available.
    
    • No issues found!
    
    [!] Flutter (Channel master, 3.11.0-10.0.pre.44, on macOS 13.3.1 22E772610a darwin-arm64, locale en-GB)
        • Flutter version 3.11.0-10.0.pre.44 on channel master at /Users/nexus/dev/sdks/flutters
        ! Warning: `flutter` on your path resolves to /Users/nexus/dev/sdks/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutters. Consider adding /Users/nexus/dev/sdks/flutters/bin to the front of your path.
        ! Warning: `dart` on your path resolves to /Users/nexus/dev/sdks/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutters. Consider adding /Users/nexus/dev/sdks/flutters/bin to the front of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision ab573048e7 (2 days ago), 2023-05-20 11:32:26 -0400
        • Engine revision aac0919568
        • Dart version 3.1.0 (build 3.1.0-129.0.dev)
        • DevTools version 2.23.1
        • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-33, build-tools 33.0.0
        • Java binary at: /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9971841/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 14.3)
        • Xcode at /Applications/Xcode-14.3.0.app/Contents/Developer
        • Build 14E222b
        • CocoaPods version 1.12.1
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2022.2)
        • Android Studio at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9971841/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    
    [✓] Android Studio (version 2022.2)
        • Android Studio at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9862592/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.1.2)
        • IntelliJ at /Users/nexus/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
        • Flutter plugin version 73.1.1
        • Dart plugin version 231.9065
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.1.2)
        • IntelliJ at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.9011.34/IntelliJ IDEA.app
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.1.1)
        • IntelliJ at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.8770.65/IntelliJ IDEA.app
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
    
    [✓] VS Code (version 1.78.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.64.0
    
    [✓] Connected device (3 available)
        • Dean’s iPad (mobile) • 00008103-000825C811E3401E • ios            • iOS 16.4.1 20E252
        • macOS (desktop)      • macos                     • darwin-arm64   • macOS 13.3.1 22E772610a darwin-arm64
        • Chrome (web)         • chrome                    • web-javascript • Google Chrome 113.0.5672.126
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
    
    
  7. added
    c: regressionIt was better in the past than it is now
    platform-iosiOS applications specifically
    frameworkflutter/packages/flutter repository. See also f: labels.
    f: scrollingViewports, list views, slivers, etc.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on May 22, 2023
  8. 11 remaining items

  9. MousyBusiness commented on Jun 13, 2023

    @MousyBusiness
    Author

    Try this @Renzo-Olivares. I've clamped the scrollviews and put them into a gesture detector with a transform for a bit of visual feedback. You'll notice that when touching the yellow text, you can move vertically, but you cannot move horizontally. This behaviour did not exist in 3.7.12

    class MyHomePage extends StatefulWidget {
      const MyHomePage({super.key, required this.title});
    
      final String title;
    
      @override
      State<MyHomePage> createState() => _MyHomePageState();
    }
    
    class _MyHomePageState extends State<MyHomePage> {
      TextEditingController _controller = TextEditingController();
    
      @override
      void initState() {
        super.initState();
    
        _controller.text = """Tweak directional focus traversal by @gspencergoog in 116230
    [framework] make ImageFiltered a repaint boundary by @jonahwilliams in 116385
    [CP] Fix Snackbar TalkBack regression by @esouthren in 116417
    Add widget of the week videos by @tvolkert in 116451
    Speed up first asset load by encoding asset manifest in binary rather than JSON by @andrewkolos in 113637
    Improve Flex layout comment by @loic-sharma in 116004
    Do not parse stack traces in _findResponsibleMethod on Web platforms that use a different format by @jason-simmons in 115500
    Support theming CupertinoSwitchs by @guidezpl in 116510
    Fix MenuAnchor padding by @gspencergoog in 116573
    Add ListenableBuilder with examples by @gspencergoog in 116543
    Time picker precursors by @gspencergoog in 116450
    Date picker special labeling for currentDate with localization and te… by @harperl-lgtm in 116433
    Adds API in semanticsconfiguration to decide how to merge child semanticsConfigurations by @chunhtai in 110730
    Revert “Speed up first asset load by encoding asset manifest in binary rather than JSON” by @CaseyHillers in 116662
    Reland “Use semantics label for backbutton and closebutton for Android” by @chunhtai in 115776
    Revert “Use semantics label for backbutton and closebutton for Android” by @chunhtai in 116675
    LookupBoundary by @goderbauer in 116429
    Reland “Use semantics label for backbutton and closebutton for Android” by @chunhtai in 116676
    Fix wrong position of TabBarIndicator when it’s label size and has label padding by @zmtzawqlp in 116398
    Add CupertinoSliverNavigationBar large title magnification on over scroll by @ivirtex in 110127
    Update text field input width when there are prefix/suffix icons by @hangyujin in 116690
    Add Material 3 support for ListTile - Part 1 by @TahaTesser in 116194
    MediaQuery as InheritedModel by @moffatman in 114459
    Add LookupBoundary to Material by @goderbauer in 116736
    Floating cursor cleanup by @moffatman in 116746
    Revert “Adds API in semanticsconfiguration to decide how to merge child semanticsConfigurations” by @CaseyHillers in 116839
    More gracefully handle license loading failures by @Hixie in 87841
    Taboo the word “simply” from our API documentation. by @Hixie in 116061
    Fix NavigationBar ripple for non-default NavigationDestinationLabelBehavior by @TahaTesser in 116888
    Add LookupBoundary to Overlay by @goderbauer in 116741
    Revert “Speed up first asset load by encoding asset manifest in binary rather than JSON” by @CaseyHillers in 116662
    Reland “Use semantics label for backbutton and closebutton for Android” by @chunhtai in 115776
    Revert “Use semantics label for backbutton and closebutton for Android” by @chunhtai in 116675
    LookupBoundary by @goderbauer in 116429
    Reland “Use semantics label for backbutton and closebutton for Android” by @chunhtai in 116676
    Fix wrong position of TabBarIndicator when it’s label size and has label padding by @zmtzawqlp in 116398
    Add CupertinoSliverNavigationBar large title magnification on over scroll by @ivirtex in 110127
    Update text field input width when there are prefix/suffix icons by @hangyujin in 116690
    Add Material 3 support for ListTile - Part 1 by @TahaTesser in 116194
    MediaQuery as InheritedModel by @moffatman in 114459
    Add LookupBoundary to Material by @goderbauer in 116736
    Floating cursor cleanup by @moffatman in 116746
    Revert “Adds API in semanticsconfiguration to decide how to merge child semanticsConfigurations” by @CaseyHillers in 116839
    More gracefully handle license loading failures by @Hixie in 87841
    Taboo the word “simply” from our API documentation. by @Hixie in 116061
    Fix NavigationBar ripple for non-default NavigationDestinationLabelBehavior by @TahaTesser in 116888
    Add LookupBoundary to Overlay by @goderbauer in 116741
    [framework] make opacity widget create a repaint boundary by @j""";
        WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
          _recomputeLongestLine();
          setState(() {});
        });
      }
    
      String _longestLine = '';
    
      void _recomputeLongestLine() {
        _longestLine = '';
        final _lines = _controller.text.split('\n');
        final buf = <String>[];
    
        for (var k = 0; k < _lines.length; k++) {
          buf.add((k + 1).toString());
        }
        // Find longest line
        _longestLine = '';
        for (var line in _lines) {
          if (line.length > _longestLine.length) _longestLine = line;
        }
    
        print("Longest: ${_longestLine}");
      }
    
      Widget _buildLongestLinePlaceHolder(double minWidth) {
        return ConstrainedBox(
          constraints: BoxConstraints(
            maxHeight: 0,
            minWidth: max(minWidth, 0),
          ),
          child: Padding(
            padding: const EdgeInsets.only(right: 16),
            child: Text(_longestLine, style: TextStyle(fontSize: 16)),
          ), // Add extra padding
        );
      }
    
      Widget _wrapInHorizontalScrollView({required Widget child}) {
        return LayoutBuilder(builder: (context, constraints) {
          return MediaQuery(
            data: const MediaQueryData(gestureSettings: DeviceGestureSettings(touchSlop: 8.0)),
            child: SingleChildScrollView(
              physics: const NeverScrollableScrollPhysics(),
              clipBehavior: Clip.none,
              scrollDirection: Axis.horizontal,
              child: IntrinsicWidth(
                child: Column(
                  mainAxisSize: MainAxisSize.min,
                  crossAxisAlignment: CrossAxisAlignment.stretch,
                  children: [
                    _buildLongestLinePlaceHolder(constraints.maxWidth),
                    child,
                  ],
                ),
              ),
            ),
          );
        });
      }
    
      Offset _lastFocalPoint = Offset.zero;
      Matrix4 matrix = Matrix4.identity();
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: Text(widget.title),
          ),
          body: GestureDetector(
            onScaleStart: (d) {
              _lastFocalPoint = d.focalPoint;
              print("Scale start");
            },
            onScaleUpdate: (d) {
              print("Scale update");
              Offset delta = d.focalPoint - _lastFocalPoint;
              final m1 = Matrix4.identity()
                ..translate(delta.dx, delta.dy)
                ..multiply(matrix);
              matrix = m1;
              _lastFocalPoint = d.focalPoint;
              setState(() {});
            },
            onScaleEnd: (_) {
              print("Scale end");
            },
            child: Container(
              width: double.infinity,
              height: double.infinity,
              color: Colors.red.withOpacity(0.1),
              child: Stack(
                children: [
                  Transform(
                    transform: matrix,
                    child: Container(
                      height: 600,
                      width: 600,
                      color: Colors.yellowAccent,
                      child: SingleChildScrollView(
                        physics: const NeverScrollableScrollPhysics(),
                        child: _wrapInHorizontalScrollView(
                          child: TextField(
                            scrollPhysics: const NeverScrollableScrollPhysics(),
                            scrollPadding: EdgeInsets.zero,
                            controller: _controller,
                            keyboardType: TextInputType.multiline,
                            decoration: null,
                            maxLines: null,
                            enabled: true,
                            onChanged: (t) {},
                            readOnly: false,
                            clipBehavior: Clip.none,
                          ),
                        ),
                      ),
                    ),
                  )
                ],
              ),
            ),
          ),
        );
      }
    }
    
  10. MousyBusiness commented on Jun 13, 2023

    @MousyBusiness
    Author

    @Renzo-Olivares it actually still happens if you remove both scroll views.

    The source of the event absorb seems to be these lines in TextField (line 1477):

                child: _selectionGestureDetectorBuilder.buildGestureDetector(
                  behavior: HitTestBehavior.translucent,
                  child: child,
                ),
    

    Specifically the drag selection in text_selection.dart (line 2852):

      Widget buildGestureDetector({
        Key? key,
        HitTestBehavior? behavior,
        required Widget child,
      }) {
        return TextSelectionGestureDetector(
          key: key,
          onTapDown: onTapDown,
          onForcePressStart: delegate.forcePressEnabled ? onForcePressStart : null,
          onForcePressEnd: delegate.forcePressEnabled ? onForcePressEnd : null,
          onSecondaryTap: onSecondaryTap,
          onSecondaryTapDown: onSecondaryTapDown,
          onSingleTapUp: onSingleTapUp,
          onSingleTapCancel: onSingleTapCancel,
          onSingleLongTapStart: onSingleLongTapStart,
          onSingleLongTapMoveUpdate: onSingleLongTapMoveUpdate,
          onSingleLongTapEnd: onSingleLongTapEnd,
          onDoubleTapDown: onDoubleTapDown,
          onTripleTapDown: onTripleTapDown,
          onDragSelectionStart: onDragSelectionStart, // HERE
          onDragSelectionUpdate: onDragSelectionUpdate, // HERE
          onDragSelectionEnd: onDragSelectionEnd, // HERE
          behavior: behavior,
          child: child,
        );
      }
    
  11. Renzo-Olivares commented on Jun 20, 2023

    @Renzo-Olivares
    Contributor

    @MousyBusiness sorry for the late reply. The workaround I posted should still work in this case. You just have to move the added MediaQuery widget to encapsulate the GestureDetector that contains the scaling so the ScaleGestureRecognizer can also beat the TextFields TapAndHorizontalDragGestureRecognizer. Let me know if that works for you.

    import 'dart:math';
    
    import 'package:flutter/gestures.dart';
    import 'package:flutter/material.dart';
    
    void main() {
      runApp(const MyApp());
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({super.key});
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          theme: ThemeData(
            primarySwatch: Colors.blue,
          ),
          home: const MyHomePage(title: 'Flutter Demo Home Page'),
        );
      }
    }
    
    class MyHomePage extends StatefulWidget {
      const MyHomePage({super.key, required this.title});
    
      final String title;
    
      @override
      State<MyHomePage> createState() => _MyHomePageState();
    }
    
    class _MyHomePageState extends State<MyHomePage> {
      TextEditingController _controller = TextEditingController();
    
      @override
      void initState() {
        super.initState();
    
        _controller.text = """Tweak directional focus traversal by @gspencergoog in 116230
    [framework] make ImageFiltered a repaint boundary by @jonahwilliams in 116385
    [CP] Fix Snackbar TalkBack regression by @esouthren in 116417
    Add widget of the week videos by @tvolkert in 116451
    Speed up first asset load by encoding asset manifest in binary rather than JSON by @andrewkolos in 113637
    Improve Flex layout comment by @loic-sharma in 116004
    Do not parse stack traces in _findResponsibleMethod on Web platforms that use a different format by @jason-simmons in 115500
    Support theming CupertinoSwitchs by @guidezpl in 116510
    Fix MenuAnchor padding by @gspencergoog in 116573
    Add ListenableBuilder with examples by @gspencergoog in 116543
    Time picker precursors by @gspencergoog in 116450
    Date picker special labeling for currentDate with localization and te… by @harperl-lgtm in 116433
    Adds API in semanticsconfiguration to decide how to merge child semanticsConfigurations by @chunhtai in 110730
    Revert “Speed up first asset load by encoding asset manifest in binary rather than JSON” by @CaseyHillers in 116662
    Reland “Use semantics label for backbutton and closebutton for Android” by @chunhtai in 115776
    Revert “Use semantics label for backbutton and closebutton for Android” by @chunhtai in 116675
    LookupBoundary by @goderbauer in 116429
    Reland “Use semantics label for backbutton and closebutton for Android” by @chunhtai in 116676
    Fix wrong position of TabBarIndicator when it’s label size and has label padding by @zmtzawqlp in 116398
    Add CupertinoSliverNavigationBar large title magnification on over scroll by @ivirtex in 110127
    Update text field input width when there are prefix/suffix icons by @hangyujin in 116690
    Add Material 3 support for ListTile - Part 1 by @TahaTesser in 116194
    MediaQuery as InheritedModel by @moffatman in 114459
    Add LookupBoundary to Material by @goderbauer in 116736
    Floating cursor cleanup by @moffatman in 116746
    Revert “Adds API in semanticsconfiguration to decide how to merge child semanticsConfigurations” by @CaseyHillers in 116839
    More gracefully handle license loading failures by @Hixie in 87841
    Taboo the word “simply” from our API documentation. by @Hixie in 116061
    Fix NavigationBar ripple for non-default NavigationDestinationLabelBehavior by @TahaTesser in 116888
    Add LookupBoundary to Overlay by @goderbauer in 116741
    Revert “Speed up first asset load by encoding asset manifest in binary rather than JSON” by @CaseyHillers in 116662
    Reland “Use semantics label for backbutton and closebutton for Android” by @chunhtai in 115776
    Revert “Use semantics label for backbutton and closebutton for Android” by @chunhtai in 116675
    LookupBoundary by @goderbauer in 116429
    Reland “Use semantics label for backbutton and closebutton for Android” by @chunhtai in 116676
    Fix wrong position of TabBarIndicator when it’s label size and has label padding by @zmtzawqlp in 116398
    Add CupertinoSliverNavigationBar large title magnification on over scroll by @ivirtex in 110127
    Update text field input width when there are prefix/suffix icons by @hangyujin in 116690
    Add Material 3 support for ListTile - Part 1 by @TahaTesser in 116194
    MediaQuery as InheritedModel by @moffatman in 114459
    Add LookupBoundary to Material by @goderbauer in 116736
    Floating cursor cleanup by @moffatman in 116746
    Revert “Adds API in semanticsconfiguration to decide how to merge child semanticsConfigurations” by @CaseyHillers in 116839
    More gracefully handle license loading failures by @Hixie in 87841
    Taboo the word “simply” from our API documentation. by @Hixie in 116061
    Fix NavigationBar ripple for non-default NavigationDestinationLabelBehavior by @TahaTesser in 116888
    Add LookupBoundary to Overlay by @goderbauer in 116741
    [framework] make opacity widget create a repaint boundary by @j""";
        WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
          _recomputeLongestLine();
          setState(() {});
        });
      }
    
      String _longestLine = '';
    
      void _recomputeLongestLine() {
        _longestLine = '';
        final _lines = _controller.text.split('\n');
        final buf = <String>[];
    
        for (var k = 0; k < _lines.length; k++) {
          buf.add((k + 1).toString());
        }
        // Find longest line
        _longestLine = '';
        for (var line in _lines) {
          if (line.length > _longestLine.length) _longestLine = line;
        }
    
        print("Longest: ${_longestLine}");
      }
    
      Widget _buildLongestLinePlaceHolder(double minWidth) {
        return ConstrainedBox(
          constraints: BoxConstraints(
            maxHeight: 0,
            minWidth: max(minWidth, 0),
          ),
          child: Padding(
            padding: const EdgeInsets.only(right: 16),
            child: Text(_longestLine, style: TextStyle(fontSize: 16)),
          ), // Add extra padding
        );
      }
    
      Widget _wrapInHorizontalScrollView({required Widget child}) {
        return LayoutBuilder(builder: (context, constraints) {
          return SingleChildScrollView(
            physics: const NeverScrollableScrollPhysics(),
            clipBehavior: Clip.none,
            scrollDirection: Axis.horizontal,
            child: IntrinsicWidth(
              child: Column(
                mainAxisSize: MainAxisSize.min,
                crossAxisAlignment: CrossAxisAlignment.stretch,
                children: [
                  _buildLongestLinePlaceHolder(constraints.maxWidth),
                  child,
                ],
              ),
            ),
          );
        });
      }
    
      Offset _lastFocalPoint = Offset.zero;
      Matrix4 matrix = Matrix4.identity();
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: Text(widget.title),
          ),
          body: MediaQuery(
            data: const MediaQueryData(gestureSettings: DeviceGestureSettings(touchSlop: 8.0)),
            child: GestureDetector(
              onScaleStart: (d) {
                _lastFocalPoint = d.focalPoint;
                print("Scale start");
              },
              onScaleUpdate: (d) {
                print("Scale update");
                Offset delta = d.focalPoint - _lastFocalPoint;
                final m1 = Matrix4.identity()
                  ..translate(delta.dx, delta.dy)
                  ..multiply(matrix);
                matrix = m1;
                _lastFocalPoint = d.focalPoint;
                setState(() {});
              },
              onScaleEnd: (_) {
                print("Scale end");
              },
              child: Container(
                width: double.infinity,
                height: double.infinity,
                color: Colors.red.withOpacity(0.1),
                child: Stack(
                  children: [
                    Transform(
                      transform: matrix,
                      child: Container(
                        height: 600,
                        width: 600,
                        color: Colors.yellowAccent,
                        child: SingleChildScrollView(
                          physics: const NeverScrollableScrollPhysics(),
                          child: _wrapInHorizontalScrollView(
                            child: TextField(
                              scrollPhysics: const NeverScrollableScrollPhysics(),
                              scrollPadding: EdgeInsets.zero,
                              controller: _controller,
                              keyboardType: TextInputType.multiline,
                              decoration: null,
                              maxLines: null,
                              enabled: true,
                              onChanged: (t) {},
                              readOnly: false,
                              clipBehavior: Clip.none,
                            ),
                          ),
                        ),
                      ),
                    )
                  ],
                ),
              ),
            ),
          ),
        );
      }
    }
  12. urusaich commented on Jan 31, 2024

    @urusaich

    @Renzo-Olivares this workaround is very dirty but works! Thanks you!

  13. added a commit that references this issue on May 1, 2024
    5181086
  14. added
    r: fixedIssue is closed as already fixed in a newer version
    on May 2, 2024
  15. github-actions commented on May 16, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  16. locked as resolved and limited conversation to collaborators on May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsc: regressionIt was better in the past than it is nowf: gesturesflutter/packages/flutter/gestures repository.f: scrollingViewports, list views, slivers, etc.found in release: 3.10Found to occur in 3.10found in release: 3.11Found to occur in 3.11frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-iosOwned by iOS platform teamtriaged-iosTriaged by iOS platform team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions