felangel / bloc

A predictable state management library that helps implement the BLoC design pattern

Home Page:https://bloclibrary.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.