bloc

BLoC: how to pass it?

佐手、 提交于 2019-12-24 08:12:31
问题 I would like to know the best way to pass the bloc. I read about the bloc providers, but what`s the difference between using them and just passing the bloc in the constructor like: ExampleView X = ExampleView(bloc,...) Actually I find this way easier to test and also a better way to keep the code cleaner. For example, if I have more blocs, something like this can happen: XBlocProvider( bloc: XBloc, child: YBlocProvider( bloc: Y, child: ZBlocProvider... ) or maybe it's just my lack of

StreamBuilder throws dirty state

狂风中的少年 提交于 2019-12-13 03:22:43
问题 I am trying to fetch some data from the internet, store it to my sqlite database and display it on the screen using a ListView . When I fetch the data for the first time everything works fine and I am able to see the data on the screen, the data is also inserted in the sqlite database, but when I reopen the app I get an error saying flutter: The following NoSuchMethodError was thrown building StreamBuilder<StudentModel>(dirty, state: flutter: _StreamBuilderBaseState<StudentModel,

Flutter simple implementation to handle click event with Bloc work once

谁说胖子不能爱 提交于 2019-12-13 03:15:35
问题 I just learn about how can i use Bloc in flutter applications and my simple app i have some separated view class as App and MainPage and i implemented simple Bloc pattern to handle click event on some widgets such as button after running application my implemented bloc pattern only work once and show message in console and after click again that don't work to show message my main.dart class void main() { runApp(MaterialApp( debugShowCheckedModeBanner: false, title: Strings.appName, theme:

BlocProvider.of() called with a context that does not contain a Bloc of type CLASS

久未见 提交于 2019-12-12 12:23:35
问题 in flutter i just learn how can i use Bloc on applications and i want to try to implementing simple login with this feature. after implementing some class of bloc to using that on view i get error when i try to use this code as BlocProvider.of<LoginListingBloc>(context).dispatch(LoginEvent(loginInfoModel: testLogin)); inside RaisedButton Error: BlocProvider.of() called with a context that does not contain a Bloc of type LoginListingBloc. My view : class _HomePageState extends State<HomePage>

implementing simple rxDart with Bloc don't get result

我是研究僧i 提交于 2019-12-11 16:45:34
问题 from this link on my web server as http://instamaker.ir/api/v1/getPersons i'm trying to get result and printing avatar from that result, unfortunately my implementation with rxDart and Bloc don't get result from this response and i don't get any error server response this simplified result: { "active": 1, "name": "my name", "email": " 3 ", "loginType": " 3 ", "mobile_number": " 3 ", ... "api_token": "1yK3PvAsBA6r", "created_at": "2019-02-12 19:06:34", "updated_at": "2019-02-12 19:06:34" }

Unhandled Exception: type 'Future<void>' is not a subtype of type 'Future<Photography>' on Firestore

安稳与你 提交于 2019-12-11 14:48:54
问题 I need to get all the data from the firestore database. I follow this way, https://stackoverflow.com/a/55865045/9139407 Future<Photography> getPhotography() { Future<Photography> data = await db .collection('photography') .document('0yUc5QBGHNNq6WK9CyyF') .setData(jsonDecode(jsonEncode(Photography( [AllImages(["list"])], "image_url", "Shanika", "image_url", "lovely couple", "Bhanuka" )))); return data; } The error message is: Unhandled Exception: type 'Future< void >' is not a subtype of type

Bloc architecture “the getter x was called on null.”

对着背影说爱祢 提交于 2019-12-11 14:21:42
问题 I am trying to use Bloc Architecture to set the Color state of child widgets, according to the documentation, and it just doesn't work. Here are my relevant files: blocProvider.dart import 'package:flutter/material.dart'; Type _typeOf<T>() => T; abstract class BlocBase { void dispose(); } class BlocProvider<T extends BlocBase> extends StatefulWidget { BlocProvider({ Key key, @required this.child, @required this.bloc, }) : super(key: key); final Widget child; final T bloc; @override

Bloc stream not updating properly

纵饮孤独 提交于 2019-12-11 12:26:11
问题 This is a direct follow on from: Bloc architecture "the getter x was called on null." which was resolved by @nonybrighto The issue now is that although I am getting no error from the application any more, the logic is failing somewhere as the colours are not updating, they just remain blue. If I call: colorBloc.changeColor(); from either a callback to the child (dropdownmenu) itself, or directly from the parent, it just doesn't actually update the colours of these widget buttons. They are

flutter: Unhandled Exception: Bad state: Cannot add new events after calling close

丶灬走出姿态 提交于 2019-12-09 18:31:55
问题 I am trying to use the bloc pattern to manage data from an API and show them in my widget. I am able to fetch data from API and process it and show it, but I am using a bottom navigation bar and when I change tab and go to my previous tab, it returns this error: Unhandled Exception: Bad state: Cannot add new events after calling close. I know it is because I am closing the stream and then trying to add to it, but I do not know how to fix it because not disposing the publishsubject will result

Bloc, Flutter and Navigation

十年热恋 提交于 2019-12-09 08:00:34
问题 So like most, i'm new to Bloc and flutter and dart and wrapping my head around. I've googled, looked through the posts here but haven't found really any answers. So this is about navigation with bloc and flutter. Take the example of a Login. So there is a login page with a bloc behind it and at some point someone presses a button to login. So we can call a function in the bloc that does the validation. I think this is against the strict approach but i see people doing this. But then if login