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.

Filter by
Sorted by
Tagged with
0 votes
2 answers
13 views

Any initState() replacement present in the Provider ecosystem?

Question: I want to build my app using no stateful widgets and I have a necessity of using initState(). I would be grateful, if anyone from the community can help me with this challenge. Is there any ...
1 vote
3 answers
37 views

Why I am not getting the state in BlocBuilder when I emit it in BlocProvider?

I am working on the application and emitting the states for particular cubit in the main file in the "MultiBlocProvider" like this. return MultiBlocProvider( providers: [ ...
1 vote
1 answer
21 views

HTTP GET Works in postman but failed in Flutter even with generated dart code from postman

i try to call api using generated dart code from postman. the link i put on flutter and postman is same link but only postman work. import 'package:flutter/material.dart'; import 'dart:async' show ...
  • 11
0 votes
2 answers
26 views

Flutter Bloc emit how to handle when the stream is done

await emit.onEach( // This stream, how do you handle when this stream is done? stream, onData: (data){ } ); Normally on Flutter Stream we have a callback onDone, but on emit onEach or forEach ...
0 votes
0 answers
27 views

Use context in global scope with go_router

I want to use go_router guideline to create GoRouter object in global scope but I can not figure out how to add a refreshListenable argument. final go_router = GoRouter( refreshListenable: ...
0 votes
1 answer
21 views

Why "StateError (Bad State: add(LoginPasswordChange) was called without a registered event handler" error?

This is the code i copied from YouTube, and I had to change several lines, because flutter bloc had a new update, but the error still happened. Widget _passwordField() { return BlocBuilder<...
  • 11
2 votes
1 answer
35 views

Freezed+BLoc how to check the current state and the variables of an specific state from BLoc Listener

I'm trying to learn how to execute some code in a BLoC listener depending on the state and a code variable that's only present in the success state. I would like to be able to tell if I'm on the ...
  • 23
0 votes
1 answer
37 views

flutter bloc: how can i access to variables in bloc all over of tree?

I want to access one or more lists or variables throughout the tree of my program and also perform operations of adding, deleting, editing on that list, I solve this problem by using the provider ...
  • 83
0 votes
1 answer
22 views

Why does my flutter BlocBuilder updates partially?

I have this piece of Flutter Bloc code. child: BlocBuilder<SalesBloc, SalesState>( builder: (context, state) { var sales = state.allSales; var sale = ...
  • 15.7k
0 votes
1 answer
27 views

Periodic timer implemented in cubit giving me error for flutter widget testing

I have a timer countdown app. The state of the time is managed by cubit. When my widget gets initialized(In init state), I am starting the timer by calling cubit function and I am disposing it also. ...
0 votes
0 answers
15 views

Why is my BlocListener not working when attached to the materialApp widget's home param?

BlocBuilder is working fine and responding to the state changes, however BlocListener seems to be not listening to the state change. class MyApp extends StatefulWidget { const MyApp({super.key}); ...
  • 2,963
0 votes
1 answer
49 views

How to conect entity(domain layer) and model(data layer) using BloC+Freezed

I'm trying to learn how to follow a clean feature-first architecture using Bloc and Freezed. From what I've seen, I should have inside the Domain layer, an entity class declaring only its properties ...
  • 23
-3 votes
1 answer
29 views

Can someone please explain this block of code?

class PortfolioHomeCubit extends Cubit<PortfolioHomeState> { PortfolioHomeCubit() : super(PortfolioHomeState()); final apiService = ApiService(); Future<void> _onFetchContent() async ...
0 votes
0 answers
29 views

Flutter Event Not Triggering New State

I'm having an issue emitting my success state from my Bloc. What I'm trying to do here is setting up Stripe implementation so I can start building the e-commerce portion of my app. As it is now, my ...
  • 19
1 vote
1 answer
39 views

Handle BlocProvider with Modal Bottom Sheet

I have a statefull widget with a Gesture detector within a Bloc Provider. @override Widget build(BuildContext context) { return RepositoryProvider.value( value: _authRepository, ...
0 votes
0 answers
31 views

Flutter - Encountered a Error at an unrecoverable point. Failure was:

I'm quite a newbie into the flutter_bloc and I got stuck for a couple of weeks with this issue and I didn't figure out how to solve it. The problem that I have is that The BLocBuilder from AddressView ...
  • 15
0 votes
0 answers
36 views

Instance of BloC did not working independently

I have a list of forms, when the user enters valid information, it will automatically render another form. And I use a BloC list to manage the state for displaying images in that form. The problem is ...
  • 1
0 votes
0 answers
27 views

What is causing the 'setState() called after dispose()' error in Flutter?

i have a footer widget : Widget footer(BuildContext context) { return Container( child: GNav( duration: const Duration(milliseconds: 400), tabs: const [ GButton( ...
0 votes
1 answer
22 views

BlocProvider.of<MyBloc>(context) return null

I upgraded my flutter app version from 3.7.5 to 3.8, integrating the null safety. Since then when I flutter run I get this error : Another exception was thrown: Null check operator used on a null ...
0 votes
1 answer
34 views

Why empty Container take full height of the screen in flutter?

Edit: Question: Why does some Container in flutter take full height of the screen, where as other doesn't ? Let me illustrate: @override Widget build(BuildContext context) { return MaterialApp(...
  • 9,759
0 votes
1 answer
36 views

how pass data from parent to child widget using bloc

what is better ? pass state from parent to children or create each child a builder bloc? (USING PACKAGE flutter_bloc) BlocProvider( create: (context) => ExampleBloc(), child: BlocBuilder<...
0 votes
0 answers
14 views

Separate natively handled objects with bloc pattern

I am working on a flutter desktop application that connects to multiple bluetooth devices using native code and flutter ffi. I can't wrap my head around how to separate it into nice blocs. Searching ...
0 votes
0 answers
44 views

Flutter BLoC: listen callback called multiple times

my blocConsumer listener calling muliple time i dont know why? This is my auth cubit page import 'package:flutter_bloc/flutter_bloc.dart'; import '../../../ApiManager/api_manager.dart'; import '...
  • 1,414
1 vote
0 answers
55 views

Flutter Navigation 2.0 with bloc and cubit pop and back button not working

I am implementing flutter navigation 2.0 for mobile with BLoC and cubit. Navigating from one screen to the other declaratively is working fine. The issue is when I pop using the back arrow or tap ...
  • 471
0 votes
1 answer
46 views

The same repository for several BLoCs in flutter

Is it a good idea to use the same repository for several BLoCs?
  • 5,648
2 votes
1 answer
63 views

Whether `Bloc` and `Cubit` are completely equivalent?

Let's consider this case: class Repository { final _controller = Behaviorsubject<List<Object>>(); Stream<List<Object>> get stream => _controller.stream; void ...
  • 5,648
0 votes
1 answer
24 views

How can I get parameter from Bloc without using Blocprovider/Bloccomsumer...?

I have defined a bloc named "AppBloc" that manage user login/logout activity of user: class AppBloc extends Bloc<AppEvent, AppState> { AppBloc() : super( const ...
1 vote
1 answer
67 views

BlocProvider in flutter in error Navigation

I'm making an app in flutter and in the main, when I navigate with a button its shows an error: This happens because you used a BuildContext that does not include the provider of your choice. There ...
0 votes
0 answers
10 views

Could not find the correct Provider above this BlocBuilder Widget

I have a blocBuilder inside a seperated file but it not working because it cannot find the provider.. I think the problem from the showDialog context I tried to give it all possible context but still ...
0 votes
1 answer
30 views

How do i make my bloc work in a reusable widget created?

I have a reusable widget I created below as part of a UI for my app The code for the reusable widget is below // ignore_for_file: prefer_typing_uninitialized_variables import 'package:flutter/...
  • 25
0 votes
1 answer
123 views

Issue with updating a TextFormField in Flutter Cubit after a tap or fetching data from an API

Github Repo : Validator Using Cubit - Generic Concept - Full Code My goal is to apply form validation using Cubit, and I've successfully made progress in the process. However, a challenge arose while ...
0 votes
1 answer
32 views

How to avoid Flutter widgets and blocs from rebuilding when keyboard is popped open

I have a chat widget screen wrapped within a Bloc builder checking state of the bloc [HydratedBloc] handling the socket connection. Whenever I try to open the keyboard from the textfield each and ...
0 votes
0 answers
92 views

Reactive redirection using go_router and flutter_bloc

What would be the best way to somehow implement a reactive redirection using bloc states? Currently I'm doing redirection like this: router.dart final router = GoRouter( routes: [ GoRoute( ...
  • 69
1 vote
1 answer
77 views

Issues initializing a Flutter cubit to automatically call a data loading function

I'm struggling to understand how to initialize a Flutter cubit such that it can load data automatically when it's first created. I saw 2 general recommendations during research, people say you can ...
0 votes
1 answer
68 views

Accesing a BLoC using getit instead of context not working

I am trying to access a BLoC instance without actually using the context, but getIt instead. The versions I have are: flutter_bloc: ^8.1.1 injectable: ^2.1.0 get_it: ^7.2.0 ...
2 votes
1 answer
174 views

How to use linked_scroll_controller with Flutter bloc state management

In my flutter application I want to create a timetable widget which will scroll horizontally and vertically with corresponding heading. The timetable should have 'Day' as horizontal heading and '...
  • 1,911
0 votes
0 answers
45 views

Flutter Bloc pagination working correctly, but the entire ListView.builder is rebuilt instead of simply appending the new items

I am relatively new to flutter_bloc, so forgive me if this is a simple question. I have a ListView.builder that renders out a list from my API, and my goal is to paginate this list. I have ...
  • 43
4 votes
0 answers
226 views

How to work with flutter_bloc 8+, go_router +6 and refreshListenable

I'm using go_router for navigation and flutter_bloc for my state management. I would like to use refreshListenable and listen to my AuthBloC events in my GoRouter configuration, however, I don't have ...
  • 730
1 vote
0 answers
28 views

Initiate global bloc on Logout

I'm providing bloc at top of all view to access at globally. When I'm doing logout and re-login without closing app, event not called because it is already initiate. Here, I want to refresh bloc on ...
0 votes
1 answer
46 views

How to prevent api being called multiple times on scroll controller

I have a scroll controller. I am making a request when the scroll position passes a defined value. The problem is, it is making thousands of requests when it overpasses the position. To prevent this I ...
0 votes
1 answer
40 views

How to properly consume this Stream method from Bloc to emit states

I am trying to process a method of type Stream from a Bloc implementation, but it seems I am not properly handling concurrency and I would need some assistance. I have the following interface and ...
  • 907
0 votes
1 answer
22 views

Showing the loading text while event is dispatched from the button in flutter

Bloc builder is not changing the ui while dispatching the event from the Inkwell onTap method. Here is code: BlocProvider( create: (context) => VendorsingleprofileBloc( ...
0 votes
1 answer
78 views

Flutter BloC repeat an event again after dio request time out

I have a problem on my flutter app, when try to load a data from api using dio and this api is private so need to be connected to the same network, so to check everything is fine I tried to connect ...
0 votes
1 answer
77 views

Is Hydrated Bloc good for storing more complex data?

I'm a newbie in flutter and recently started learning Bloc with flutter_bloc package. I want to store some data in local storage. I have found the hydrated_bloc package, and here comes my question: &...
  • 1
0 votes
1 answer
63 views

BLoC emit not updating the state in UI

I have build the screen with Appbar,Tabs and TabView, the Appear has TextField, every time text changes, the control is going inside the BLoC's emit but never received at UI. Please find the code ...
  • 1,129
0 votes
0 answers
42 views

Flutter App Back button is closing the App instead of navigating to the previous screen in flutter Navigation 2.0 with bloc and cubit

I am working on a flutter App and managing state using bloc architecture and cubits for navigation. The App is a bit large and complicated. The issue I am having is when I tap the Android back button; ...
  • 471
0 votes
0 answers
50 views

Change the boolean value onclick and save to secured storage flutter

class Lessons { final int? id; final String? title; final List<Resources> resources; Lessons({ required this.id, required this.title, required this.resources, }); } class ...
0 votes
0 answers
47 views

Bad state: Cannot emit new states after calling close

I'm using flutter_form_bloc (https://pub.dev/packages/flutter_form_bloc) and I created two classes, the first is the login page: class LoginScreen extends StatelessWidget { const LoginScreen({super....
0 votes
1 answer
59 views

Can I declare a function inside a flutter_bloc builder?

I am using table_calendar flutter package to add a calendar with events. I need to declare a function that uses state from bloc. Is there any problem with his approach? Right now it's working but I ...
  • 919
1 vote
0 answers
41 views

flutter_bloc is not resetting its Cubit Model values when we try to push the same screen more than one time

Here is my main.dart code, void main() { // Bloc.observer = AppBlocObserver(); runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); // This widget is the ...
  • 1,762

1
2 3 4 5
18