Im experimenting with flutter, and ive came up with many projects on github that declare the repositories and pass them to the bloc on the UI side. Why is that the proper way to do it and not on the backend side (on the bloc) ?
Example:
class MyApp extends StatelessWidget {
final authenticationRepository = AuthenticationRepository();
final accountRepository = AccountRepository();
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'My App',
debugShowCheckedModeBanner: false,
home: MultiRepositoryProvider(
providers: [
RepositoryProvider(create: (_) => authenticationRepository),
RepositoryProvider(create: (_) => accountRepository),
],
child: BlocProvider(
create: (_) => AuthenticationBloc(
authenticationRepository: authenticationRepository,
accountRepository: accountRepository,
),
child: Container(); // I removed the content here
),
),
),
);
}
}
Thank you