Skip to content

Implementations of TextEditingControllers throw error #148692

Closed

Description

@FMorschel

Steps to reproduce

  1. Latest Flutter version environment (in 3.19.6 this API was external).
  2. Create a project and extend TextEditingController (example below).
  3. Trigger the error by clicking/tapping on the TextField

Expected results

No errors.

Actual results

More details in log below:

NoSuchMethodError: tried to call a non-function, such as null:
'core.NoSuchMethodError.withInvocation'

When the exception was thrown, this was the stack:
packages/floating_overlay/main.dart 77:46                           [_isSelectionWithinTextBounds]

Code sample

Code sample
import 'package:flutter/material.dart';

void main() => runApp(
      MaterialApp(
        home: Scaffold(
          appBar: AppBar(
            title: const Text('Example'),
          ),
          body: TextField(
            controller: DelegatingTextEditingController(),
          ),
        ),
      ),
    );

class DelegatingTextEditingController implements TextEditingController {
  DelegatingTextEditingController([
    TextEditingController? controller,
  ]) : _text = controller ?? TextEditingController();

  final TextEditingController _text;

  @override
  void dispose() {
    _text.dispose();
  }

  @override
  void addListener(VoidCallback listener) {
    _text.addListener(listener);
  }

  @override
  void notifyListeners() {
    _text.notifyListeners();
  }

  @override
  void removeListener(VoidCallback listener) {
    _text.removeListener(listener);
  }

  @override
  TextSpan buildTextSpan({
    required bool withComposing,
    required BuildContext context,
    TextStyle? style,
  }) =>
      _text.buildTextSpan(
        context: context,
        style: style,
        withComposing: withComposing,
      );

  @override
  void clear() => _text.clear();

  @override
  void clearComposing() => _text.clearComposing();

  @override
  TextSelection get selection => _text.selection;
  @override
  set selection(TextSelection newSelection) => _text.selection = newSelection;

  @override
  String get text => _text.text;
  @override
  set text(String newText) => _text.text = newText;

  @override
  TextEditingValue get value => _text.value;
  @override
  set value(TextEditingValue newValue) => _text.value = newValue;

  @override
  bool get hasListeners => _text.hasListeners;
}

Screenshots or Video

No response

Logs

Logs
══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
The following JSNoSuchMethodError was thrown while handling a gesture:
NoSuchMethodError: tried to call a non-function, such as null:
'core.NoSuchMethodError.withInvocation'

When the exception was thrown, this was the stack:
packages/floating_overlay/main.dart 77:46                           [_isSelectionWithinTextBounds]
packages/flutter/src/widgets/editable_text.dart 3934:28             [_handleSelectionChanged]
packages/flutter/src/widgets/editable_text.dart 4184:7              [_formatAndSetValue]
packages/flutter/src/widgets/editable_text.dart 4554:5              userUpdateTextEditingValue
packages/flutter/src/rendering/editable.dart 719:5                  [_setTextEditingValue]
packages/flutter/src/rendering/editable.dart 738:5                  [_setSelection]
packages/flutter/src/rendering/editable.dart 2088:5                 selectPositionAt
packages/flutter/src/rendering/editable.dart 2065:5                 selectPosition
packages/flutter/src/widgets/text_selection.dart 2260:9             onTapDown
packages/flutter/src/widgets/text_selection.dart 3283:23            [_handleTapDown]
packages/flutter/src/gestures/tap_and_drag.dart 1179:41             <fn>
packages/flutter/src/gestures/recognizer.dart 344:24                invokeCallback
packages/flutter/src/gestures/tap_and_drag.dart 1179:7              [_checkTapDown]
packages/flutter/src/gestures/tap_and_drag.dart 982:7               acceptGesture
packages/flutter/src/gestures/arena.dart 269:10                     [_resolveByDefault]
packages/flutter/src/gestures/arena.dart 249:31                     callback
dart-sdk/lib/async/schedule_microtask.dart 40:11                    _microtaskLoop
dart-sdk/lib/async/schedule_microtask.dart 49:5                     _startMicrotaskLoop
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 181:7  <fn>

Handler: "onTapDown"
Recognizer:
  TapAndPanGestureRecognizer#aceca
════════════════════════════════════════════════════════════════════════════════════════════════════

Flutter Doctor output

Doctor output
[√] Flutter (Channel stable, 3.19.6, on Microsoft Windows [Version 10.0.22621.3007], locale pt-BR)
    • Flutter version 3.19.6 on channel stable at C:\Users\felip_0vh5fa6\.puro\envs\stable\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 54e66469a9 (11 days ago), 2024-04-17 13:08:03 -0700
    • Engine revision c4cd48e186
    • Dart version 3.3.4
    • DevTools version 2.34.3

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at C:\Users\felip_0vh5fa6\AppData\Local\Android\sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: C:\Users\felip_0vh5fa6\AppData\Local\Programs\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.4.5)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.4.33403.182
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2023.2)
    • Android Studio at C:\Users\felip_0vh5fa6\AppData\Local\Programs\Android Studio
    • 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.9+0--11185874)

[√] IntelliJ IDEA Community Edition (version 2024.1)
    • IntelliJ at C:\Users\felip_0vh5fa6\AppData\Local\Programs\IntelliJ IDEA Community Edition
    • Flutter plugin version 78.5.1
    • Dart plugin version 241.15845

[√] VS Code (version 1.89.1)
    • VS Code at C:\Users\felip_0vh5fa6\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.78.0

[√] VS Code (version 1.88.0-insider)
    • VS Code at C:\Users\felip_0vh5fa6\AppData\Local\Programs\Microsoft VS Code Insiders
    • Flutter extension version 3.64.0

[√] Connected device (4 available)
    • SM S918B (mobile) • fmorschel-phone:33587 • android-arm64  • Android 14 (API 34)
    • Windows (desktop) • windows               • windows-x64    • Microsoft Windows [Version 10.0.22621.3007]
    • Chrome (web)      • chrome                • web-javascript • Google Chrome 125.0.6422.60
    • Edge (web)        • edge                  • web-javascript • Microsoft Edge 124.0.2478.80

[√] Network resources
    • All expected network resources are available.

• No issues found!

Activity

  1. FMorschel commented on May 20, 2024

    @FMorschel
    ContributorAuthor

    More context:

    I've filed #148033 before and this has the same end objective. I'm wrapping both classes to create a single controller to a custom TextField within my project.

  2. FMorschel commented on May 20, 2024

    @FMorschel
    ContributorAuthor

    Later today I'll try to recreate a minimal reproducible code for something that happened on my app. I have two of these DelegatingTextEditingControllers and two TextFields on the same page, I could simply not change my focus to the second TextField while using that DelegatingTextEditingController instance.

  3. FMorschel commented on May 20, 2024

    @FMorschel
    ContributorAuthor

    Found #148471 which is what I meant. I think I'll close this and defer to that.

  4. danagbemava-nc commented on May 21, 2024

    @danagbemava-nc
    Member

    Related to #148471

    Labeling for further investigation.

    flutter doctor -v
    [✓] Flutter (Channel stable, 3.22.0, on macOS 14.4.1 23E224 darwin-arm64, locale en-GB)
        • Flutter version 3.22.0 on channel stable at /Users/nexus/dev/sdks/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 5dcb86f68f (12 days ago), 2024-05-09 07:39:20 -0500
        • Engine revision f6344b75dc
        • Dart version 3.4.0
        • DevTools version 2.34.3
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-34, build-tools 34.0.0
        • Java binary at: /Users/nexus/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 15.3)
        • Xcode at /Applications/Xcode-15.3.0.app/Contents/Developer
        • Build 15E204a
        • CocoaPods version 1.15.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2023.1)
        • Android Studio at /Users/nexus/Applications/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.7+0-17.0.7b1000.6-10550314)
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.2.5)
        • IntelliJ at /Users/nexus/Applications/IntelliJ IDEA Ultimate.app
        • Flutter plugin version 77.2.2
        • Dart plugin version 232.10286
    
    [✓] VS Code (version 1.89.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.88.0
    
    [✓] Connected device (4 available)
        • Nexus (mobile)                  • 00008020-001875E83A38002E • ios            • iOS 17.4.1 21E236
        • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 14.4.1 23E224 darwin-arm64
        • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 14.4.1 23E224 darwin-arm64
        • Chrome (web)                    • chrome                    • web-javascript • Google Chrome 124.0.6367.208
        ! Error: Browsing on the local area network for Dean’s iPad. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
          The device must be opted into Developer Mode to connect wirelessly. (code -27)
    
    [✓] Network resources
        • All expected network resources are available.
    
    • No issues found!
    
    [!] Flutter (Channel master, 3.22.0-39.0.pre.2, on macOS 14.4.1 23E224 darwin-arm64, locale en-GB)
        • Flutter version 3.22.0-39.0.pre.2 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 d02292dbc4 (4 hours ago), 2024-05-20 21:25:37 -0700
        • Engine revision c2ef01f6f1
        • Dart version 3.5.0 (build 3.5.0-172.0.dev)
        • DevTools version 2.36.0-dev.10
        • 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 34.0.0)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-34, build-tools 34.0.0
        • Java binary at: /Users/nexus/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 15.3)
        • Xcode at /Applications/Xcode-15.3.0.app/Contents/Developer
        • Build 15E204a
        • CocoaPods version 1.15.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2023.1)
        • Android Studio at /Users/nexus/Applications/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.7+0-17.0.7b1000.6-10550314)
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.2.5)
        • IntelliJ at /Users/nexus/Applications/IntelliJ IDEA Ultimate.app
        • Flutter plugin version 77.2.2
        • Dart plugin version 232.10286
    
    [✓] VS Code (version 1.89.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.88.0
    
    [✓] Connected device (4 available)
        • Nexus (mobile)                  • 00008020-001875E83A38002E • ios            • iOS 17.4.1 21E236
        • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 14.4.1 23E224 darwin-arm64
        • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 14.4.1 23E224 darwin-arm64
        • Chrome (web)                    • chrome                    • web-javascript • Google Chrome 124.0.6367.208
        ! Error: Browsing on the local area network for Dean’s iPad. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
          The device must be opted into Developer Mode to connect wirelessly. (code -27)
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
    
    
  5. added
    c: regressionIt was better in the past than it is now
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    team-designOwned by Design Languages team
    and removed
    in triagePresently being triaged by the triage team
    on May 21, 2024
  6. added and removed
    team-designOwned by Design Languages team
    on May 22, 2024
  7. added
    P2Important issues not at the top of the work list
    on May 23, 2024
  8. FMorschel commented on May 28, 2024

    @FMorschel
    ContributorAuthor

    Can this be cherry-picked into Flutter version 3.22.2? Or should I create a new issue for requesting this?

  9. added
    r: fixedIssue is closed as already fixed in a newer version
    on May 30, 2024
  10. github-actions commented on Jun 13, 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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: regressionIt was better in the past than it is nowfound in release: 3.22Found to occur in 3.22frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer versionteam-text-inputOwned by Text Input teamtriaged-text-inputTriaged by Text Input team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions