Home > Enterprise >  Error: Member not found: 'Scrollable.maybeOf'. final scrollableState = Scrollable.maybeOf(
Error: Member not found: 'Scrollable.maybeOf'. final scrollableState = Scrollable.maybeOf(

Time:02-02

Hello, good day everyone i encountered this error in my Android Studio Can someone help me about this i am on Flutter 3.3.8 Thank you so much

@override
  void didChangeDependencies() {
    super.didChangeDependencies();
    final scrollableState = Scrollable.maybeOf(context);
    if (scrollableState != null) {
      // The TypeAheadField is inside a scrollable widget
      _scrollPosition = scrollableState.position;

      _scrollPosition!.removeListener(_scrollResizeListener);
      _scrollPosition!.isScrollingNotifier.addListener(_scrollResizeListener);
    }
  }

/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_typeahead-4.3.1/lib/src/flutter_typeahead.dart:898:40: Error: Member not found: 'Scrollable.maybeOf'. final scrollableState = Scrollable.maybeOf(context); ^^^^^^^ /C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_typeahead-4.3.1/lib/src/cupertino_flutter_typeahead.dart:649:40: Error: Member not found: 'Scrollable.maybeOf'. final scrollableState = Scrollable.maybeOf(context); ^^^^^^^

I am expecting someone could help me about this flutter and my project, Ill promise after i learn coding i will payback all the help to the one in needs.!!!!

CodePudding user response:

Update your flutter_typeahead dependency version to at least 4.3.1 on your pubspec.yaml file.

By the widget change log it states that this has been fixed on 28-January-2023

PR #447 - fix: Use maybeOf for scrollable to not throw an exception in flutter …

See change log: https://pub.dev/packages/flutter_typeahead/changelog#431---28-january-2023

CodePudding user response:

goto path by ctrl click on path provided in console. change maybeOf to of. Run flutter pub get in terminal and error is gone.

  • Related