When using the class Bloc provider as follows, I get the error:
'The method 'ancestorInheritedElementForWidgetOfExactType' isn't defined for the type 'BuildContext'.'
So I replaced this line context.ancestorInheritedElementForWidgetOfExactType(type)?.widget;
with this line context.getElementForInheritedWidgetOfExactType<_BlocProviderInherited<T>>().widget;
but then I get the following Error:
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/dynamic_theme-1.0.1/lib/dynamic_theme.dart:25:20: Error: The method 'ancestorStateOfType' isn't defined for the class 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../../development/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'.
return context.ancestorStateOfType(const TypeMatcher<DynamicThemeState>());
^^^^^^^^^^^^^^^^^^^
Command PhaseScriptExecution failed with a nonzero exit code
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
Could not build the precompiled application for the device.
Error launching application on iPhone
This is the Bloc Provider i am using:
class BlocProvider<T extends BlocBase> extends StatefulWidget {
BlocProvider({
Key key,
@required this.child,
@required this.bloc,}) : super(key: key);
final Widget child;
final T bloc;
@override
_BlocProviderState<T> createState() => _BlocProviderState<T>();
static T of<T extends BlocBase>(BuildContext context) {
final type = _typeOf<_BlocProviderInherited<T>>();
_BlocProviderInherited<T> provider =
context.ancestorInheritedElementForWidgetOfExactType(type)?.widget;
return provider?.bloc;
}
}
I am on the Master channel, Flutter (Channel master, 1.26.0-2.0.pre.275)