我添加了setState()方法,得到了一个错误。终端错误(我使用flutter run -d chrome --web-hostname localhost --web-port 7357命令,所以它在终端中):
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following assertion was thrown building StreamBuilder<List<BusinessModel>>(
我正在尝试在initState()期间从SharedPreferences获取数据并对其进行测试。如果我只是在状态中设置私有变量,而不调用setState(),则视图不会更新。
如果我试图在setState()方法中包装设置变量,我的测试将在setState()方法处使用空指针中断。
NoSuchMethodError: The method 'markNeedsBuild' was called on null.
Receiver: null
Tried calling: markNeedsBuild()
这是我的initState()
initState() {
_ap
您好,我正面临一个问题,我的flutter应用程序使用提供商和消费者。 当我在调试器中遇到这个问题时,一切都很正常: ════════ Exception caught by foundation library ════════════════════════════════
The following assertion was thrown while dispatching notifications for CatergoryProvider:
setState() or markNeedsBuild() called during build.
This _InheritedP
我用编辑模式编写了逻辑,允许用户在输入字段中进行更改,但是当再次单击“编辑模式”按钮时,则需要在编辑之前返回值。这有一个问题,因为一切都很好,但是控制台给我显示了这个错误:
════════ Exception caught by foundation library ════════════════════════════════
The following assertion was thrown while dispatching notifications for TextEditingController:
setState() or markNeedsBuild() called
我试图根据FutureBuilder收到的结果来设置状态,看起来这是不可能的,因为FutureBuild还在构建,有什么想法吗?
错误:
The following assertion was thrown building FutureBuilder<String>(dirty, state: _FutureBuilderState<String>#db9f1):
setState() or markNeedsBuild() called during build.
This StatefulBuilder widget cannot be marked as ne
启动后,我正在尝试处理我的应用程序的屏幕。
预期的路线是:
boot -> check if is logged in -> if yes -> navigator.push() to MainWindow.
boot -> check if is logged in -> no snapshot data -> navigator.push() to LoadingScreen.
boot -> check if is logged in -> if no -> navigator.push() to LoginScreen.
函数在Ma
我有一个类别的动态列表。
我有一个每类产品的动态列表。
我的lit视图构建器垂直显示类别列表。现在,对于每个类别,它向我的服务器发出一个请求,以获取并显示该类别下的产品。
这是有效的,但是垂直滚动是不稳定的,并且我在我的调试控制台中经常看到以下错误:
════════ Exception caught by foundation library ════════════════════════════════
setState() or markNeedsBuild() called during build.
═════════════════════════════════════════
我有一个flutter应用程序,它正在抛出 NoSuchMethodError: The method 'markNeedsBuild' was called on null. Receiver: null Tried calling: markNeedsBuild() 下面是抛出这个问题的代码: if (this.mounted) {
setState(() {
groupDocument = groups.documents[0];
group = groupDocument.data;
});
} 我正在检查mounted
基础库═捕获到═异常 在调度AuthService的通知时引发了以下断言:生成期间调用的setState()或markNeedsBuild()。 我收到以下错误: This _InheritedProviderScope<AuthService> widget cannot be marked as needing to build because the framework is already in the process of building widgets. A widget can be marked as needing to be built during th
使用flutter 2.x和Get package版本^4.1.2。
我有一个像这样的小部件:
class InitializationScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: FutureBuilder(
future:
// this is just for testing purposes
Future.delayed(const Du
我从一个initState()方法调用了一个ChangeNotifier函数,函数内部的notifyListener()调用抛出了setState() or markNeedsBuild() called during build.异常 void initState(){
Provider.of<MessengerRepository>(context, listen: false).setUnreadCount(0);
super.initState();
} class MessengerRepository with ChangeNotifier {
int unr
我想导航到QrScan屏幕,一旦图标被按下,我得到了一个错误!!setState() or markNeedsBuild() called during build我想导航到那个屏幕并从QR代码中获取数据,然后我希望这些数据显示在另一个屏幕上!
它说:
不能将此覆盖小部件标记为需要构建,因为框架已经在构建小部件的过程中。只有当小部件的祖先之一正在构建时,才能将其标记为需要在构建阶段构建。允许此异常是因为框架在子程序之前构建父部件,这意味着将始终生成脏子代。否则,框架可能不会在此构建阶段访问此小部件。
调用setState()或markNeedsBuild()的小部件是: Overlay- La
我正在尝试创建一个全局提供程序,它将包含一个布尔值作为提供程序家族的一部分 final PaginationProvider = StateProvider.family((ref, id) => true); 但是,我尝试像对其他提供者一样设置该值是失败的。 context.read(PaginationProvider(0)).state = false; 具体的错误是 Unhandled Exception: setState() or markNeedsBuild() called during build.
This UncontrolledProviderScope wid