https://pub.dev/packages/hooks_riverpod/example
このサンプルのreturn Scaffold(が実行される前に
increment()を実行したいのですが
final count = useProvider(counterProvider);
context.read(counterProvider.notifier).increment();
return Scaffold(
と書いたら大量のエラーが発生しました
どうやればウィジェットをreturnする前にincrement()を実行できますか?
E/flutter (23139): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: setState() or markNeedsBuild() called during build.
E/flutter (23139): This UncontrolledProviderScope 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 the build phase only if one of its ancestors is currently building. This exception is allowed because the framework builds parent widgets before children, which means a dirty descendant will always be built. Otherwise, the framework might not visit this widget during this build phase.
E/flutter (23139): The widget on which setState() or markNeedsBuild() was called was:
探検
Flutterやろうよ!!! 3
■ このスレッドは過去ログ倉庫に格納されています
529デフォルトの名無しさん (ワッチョイ f15f-mnzl)
2021/11/04(木) 01:05:35.85ID:ZPLsF2ZP0■ このスレッドは過去ログ倉庫に格納されています
