草庐IT

BlocProvider

全部标签

flutter radio 值不变

我正在尝试设置一组非常简单的单选按钮,这就是为什么令人沮丧的是它们无法正常工作。我试过在类似的类(class)中设置它,并且成功了。我知道正在调用setstate的事实,但由于某种原因它没有更新单个单选按钮。这让我觉得这是一些与状态有关的奇怪问题。无论如何,我们将不胜感激。我的主类是下面代码的第二部分。import'package:flutter/material.dart';import'package:flutter_bloc/flutter_bloc.dart';import'../bloc/thembloc.dart';import'./components/textfield

flutter radio 值不变

我正在尝试设置一组非常简单的单选按钮,这就是为什么令人沮丧的是它们无法正常工作。我试过在类似的类(class)中设置它,并且成功了。我知道正在调用setstate的事实,但由于某种原因它没有更新单个单选按钮。这让我觉得这是一些与状态有关的奇怪问题。无论如何,我们将不胜感激。我的主类是下面代码的第二部分。import'package:flutter/material.dart';import'package:flutter_bloc/flutter_bloc.dart';import'../bloc/thembloc.dart';import'./components/textfield

flutter - 使用 BlocProvider 并实例化 BLoC

我是Flutter的新手,最近开始学习BLoC模式。我不明白为什么我需要在小部件内部使用BlocProvider.of(context),我可以在所有小部件依赖的文件顶部简单地实例化一个Bloc(finalblocX=bloc();),即使没有在任何代码中定义单个BlocProvider。非常感谢。classHomePageInitextendsStatelessWidget{@overrideWidgetbuild(BuildContextcontext){returnScaffold(body:BlocProvider(builder:(context)=>WeatherBloc(

flutter - 使用 BlocProvider 并实例化 BLoC

我是Flutter的新手,最近开始学习BLoC模式。我不明白为什么我需要在小部件内部使用BlocProvider.of(context),我可以在所有小部件依赖的文件顶部简单地实例化一个Bloc(finalblocX=bloc();),即使没有在任何代码中定义单个BlocProvider。非常感谢。classHomePageInitextendsStatelessWidget{@overrideWidgetbuild(BuildContextcontext){returnScaffold(body:BlocProvider(builder:(context)=>WeatherBloc(

flutter Bloc : No ancestor could be found starting from the context?

我是Flutter的新手,也是Bloc的新手。编译代码时出现错误:ThefollowingassertionwasthrownbuildingLogin(dirty,state:_LoginFormState#44e7f):BlocProvider.of()calledwithacontextthatdoesnotcontainaBlocoftypeBtnBloc.NoancestorcouldbefoundstartingfromthecontextthatwaspassedtoBlocProvider.of().Thiscanhappenifthecontextyouusecome

flutter Bloc : No ancestor could be found starting from the context?

我是Flutter的新手,也是Bloc的新手。编译代码时出现错误:ThefollowingassertionwasthrownbuildingLogin(dirty,state:_LoginFormState#44e7f):BlocProvider.of()calledwithacontextthatdoesnotcontainaBlocoftypeBtnBloc.NoancestorcouldbefoundstartingfromthecontextthatwaspassedtoBlocProvider.of().Thiscanhappenifthecontextyouusecome

flutter - 使用不包含 CLASS 类型的 Bloc 的上下文调用 BlocProvider.of()

在flutter中,我刚刚学习了如何在应用程序上使用Bloc,我想尝试使用此功能实现简单的登录。在实现一些bloc类以在View中使用它之后当我尝试将此代码用作BlocProvider.of(context).dispatch(LoginEvent(loginInfoModel:testLogin));在RaisedButton中错误:BlocProvider.of()calledwithacontextthatdoesnotcontainaBlocoftypeLoginListingBloc.我的观点:class_HomePageStateextendsState{LoginList

flutter - 使用类参数传递 BlocProvider

在我的应用程序中的一个类中,我想通过类参数传递BlocProvider,例如:enumMenuItems{dashboard,tutorials,logout}classDashboardItems{MenuItemsmenuItem;BlocProvideraction;DashboardItems({@requiredthis.menuItem,@requiredthis.action});}在action字段中,我尝试传递此方法:BlocProvider.of(context).dispatch(MyEvent(event)))例如:DashboardItems(menuItem

flutter - BlocProvider 在继承的小部件中不可用

面临BlocProviders的问题。据我了解,一个block应该可以在继承的小部件范围内的任何地方访问。我有一个App类,它恰好是我的核心类,我在其中构建我的MaterialAppWidgetbuild(BuildContextcontext){returnMaterialApp(debugShowCheckedModeBanner:false,title:'E-Form',color:Color(0xFF44697D),home:BlocProvider(child:LaunchScreen()),);}现在我有了LaunchScreen类,这里我没有使用BlocProvider,