草庐IT

Getter-Setter

全部标签

flutter - getter'token'在null上调用

''finalparsedExpirytime=datetime.parse(expiryTimeString.toString());''I/flutter(28078):══╡EXCEPTIONCAUGHTBYWIDGETSLIBRARY╞═══════════════════════════════════════════════════════════i/flutter(28078):以下nosuchmethoderror是建筑商抛出的:I/Flutter(28078):getter“token”被调用为空。I/颤振(28078):接收器:空I/Flutter(28078):尝

flutter - 未为对象定义 Getter

我正在尝试使用传递的类实例设置状态并访问成员值,但它给了我未在对象上定义getter的错误。但同样适用于initState方法。这用于在用户关闭ShowDialog时传递值。我尝试设置setter/getter并将类(class)成员从私有(private)更改为公共(public)。classMyReaction{IconData_icon;String_text;MyReaction(this._icon,this._text);IconDatageticonD=>this._icon;StringgettextV=>this._text;}class_MyHomePageStat

flutter - 如何修复 'NoSuchMethodError: The getter ' 长度' was called on null'

我该如何解决这个问题我使用函数从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

flutter - 如何修复 "The getter ' 长度'在 null 上被调用

我已经使用了FutureBuilder,但仍然有这个问题这是我的主体代码,我已经使用了futurebuilder,但仍然存在长度问题。我不明白这一点。FutureBuilder(future:showPosts(),builder:(context,snapshot){returnListView.builder(itemCount:snapshot.data.length,itemBuilder:(context,index){returnCard(color:Color(0xFFE1F5FE),child:Column(mainAxisSize:MainAxisSize.min,c

http - Flutter:单例数据,getter 在 null 上调用

在我从http请求中检索到数据(一个用户)之后,我想将这些数据放入一个单例中。然后,在另一个View中,我想在边栏中显示该用户的名称,但它显示“Thegetter'user'wascalledonnull”。这是我的代码:varuser=awaitgetUser(_username,_password);if(user.loginError==false){model.user=user;Navigator.of(context).pushNamedAndRemoveUntil('/home_view',ModalRoute.withName('/home_view'));}这是我尝试

dart - Flutter调用showTimePicker函数报错: The getter 'modalBarrierDismissLabel' was called on null

@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应用程序中

dart - getter 'value' 在 null 上被调用

我正在尝试在flutter中创建此字体大小动画,但我收到以下错误:getter'value'wascalledonnull。这看起来很奇怪,因为我有另一个包含类似代码的dart文件并且它运行良好。如有任何帮助,我们将不胜感激。Animation_fontSizeAnimation;AnimationController_fontSizeAnimationController;初始化状态函数():super.initState();_fontSizeAnimationController=newAnimationController(duration:newDuration(millis

firebase - 我/flutter (14318) : NoSuchMethodError: Class 'FirebaseUser' has no instance getter 'firstname'

我正在尝试更新我正在构建的应用程序用户的用户配置文件。用户信息存储在firebase中,应用程序在运行在android上的dart中编码。我已经尝试实现来自https://firebase.google.com/docs/auth/web/manage-users的示例网站。51createUser(){52if(checkFields()){53//PerformLogin54varuser=FirebaseAuth.instance.currentUser();55FirebaseAuth.instance56.createUserWithEmailAndPassword(emai

dart - getter 中的 future 对象

我在我的getter中为我的Locale变量调用一个future对象。如何让返回值等待呢?classChangeLocalewithChangeNotifier{Locale_locale;Localegetlocale{getLanguage().then((LocaleprefLocale){_locale=prefLocale;});return_locale;}setlocale(LocalenewValue){print(newValue);_locale=newValue;notifyListeners();}} 最佳答案

dart - 没有声明顶级 getter <className>

我正在扩展flutter_gallery示例。我尝试创建新的画廊项目newGalleryItem(title:'Journal',subtitle:'Exampleappcoding',category:'Apps',routeName:JournalDemo.routeName,buildRoute:(BuildContextcontext)=>newJournalDemo()),我导入了import'../journal/journal_all.dart';里面我有export'journal_demo.dart';JournalDemo类和ListDemo是同一个类,我只改了类名