我正在调用初始方法以使用initState从API加载数据。但这导致我出错。这是错误:UnhandledException:inheritFromWidgetOfExactType(_LocalizationsScope)orinheritFromElement()wascalledbefore_ScreenState.initState()completed.Whenaninheritedwidgetchanges,forexampleifthevalueofTheme.of()changes,itsdependentwidgetsarerebuilt.Ifthedependentw
我正在尝试检查用户是否已登录,我已经使用firebase验证了我的flutter应用程序,我希望用户的状态将应用程序重定向到登录页面或主页,但我可以'运行应用程序,它在红色屏幕上显示错误,错误是:NoSuchMethodError:在null上调用了方法“currentUser”。接收者:空尝试调用:currentUser()我看到了解决方案here但我没有正确理解它当前用户函数:FuturecurrentUser()async{FirebaseUseruser=await_firebaseAuth.currentUser();returnuser!=null?user.uid:nul
我的目标是使用Firebase在Flutter中构建注册。但是,当我按下包含注册功能的按钮时,没有任何反应,我收到此错误:E/flutter(13218):[ERROR:flutter/lib/ui/ui_dart_state.cc(148)]UnhandledException:NoSuchMethodError:Themethod'setState'wascalledonnull.E/flutter(13218):Receiver:nullE/flutter(13218):Triedcalling:setState(Closure:()=>Null)与firebase的集成正在运行
我该如何解决这个问题我使用函数从api获取数据,但我看到错误“NoSuchMethodError:getter'length'wascalledonnull'我的代码:FuturegetData()async{http.Responseresponse=awaithttp.get('https://myappres.000webhostapp.com/pubg/api.php?action=getskin');debugPrint(response.body);_data=json.decode(response.body);_list=_data['categorys'];retur
@overrideWidgetbuild(BuildContextcontext){returnMaterialApp(home:Scaffold(appBar:AppBar(title:Text("HelloFlutter"),),body:Column(children:[GestureDetector(onTap:(){showTimePicker(context:context,initialTime:constTimeOfDay(hour:7,minute:0),);},child:Text("22:30"))像这样尝试将timePicker添加到我的Flutter应用程序中
这是一个简单的联系人应用程序,允许添加查看和编辑个人的联系方式。我无法完全理解这里的错误。classViewContactextendsStatefulWidget{finalStringid;ViewContact(this.id);@override_ViewContactStatecreateState()=>_ViewContactState(this.id);}class_ViewContactStateextendsState{DatabaseReference_databaseReference=FirebaseDatabase.instance.reference();
我在使用_showSnackbar时遇到了一些问题,我看到以下错误:Exceptionhasoccurred.NoSuchMethodError(NoSuchMethodError:Themethod'showSnackBar'wascalledonnull.Receiver:nullTriedcalling:showSnackBar(Instanceof'SnackBar'))但我确定我已经为ShowSnackbar创建了GlobalKey:final_scaffoldKey=GlobalKey();这是我的功能showsnackbarvoid_showSnackBar(BuildC
我在我的代码中收到以下NoSuchMethodError:I/flutter(6579):ThefollowingNoSuchMethodErrorwasthrownbuilding:I/flutter(6579):Class'List'hasnoinstancemethod'call'.I/flutter(6579):Receiver:Instance(length:2)of'_GrowableList'I/flutter(6579):Triedcalling:call(0)这是错误行:returnRepTile(RepData.fromDocument(snapshot.data.
我在将项目添加到CardList并尝试使用轮播显示它时遇到问题。该项目已添加到列表中,但当我尝试通过轮播查看它时,显示错误:I/flutter(12255):抛出另一个异常:NoSuchMethodError:Themethod'*'wascalledonnull.我已尝试不留下任何未初始化的内容,正如我在类似案例中读到的有关此问题的内容,但这无济于事。您可以在我的Github个人资料上查看我的代码:https://github.com/varamsky/notes这是模拟器屏幕的图像。enterimagedescriptionhere 最佳答案
有时animals.relatives是空的,所以t.name返回null,这是导致问题的原因我尝试了ifelse语句和trycatch,但我猜它在小部件内部不起作用?我不确定为什么它不起作用Column(children:[Text(animals.name),Text(animals.desc),Text("Relatives:"),Row(children:animals.relatives.map((t)=>FilterChip(label:Text(t.name),onSelected:(b){})).toList(),),]),如果t.name为null,我不希望其上方的行