Issue I got a flutter error A value of type ‘Iterable<HospitalListModel>’ can’t be assigned to a variable of type ‘List<HospitalListModel>’. This is my model: List<HospitalListModel> hospitalListModelFromJson(String str) => List<HospitalListModel>.from(json.decode(str).map((x) => HospitalListModel.fromJson(x))); String hospitalListModelToJson(List<HospitalListModel> data) => json.encode(List<dynamic>.from(data.map((x) => x.toJson()))); class HospitalListModel
Continue readingTag: flutter-bloc
How to alter state of one screen from another screen using Cubit in Flutter?
Issue I am new to flutter and I am using the Cubit from flutter_bloc package. I have this situation going here. I have screen-A as in diagram below where I show list of videos and the likes, comments connected with
Continue readingHow to listen to stream variable using bloc | Could not find the correct Provider<StateStreamable<.>> above this BlocBuilder<StateStreamable<.>, <.>>
Issue I am looking for the right way of implementing streams using bloc. I have a appUser of type AppUser which changes based on the stream . I want to listen to this appUser throughout the application using bloc. My
Continue readingwhat does this copyWith pattern mean? <datatype> Function()? <variable>
Issue In the ToDo tutorial of BlocLibrary I cam along the following snippet. TodosOverviewState copyWith({ TodosOverviewStatus Function()? status, List<Todo> Function()? todos, TodosViewFilter Function()? filter, Todo? Function()? lastDeletedTodo, }) { return TodosOverviewState( status: status != null ? status() : this.status, todos:
Continue readingHow to call 2 Future functions that return Future values in FutureBuilder?
Issue I am working on a complex web application in which from time to time, I need to fetch data from backend API. Sometimes, I need to call 2 future functions in Future Builder to use their values. However, it
Continue readingFlutter bloc how to call event the right way?
Issue I have a quite complex app structure and im wondering how to handle calling my events the right way. Imagine my widget tree. On top of everything I have the following file AppWrapper with this 1. level file AppWrapper
Continue readingSend the provider in the navigator in flutter
Issue I am creating an app about shopping lists in flutter and firestore. I am trying to use the bloc pattern now, and when I press a button I want to navigate to a different screen to create a new
Continue readingFlutter Bloc + Socket.io + Freezed implementation
Issue How to implement socket_io_client to flutter_bloc with freezed? Solution socket_bloc.dart import ‘package:flutter_bloc/flutter_bloc.dart’; import ‘package:freezed_annotation/freezed_annotation.dart’; import ‘package:socket_io_client/socket_io_client.dart’; part ‘socket_bloc.freezed.dart’; part ‘socket_event.dart’; part ‘socket_state.dart’; class SocketBloc extends Bloc<SocketEvent, SocketState> { late final Socket _socket; SocketBloc() : super(SocketState.initial()) { _socket = io(
Continue readingFlutter bloc bad state of stream
Issue in my class Repository() I have two streamcontrollers running who are listening to changes. final remoteStreamController = StreamController<dynamic>.broadcast(); Stream<dynamic> get remoteId => remoteStreamController.stream.asBroadcastStream(); final localStreamController = StreamController<dynamic>.broadcast(); Stream<dynamic> get localJoined => localStreamController.stream.asBroadcastStream(); now when there is an event in
Continue readingListen to changes without caring about state in Flutter Bloc
Issue I am currently learning how to use the Bloc state management library in Flutter, and I have a scenario where I would like to listen to an action performed (e.g. clicking a button) and react to that action in
Continue reading