bloc

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

How to create a BlocListener that can listen to all pages in flutter with access to MaterialApp context?

荒凉一梦 提交于 2021-01-28 19:05:25
问题 I'm trying to create a BlocListener that has the ability to listen to all pages/routes throughout the app just like how you can access a Bloc or a Provider all throughout the app if they are defined at root-level like in the code below runApp( MultiProvider( providers: [ ChangeNotifierProvider<IdentityTokenProvider>( create: (_) => IdentityTokenProvider(), ), ], child: MultiBlocProvider( providers: [ BlocProvider<AuthBloc>( create: (_) => AuthBloc(), ), ], child: MaterialApp(

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

how to use same bloc in multiple widgets

僤鯓⒐⒋嵵緔 提交于 2021-01-22 07:56:46
问题 I'm facing issue in my current project so created this question im unable to get same bloc state in other widget i tried this https://github.com/felangel/bloc/issues/74#issuecomment-457968962 but i'm getting BlocProvider.of() called with a context that does not contain a Bloc of type CounterBloc. error if add Provider again in other widget another state is created for that page how to use same bloc state in different widgets. import 'dart:async'; import 'package:flutter/material.dart'; import

how to use same bloc in multiple widgets

有些话、适合烂在心里 提交于 2021-01-22 07:56:10
问题 I'm facing issue in my current project so created this question im unable to get same bloc state in other widget i tried this https://github.com/felangel/bloc/issues/74#issuecomment-457968962 but i'm getting BlocProvider.of() called with a context that does not contain a Bloc of type CounterBloc. error if add Provider again in other widget another state is created for that page how to use same bloc state in different widgets. import 'dart:async'; import 'package:flutter/material.dart'; import

Didier Boelens' Reactive Programming BLoC or how to implement an app wide BLoC

▼魔方 西西 提交于 2021-01-01 09:55:29
问题 I was looking into quite a few pages to learn how to best implement an app wide bloc (for authentication, user management and initialization). I did not find so much and for a beginner regarding this level of bloc patterns I found it hard to identify a reasonable one. The pattern by Didier Boelens explained here appears to be the most promising one. Is it still a sound pattern (it is from 2018) or did the bloc library evolve in the meantime or did other patterns proved better/easier? What

Didier Boelens' Reactive Programming BLoC or how to implement an app wide BLoC

余生长醉 提交于 2021-01-01 09:55:13
问题 I was looking into quite a few pages to learn how to best implement an app wide bloc (for authentication, user management and initialization). I did not find so much and for a beginner regarding this level of bloc patterns I found it hard to identify a reasonable one. The pattern by Didier Boelens explained here appears to be the most promising one. Is it still a sound pattern (it is from 2018) or did the bloc library evolve in the meantime or did other patterns proved better/easier? What

How to rebuild all grid items in flutter?

谁都会走 提交于 2021-01-01 08:01:02
问题 I have a dashboard , represented by grid, that supposed to delete item on long press event (using flutter_bloc), but it deletes last item instead of selected. All debug prints show, that needed element actually removed from list, but view layer still keeps it. My build function code: Widget build(BuildContext context) { double pyxelRatio = MediaQuery.of(context).devicePixelRatio; double width = MediaQuery.of(context).size.width * pyxelRatio; return BlocProvider( bloc: _bloc, child:

How to rebuild all grid items in flutter?

主宰稳场 提交于 2021-01-01 07:59:08
问题 I have a dashboard , represented by grid, that supposed to delete item on long press event (using flutter_bloc), but it deletes last item instead of selected. All debug prints show, that needed element actually removed from list, but view layer still keeps it. My build function code: Widget build(BuildContext context) { double pyxelRatio = MediaQuery.of(context).devicePixelRatio; double width = MediaQuery.of(context).size.width * pyxelRatio; return BlocProvider( bloc: _bloc, child:

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