bloc

Flutter BLoC - How to pass parameter to event?

非 Y 不嫁゛ 提交于 2020-07-08 15:25:12
问题 Trying to learn BLoCs I came up with this problem. I have some code in which I generate some buttons with BLoC pattern. However, I have no clue how to update specific buttons properties with dispatch(event) method. How to pass parameters to the event ChangeSomeValues ?? The part where the BLoC is used BlocBuilder( bloc: myBloc, builder: (context, state) { return ListView.builder( itemCount: state.buttonList.length, itemBuilder: (context, index) { return MyButton( label: buttonList[index]

Flutter BLoC - How to pass parameter to event?

感情迁移 提交于 2020-07-08 15:20:40
问题 Trying to learn BLoCs I came up with this problem. I have some code in which I generate some buttons with BLoC pattern. However, I have no clue how to update specific buttons properties with dispatch(event) method. How to pass parameters to the event ChangeSomeValues ?? The part where the BLoC is used BlocBuilder( bloc: myBloc, builder: (context, state) { return ListView.builder( itemCount: state.buttonList.length, itemBuilder: (context, index) { return MyButton( label: buttonList[index]

What are the difference between business logic and UI logic?

人盡茶涼 提交于 2020-06-17 00:07:32
问题 I am learning state management in flutter and most of the time I encounter with words business logic ui logic and some time presentation logic , I searched it on the internet as people explain it in different languages, I couldn't get a better understanding, Could someone please show these three types of logic in the form of an example and explain it very clean and easy? 回答1: When we use a library, it is our responsibility and mission to separate it from critical parts of our code, which is

Flutter BloC not refresh my view (counter app)

浪子不回头ぞ 提交于 2020-06-16 17:16:16
问题 I'm trying BloC library with Counter test app but I have a little problem on my view when I use object to increment/decrement my counter. MyObject.MyProperty increment or decrement but my view not refreshed. Why? Sample app with simple int variable. My code with object: import 'dart:async'; import 'package:flutter/material.dart'; import 'package:bloc/bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; void main() { runApp(App()); } class App extends StatelessWidget { @override Widget

Flutter BlocListener executed only once even after event gets re-fired

若如初见. 提交于 2020-05-30 11:27:28
问题 I am implementing Reso Coder's clean architecture in flutter. I followed his guides in dividing the project to layers and using dependency injection. In one of the cases I want to have the following scenario: An administrator user logs in, sees data on their home screen, edits it and by pressing a button, saves the data to the local db (sqflite). Upon saving the data I want to show a Snackbar with some sort of text "Settings saved!" for example. Here's my code (parts): class AdministratorPage

mapEventToState triggers one time only

给你一囗甜甜゛ 提交于 2020-05-21 01:58:56
问题 What am I doing wrong here that my state in a Bloc Pattern changes only one time then mapEventToState doesn't react to BlocProvider.of<CounterBloc>(context).add(ActiveEvent()); request? I am trying to get into the way of things with the Bloc Pattern but when I switch state in the switcher on a counter page the state changes and after that, it doesn't update at all. It's like don't go any further from onChanged switch function. I guess the issue is in my stream subscription which is

mapEventToState triggers one time only

此生再无相见时 提交于 2020-05-21 01:58:11
问题 What am I doing wrong here that my state in a Bloc Pattern changes only one time then mapEventToState doesn't react to BlocProvider.of<CounterBloc>(context).add(ActiveEvent()); request? I am trying to get into the way of things with the Bloc Pattern but when I switch state in the switcher on a counter page the state changes and after that, it doesn't update at all. It's like don't go any further from onChanged switch function. I guess the issue is in my stream subscription which is