hey when i update the version 0.13.0 to 0.19.1 there has some error
1.BlocProvider miss the bloc params
2.BlocSupervisor doesn't have a default constructor
can you show me how to fix it! tks
Hey @Huai-Dc !
flutter_blocAccording to the changelogs and the sources that you can read.
Since the version 0.16.0 the BlocProvider expose a builder and a bool dispose property.
Since the version 0.17.0 the BlocProvider is automatically disposing the bloc (can be forced with bool dispose property).
Since the version 0.19.0 flutter_bloc is now extending classes from the provider with different constructors.
As you can see here, BlocProvider can now be constructed two different ways.
If you want to let the provider to auto-dispose the bloc you can use the new implementation of the default constructor:
BlocProvider(
builder: (context)=> MyBloc(),
);
If you still want to manage the lifecycle of your bloc you can use the named constructor BlocProvider.value(/*omitted*/) :
MyBloc mybloc = MyBloc();
/* ... */
BlocProvider.value(
value: myBloc,
);
So if you are coming from 0.13.0 you can easily migrate from :
BlocProvider(
bloc: myBloc,
);
to
BlocProvider.value(
value: myBloc
);
blocAccording to the doc :
0.14.0 the BlocSupervisor have been improved.So the constructor of BlocSupervisor is no longer exposed but you can still use it by migrating from :
BlocSupervisor().delegate = /*...*/;
to
BlocSupervisor.delegate = /*...*/;
thank you
Most helpful comment
Hey @Huai-Dc !
BlocProvider from
flutter_blocAccording to the changelogs and the sources that you can read.
Since the version
0.16.0theBlocProviderexpose abuilderand abool disposeproperty.Since the version
0.17.0theBlocProvideris automatically disposing the bloc (can be forced withbool disposeproperty).Since the version
0.19.0flutter_blocis now extending classes from theproviderwith different constructors.As you can see here,
BlocProvidercan now be constructed two different ways.BlocProvider with builder
If you want to let the provider to auto-dispose the bloc you can use the new implementation of the default constructor:
BlocProvider with value
If you still want to manage the lifecycle of your bloc you can use the named constructor
BlocProvider.value(/*omitted*/):Migration
So if you are coming from
0.13.0you can easily migrate from :to
BlocSupervisor from
blocAccording to the doc :
0.14.0theBlocSupervisorhave been improved.Migration
So the constructor of
BlocSupervisoris no longer exposed but you can still use it by migrating from :to