原因分析 bloc 继承于 cubit , 查看 cubit 源码得知,状态更新时做了判断,如果接收到的 newState 与 currentState 为同一个对象,则直接 return,不响应本次状态变更。 处理方式: 1. State实现copyWith()方法 每个State类都要有copy()方法,用于产生state对象的副本;每次编辑 state 的字段内容,然后 yield 副本,保证...
Expand Up@@ -6,7 +6,7 @@ import 'package:flutter/material.dart'; import'package:flutter_bloc/flutter_bloc.dart'; import'../../cubit/canteen_cubit.dart'; import'../../cubit/daily_meal_plans_cubit.dart'; import'../../cubit/meal_plans_cubit.dart'; ...
Uses Cubit for storing state and flutter_bloc for state management Getting Started Prerequisites Make sure you have the following installed: Flutter (version 3.10 or higher) Dart Steps to run the project Clone the repository Open your terminal and run the following command: git clone <repo-url>...