felangel / bloc

A predictable state management library that helps implement the BLoC design pattern
https://bloclibrary.dev
MIT License
11.77k stars 3.39k forks source link

fix: MultiBlocProvider and easy_localization library problem #4117

Closed ljoly83 closed 6 months ago

ljoly83 commented 6 months ago

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. .

ljoly83 commented 6 months ago

I close as the first solution finaly dont work. Have to found the issue.

ljoly83 commented 6 months ago

I close as the first solution finaly dont work. Have to found the issue.