Upgrading provider 0.0 to 1
Breaking0.0.1 → 1.6.1Breaking3Deprecated1New11
BreakingUpgrade verdict
3 breaking changes.
In plain terms
- Looking up a provider that does not exist above the widget now throws an error instead of silently returning something.
- StatefulProvider is back, but its API changed. Two callbacks no longer receive a second argument, and the value builder now runs only once instead of repeatedly.
- Code that supplies a valueBuilder must now accept a BuildContext argument.
- StatefulProvider is deprecated. Switch to a StatefulWidget or the new HookProvider.
Must act 4 items need code or config changes
What you must change
Breaking3
Provider.of<T> now crashes with a ProviderNotFoundException when no Provider<T> is found in the context's ancestors.Provider.of<T>Provider<T>ProviderNotFoundExceptionReintroduces StatefulProvider with a modified prototype: valueBuilder and didChangeDependencies lose their second argument, and valueBuilder is called only once per life cycle.
StatefulProvidervalueBuilderdidChangeDependenciesPasses
BuildContext to the valueBuilder callback.BuildContextvalueBuilderDeprecations to plan for
Deprecated1
Deprecates StatefulProvider; use a StatefulWidget or HookProvider instead.
StatefulProviderStatefulWidgetHookProviderAPI changes
Generated by DepDelta from published Dart source. Not mixed with prose notes.
- changed:
class Provider<T> extends InheritedWidget → class Provider<T> extends InheritedWidget implements ProviderBase - changed:
class StatefulProvider<T> extends StatefulWidget → class StatefulProvider<T> extends StatefulWidget implements ProviderBase - changed:
ctor Provider({Key key, this.value, Widget child}) → ctor Provider({ Key key, @required this.value, Widget child, UpdateShouldNotify<T> updateShouldNotify, }) - changed:
ctor StatefulProvider({Key key, this.valueBuilder, this.child}) → ctor StatefulProvider({ Key key, @required this.valueBuilder, this.child, this.onDispose, this.updateShouldNotify, }) - changed:
method StatefulProvider.Function(T previous): T → method StatefulProvider.Function(BuildContext context): T - added:
class ChangeNotifierProvider<T extends ChangeNotifier> extends HookWidget implements ProviderBase - added:
class Consumer2<A, B> extends StatelessWidget - added:
class Consumer3<A, B, C> extends StatelessWidget - added:
class Consumer4<A, B, C, D> extends StatelessWidget - added:
class Consumer5<A, B, C, D, E> extends StatelessWidget - added:
class Consumer6<A, B, C, D, E, F> extends StatelessWidget - added:
class Consumer<T> extends StatelessWidget - added:
class HookProvider<T> extends HookWidget implements ProviderBase - added:
class MultiProvider extends StatelessWidget implements ProviderBase - added:
class ProviderBase: abstract implements Widget - added:
class ProviderNotFoundError extends Error - added:
class StreamProvider<T> extends HookProvider<AsyncSnapshot<T>> - added:
class ValueListenableProvider<T> extends HookProvider<T> - added:
ctor ChangeNotifierProvider({Key key, @required T notifier, this.child}) - added:
ctor ChangeNotifierProvider.stateful({ Key key, @required ValueBuilder<T> builder, Disposer<T> disposer, this.child, }) - added:
ctor Consumer({Key key, @required this.builder}) - added:
ctor Consumer2({Key key, @required this.builder}) - added:
ctor Consumer3({Key key, @required this.builder}) - added:
ctor Consumer4({Key key, @required this.builder}) - added:
ctor Consumer5({Key key, @required this.builder}) - added:
ctor Consumer6({Key key, @required this.builder}) - added:
ctor HookProvider({Key key, this.hook, this.child, this.updateShouldNotify}) - added:
ctor MultiProvider({Key key, @required this.providers, this.child}) - added:
ctor ProviderNotFoundError( this.valueType, this.widgetType, ) - added:
ctor StreamProvider({ @required this.stream, Key key, T initialData, Widget child, }) - added:
ctor ValueListenableProvider({ @required this.valueListenable, Key key, Widget child, }) - added:
field ChangeNotifierProvider.child: final Widget - added:
field HookProvider.child: final Widget - added:
field MultiProvider.child: final Widget - added:
field MultiProvider.providers: final List<ProviderBase> - added:
field ProviderNotFoundError.valueType: final Type - added:
field ProviderNotFoundError.widgetType: final Type - added:
field StreamProvider.stream: final Stream<T> - added:
field ValueListenableProvider.valueListenable: final ValueListenable<T> - added:
method ChangeNotifierProvider.build(BuildContext context): Widget - added:
method ChangeNotifierProvider.cloneWithChild(Widget child): ChangeNotifierProvider<T> - added:
method Consumer.Function(BuildContext context, T value): Widget - added:
method Consumer.build(BuildContext context): Widget - added:
method Consumer2.Function(BuildContext context, A value, B value2): Widget - added:
method Consumer2.build(BuildContext context): Widget - added:
method Consumer3.Function(BuildContext context, A value, B value2, C value3): Widget - added:
method Consumer3.build(BuildContext context): Widget - added:
method Consumer4.Function( BuildContext context, A value, B value2, C value3, D value4): Widget - added:
method Consumer4.build(BuildContext context): Widget - added:
method Consumer5.Function( BuildContext context, A value, B value2, C value3, D value4, E value5): Widget - added:
method Consumer5.build(BuildContext context): Widget - added:
method Consumer6.Function(BuildContext context, A value, B value2, C value3, D value4, E value5, F value6): Widget - added:
method Consumer6.build(BuildContext context): Widget - added:
method HookProvider.Function(): T - added:
method HookProvider.Function(T, T): bool - added:
method HookProvider.build(BuildContext context): Widget - added:
method HookProvider.cloneWithChild(Widget child): HookProvider<T> - added:
method MultiProvider.build(BuildContext context): Widget - added:
method MultiProvider.cloneWithChild(Widget child): MultiProvider - added:
method Provider.Function(T previous, T current): bool - added:
method Provider.cloneWithChild(Widget child): Provider<T> - added:
method Provider.debugFillProperties(DiagnosticPropertiesBuilder properties): void - added:
method ProviderBase.cloneWithChild(Widget child): ProviderBase - added:
method ProviderNotFoundError.toString(): String - added:
method StatefulProvider.Function(BuildContext context, T value): void - added:
method StatefulProvider.Function(T previous, T current): bool - added:
method StatefulProvider.cloneWithChild(Widget child): StatefulProvider<T> - added:
static method StreamProvider.of<T>(BuildContext context): AsyncSnapshot<T>