fix: MultiBlocProvider and easy_localization library problem
ljoly83 opened this issue · comments
Description
MultiBlocProvider doesn't work with easy_localization library if declared before MaterialApp
Steps To Reproduce
This work:
class MyApp extends StatelessWidget {
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
localizationsDelegates: context.localizationDelegates,
supportedLocales: context.supportedLocales,
locale: context.locale,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MultiBlocProvider(
providers: [
BlocProvider(
create: (_) => GetUserBloc(GetUserUseCase()),
)
],
child: UserView(),
));
}
}
This doesn't work (but should)
@OverRide
Widget build(BuildContext context) {
return MultiBlocProvider(
providers: [
BlocProvider(
create: (_) => GetUserBloc(GetUserUseCase()),
)
],
child: MaterialApp(
supportedLocales: context.supportedLocales,
localizationsDelegates: context.localizationDelegates,
locale: context.locale,
home: const UserView(),
),
);
}
}
Expected Behavior
It should work with MultiBlocProvider at top level as it is the recommand way.
.
I close as the first solution finaly dont work. Have to found the issue.
I close as the first solution finaly dont work. Have to found the issue.