Flutter master branch issue - The method 'ancestorStateOfType' isn't defined for the class 'BuildContext'.
Theunodb opened this issue · 6 comments
For future release:
If you are in the latest master branch of flutter the ios build fails with this error:
./../../../.pub-cache/hosted/pub.dartlang.org/flutter_google_places-0.2.6/lib/src/flutter_google_places.dart:74:15: Error: The method 'ancestorStateOfType' isn't defined for the class 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../../../flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'ancestorStateOfType'.
context.ancestorStateOfType(const TypeMatcher<PlacesAutocompleteState>());
^^^^^^^^^^^^^^^^^^^
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 1.26.0-2.0.pre.402, on macOS 11.1 20C69 darwin-x64, locale en-ZA)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2020.3.1)
[✓] Connected device (2 available)
This change is now in Flutter beta so really needing a fix.
Please, trying use my fork: https://github.com/hoc081098/flutter_google_places
flutter_google_places:
git:
url: https://github.com/hoc081098/flutter_google_places.git
ref: feature/restricted-api-keys
I am using beta channel. I receive similar error:
./../../.pub-cache/hosted/pub.dartlang.org/flutter_google_places-0.2.6/lib/src/flutter_google_places.dart:74:15: Error: The method 'ancestorStateOfType' isn't defined for the class 'BuildContext'.
in pubspec.yaml: flutter_google_places: ^0.2.6
I made this change:
static PlacesAutocompleteState of(BuildContext context) =>
// context.ancestorStateOfType(const TypeMatcher<PlacesAutocompleteState>());
context.findAncestorStateOfType<PlacesAutocompleteState>();
in c:\src\flutter.pub-cache\hosted\pub.dartlang.org\flutter_google_places-0.2.6\lib\src\flutter_google_places.dart
and it works
I'm still seeing this error, when could I install a fix?
I upgraded flutter_google_places to ^0.2.8 and rxdart to ^0.25.0 and it worked :D