Questions tagged [flutter-bloc]

For questions relating to the "flutter_bloc" package for the Flutter framework. Use this tag in combination with the general [flutter] tag. If your question applies to Flutter more generally, use the [flutter] tag only.

This tag should be used for any questions regarding the flutter_bloc package for the Flutter framework.

flutter_bloc is a package implementing the BloC pattern for Flutter, specifically the BlocProvider and BlocBuilder classes.

To get started, you can read through the README document on GitHub.

932 questions
4
votes
1 answer

Flutter Navigator 2.0 does not transition between root navigator pages

I'm using Navigator 2.0 API to handle navigation in my app, and I have problem with top-most RouterDelegate (the nested RouterDelegates underneath it work fine). Depending on authentication state I want to show Splash Screen, Login Screen, or Home…
4
votes
1 answer

Why is AnimatedList not building using list from bloc state in flutter?

I am trying to create an AnimatedList using bloc pattern, but ran into some problems. When I am setting initialItemsCount of AnimatedList to state.itemList.length, it does not build. Although when I am printing out state.itemList (that comes from…
4
votes
1 answer

How to manually change app language with Flutter_localizations and Bloc?

void main() async { runApp(MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key key}) : super(key: key); @override Widget build(BuildContext context) { return BlocProvider( create: (context) => LanguageCubit(), …
Raghim Najafov
  • 315
  • 3
  • 15
4
votes
1 answer

Error: Type argument 'RoutesBloc' doesn't conform to the bound 'BlocBase' of the type variable 'B' on 'BlocBuilder'

I'm getting this error and I have no clue where it's coming from. class Routes extends StatelessWidget { @override Widget build(BuildContext context) { return BlocBuilder( // <-- It occurs here builder:…
Matthias
  • 3,729
  • 22
  • 37
4
votes
2 answers

How to listen to multiple stream subscriptions in a bloc?

I'm trying to create a bloc that depends on two other blocs. For example, I have Bloc C which depends on Bloc A and Bloc B. I'm trying to do something like the following using flutter_bloc in order to achieve it : class BlocC extends Bloc<…
Yunet Luis Ruíz
  • 425
  • 4
  • 16
4
votes
1 answer

How I can change theme with a switch in flutter using bloc?

I am new in Flutter and bloc. I am making a app with bloc state management that can change the theme as the system theme changed. Now it work fine but I need switch that can override the theme. How can I implement that? I am making this app by…
Sunny Rahi
  • 99
  • 1
  • 6
4
votes
0 answers

Flutter initial state Cubit

When start the app, first work AuthCubit class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MultiBlocProvider( providers: [ BlocProvider( create: (context) =>…
Andrey Khan
  • 183
  • 1
  • 3
  • 13
4
votes
1 answer

Dialog state does not change after restarting (closing and opening again) in flutter

I have defined one button inside one StatelessWidget (This will have the bloc creation logic and injecting using bloc provider, ), on click of the button i am showing a dialog and passing the bloc instance to it, as shown in the code. //EsignBloc…
Purushotam Kumar
  • 1,002
  • 2
  • 13
  • 23
4
votes
1 answer

Bloc pattern in situations where immutable state is just not practical

I am really struggling to convert my MVVM pattern to a bloc pattern with flutter_bloc for a very simple page. My most immediate concern is where do I place my functions that perform side effects? I have this BlocListener to perform a side effect…
BeniaminoBaggins
  • 11,202
  • 41
  • 152
  • 287
4
votes
2 answers

Flutter + Bloc 6.0.6. BlocBuilder's "builder" callback isn't provided with the same state as the "buildWhen" callback

I'm building a tic-tak-toe app and I decided to learn BLoC for Flutter along. I hava a problem with the BlocBuilder widget. As I think about it. Every time Cubit/Bloc that the bloc builder widget listens to emits new state the bloc builder goes…
user11655900
  • 420
  • 7
  • 15
4
votes
1 answer

What are disadvantages of using flutter_bloc library

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…
Kasandrop
  • 335
  • 1
  • 5
  • 14
4
votes
1 answer

Flutter Bloc state does not update no matter what

I am currently trying to learn state management for flutter and i have the below code, but for some reason the state is never updated, am i missing something? import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import…
Dev Man
  • 2,114
  • 3
  • 23
  • 38
4
votes
1 answer

What are the difference between business logic and UI logic?

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…
Muhammad
  • 2,572
  • 4
  • 24
  • 46
4
votes
1 answer

Display loading indicator using states from bloc and show dialog if error occurred

I am new to Flutter development and i am build an application where i am usign the Bloc library with states and events. I have a page where the user can entre his email address in TextFormField. After that he needs to press the send button where the…
Boris
  • 213
  • 4
  • 13
4
votes
2 answers

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

Error: I/flutter ( 5919): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════ I/flutter ( 5919): The following assertion was thrown building Builder: I/flutter ( 5919): …
Zhu
  • 387
  • 4
  • 15