I had Bloc class before using BlocProvider as below.
And I want to use blockProvider using 'flutter_bloc 4.0.0'.
class SelfRentalBloc {
final _srsController = StreamController<List<SelfRental>>.broadcast();
get srs => _srsController.stream;
SelfRentalBloc() {
getSRs();
}
... more code
}
So I added blocProvider in myApp.dart. void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (BuildContext context) => SelfRentalBloc(),
child: MaterialApp(
initialRoute: '/',
routes: {
'/': (BuildContext context) => HomePage(),
'/page': (BuildContext context) => Page(),
},
));
}
}
But It says SelfRental doesn't extend Bloc.
I think I have to modify SelfRentalBloc class above.
But I don't know how to make it. Could you recommend some solution? Thank you for reading it.
I've already read documentation of flutter_bloc. but it 's too hard to understand for my case due to my low level flutter.