flutter-bloc

The superclass 'Bloc<xxx, xxx>' doesn't have a zero argument constructor in dart

安稳与你 提交于 2021-02-07 18:46:43
问题 I am a beginner in Dart language development. I try to create a sample flutter application BLOC pattern inspired by this GitHub repo, but I got some error message related to the class inheritance. I am already familiar with the inheritance and superclass and subclass programming in the dot net C# language. But in the case of the dart, I need some advice. Here is my code: class UserRegBloc extends Bloc<UserRegEvent, UserRegState> { UserRepository userRepository; UserRegBloc({@required

The superclass 'Bloc<xxx, xxx>' doesn't have a zero argument constructor in dart

China☆狼群 提交于 2021-02-07 18:46:22
问题 I am a beginner in Dart language development. I try to create a sample flutter application BLOC pattern inspired by this GitHub repo, but I got some error message related to the class inheritance. I am already familiar with the inheritance and superclass and subclass programming in the dot net C# language. But in the case of the dart, I need some advice. Here is my code: class UserRegBloc extends Bloc<UserRegEvent, UserRegState> { UserRepository userRepository; UserRegBloc({@required

Flutter: How do I pop dialog as well as current page?

别等时光非礼了梦想. 提交于 2021-01-29 19:07:50
问题 Below is the code. Navigation to Login page, from Home page ElevatedButton( onPressed: () => Navigator.of(context, rootNavigator: true) .push(MaterialPageRoute( fullscreenDialog: true, builder: (context) => UserLoginPage(), )), child: Text('Login to continue'), ), Inside Login page: BlocConsumer<UserAuthCubit, UserAuthState>( listener: (context, state) { if (state is UserAuthorized) { Navigator.of(context, rootNavigator: true).pop(); } if (state is UserAuthWaiting) { showModalBottomSheet(

flutter bloc and how a bloc state change can then trigger a 2nd async call before updating the Widget/UI with both? (code attached)

此生再无相见时 提交于 2021-01-29 15:32:52
问题 How would one load a set of local images for display in a widget (noting this is async - see function below) triggered by (based on) a change in state from a flutter_bloc for “settings”? Noting this bloc is persisted too via hydrated_bloc. So the use case for which I’m asking how do I code this in flutter (noting I’m using flutter_bloc) is: Use Case - Render different set of images on the same Widget I have for dynamically displaying a room for a 2D point & click adventure type game, BASED ON

What are disadvantages of using flutter_bloc library

邮差的信 提交于 2021-01-29 04:19:38
问题 There are many versions of implementation of BLoC pattern. One of them is flutter_bloc by Felix Angelov. On one of the social medias I came across of the statement that flutter_bloc is not a good choice for the project and another BLoC or another state management should be chosen instead . Actually it was a small standard project separated into layers:domain,application,infrastructure and presentation. Nothing special about it. So the guy who complained about the wrong choice was saying that

Flutter, using a bloc in a bloc

家住魔仙堡 提交于 2021-01-28 21:22:22
问题 I have two BLoCs. EstateBloc EstateTryBloc My Application basically gets estates from an API and displays them in a similar fashion Now I wanted to add a sort functionality, but I could only access the List of Estates via a specific state. if(currentState is PostLoadedState){{ print(currentState.estates); } I wanted to make the List of estates available for whichever bloc, that needed that list. What I did was, I created the EstateTryBloc, which basically contains the List of estates as a

Async request using BLoC in Flutter

梦想的初衷 提交于 2021-01-28 06:24:13
问题 I would like download the data, but also use the application all the time. Can you tell me if it's right solution? The case is we press button download and call funtion bloc.dispatch(Event.download()); In mapEventToState in _Download event we reqest data. But we don't wait for response because we don't want to block others events which are changing view. So I create Future and after getting response I call event _UpdateData() where I process downloaded data and generate state with them. It's

Flutter listen Bloc state from Other Bloc

拥有回忆 提交于 2020-12-30 08:14:32
问题 Hello I'm trying to listen state of bloc form other bloc. I'm using this package https://pub.dev/packages/bloc From my UserBloc I want listen AuthBloc and when It has the state AuthenticationAuthenticated the UserBloc should fire an event. final UserRepository userRepository; final authBloc; StreamSubscription authSub; UserBloc({ @required this.userRepository, @required this.authBloc}) { authSub = authBloc.listen((stateAuth) { //here is my problem because stateAuth, even is

Flutter listen Bloc state from Other Bloc

生来就可爱ヽ(ⅴ<●) 提交于 2020-12-30 08:12:44
问题 Hello I'm trying to listen state of bloc form other bloc. I'm using this package https://pub.dev/packages/bloc From my UserBloc I want listen AuthBloc and when It has the state AuthenticationAuthenticated the UserBloc should fire an event. final UserRepository userRepository; final authBloc; StreamSubscription authSub; UserBloc({ @required this.userRepository, @required this.authBloc}) { authSub = authBloc.listen((stateAuth) { //here is my problem because stateAuth, even is

Triggering initial event in BLoC

痴心易碎 提交于 2020-12-29 13:18:30
问题 example_states: abstract class ExampleState extends Equatable { const ExampleState(); } class LoadingState extends ExampleState { // } class LoadedState extends ExampleState { // } class FailedState extends ExampleState { // } example_events: abstract class ExampleEvent extends Equatable { // } class SubscribeEvent extends ExampleEvent { // } class UnsubscribeEvent extends ExampleEvent { // } class FetchEvent extends ExampleEvent { // } example_bloc: class ExampleBloc extends Bloc