我尝试了flutter_bloc包,但遇到了以下错误:
The following assertion was thrown building BlocBuilder<MyCubit, MyState>(dirty, dependencies: [_InheritedProviderScope<MyCubit?>], state: _BlocBuilderBaseState<MyCubit, MyState>#8c21a):
setState() or markNeedsBuild() called during build.
This Form widg
我见过BlocProvider自动处理flutter_bloc包中的块。在将bloc/cubit作用域指定到单个小部件时也是如此吗? BlocBuilder<BlocA, BlocAState>(
cubit: blocA, // provide the local cubit instance
builder: (context, state) {
// return widget here based on BlocA's state
}
) (我似乎在创建我的cubit的多个实例)
我将描述我的问题和我所面临的错误。然后,我将复制我的代码,以使它更清楚。问题是:
ApplicationBloc.Use (StartupScreen).If AuthenticationBloc的状态更改为AuthAuthenticatedState,然后路由到MainScreen,否则,将路由到LoginScreen.If用户,然后路由到MainScreen:,然后从存储(异步)获得currentUser,然后包装BlocListener内部FutureBuilder。它最终导致无法显示屏幕,并以following:的形式出现错误
BlocProvider.of() called wi
我试图在屏幕上显示当前的蓝牙状态(打开、关闭、加载)。当我初次亮相的时候,一切似乎都是真的。如果我想执行的话,代码就会执行。在UI中仍然没有显示任何内容。使用的flutter_blue软件包。
bluetooth_cubit_dart.
part 'bluetooth_state.dart';
class BluetoothCubit extends Cubit<BluetoothCubitState> {
final FlutterBlue flutterBlue;
late final StreamSubscription bluetoothStrea
我有一个小部件,当点击时,保存一个ID号,覆盖1000ms的CircularProgressIndicator,然后弹出进度指示器,并将用户路由到另一个页面。
这个带有ProgressIndicator和计时器的位是新的,它破坏了我的单元测试,现在给出了以下错误:
The following assertion was thrown running a test:
'package:flutter_test/src/binding.dart': Failed assertion: line 574 pos 12: '() {
'A Timer is
简而言之,问题是:如何重用整个小部件子树的状态?
这就是我的代码当前的样子:
...
BlocBuilder<AuthBloc, AuthState>(
builder: (context, state) {
if (state is Authenticating) {
return AppLoading();
} else if (state is NotAuthenticated) {
return AppOnboarding();
} else if (state is Authenticated) {
ret
我正在尝试使用Sliver来实现可折叠的列表头。当我将小部件从普通窗口小部件更改为小窗口窗口小部件时,我经常会出现这样的错误:
I/flutter ( 3141): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 3141): The following assertion was thrown building NotificationListener<ScrollNotification>():
I/f
我很难将CupertinoDatePicker的minuteInterval:属性设置为30。它应该是整数因子60,所以30应该可以。但我只能将其设置为1或2,任何其他值都会引发此异常:
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following assertion was thrown building BlocBuilder<BookingBloc, BookingState>(dirty, state: _B