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 readingCategory: Bloc
what 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 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 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 readingGetting network image with an url – flutter, firebase – error
Issue I’m getting an error " Invalid argument(s): No host specified in URI file:///" and also "StateError (Bad state: field does not exist within the DocumentSnapshotPlatform)" while trying to receive an image from an url that user types in the
Continue readingHow to globally listen from a flutter bloc?
Issue I’m implementing notifications on my app. I have a Cubit that will emit states when the app receives a new notification. This is my main: class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MultiBlocProvider( providers: [
Continue readingWhy use BloC or Provider in Flutter when we already have Flutter's built-in setState?
Issue Maybe I don’t understand the purpose of BloC or Provider but I’m confused as to why we would ever want to use them instead of using Flutter’s built-in state management using the Stateful widget. I’ve just finished an app
Continue readingCubit state change problem in flutter cubit
Issue So I am trying cubit state management and through that I am trying to login a user to second screen. The error occurs in cubit states changing as it’s stuck on initial State. Upon pressing the login button the
Continue readingHow to run BlocObserver example in cli
Issue Update: As @oleksa found, the solution is just create/attach the MyBlocObserver before the BloC. I was hoping to be able to test BlocObserver in a simple dart cli. import ‘package:bloc/bloc.dart’; void main(){ MyBloc myBloc = MyBloc(); // << just
Continue readingHow to run BlocObserver example in cli
Issue Update: As @oleksa found, the solution is just create/attach the MyBlocObserver before the BloC. I was hoping to be able to test BlocObserver in a simple dart cli. import ‘package:bloc/bloc.dart’; void main(){ MyBloc myBloc = MyBloc(); // << just
Continue reading