- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
import 'dart:io';
import 'package:Zabatnee/common_app/provider/user_details_provider.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class ForgetPasswordDialog extends StatefulWidget {
static const routeName = '/customeDialog';
final String title,description;
ForgetPasswordDialog({
this.title,
this.description,});
@override
_ForgetPasswordDialogState createState() => _ForgetPasswordDialogState();
}
class _ForgetPasswordDialogState extends State<ForgetPasswordDialog> {
final emailController = TextEditingController();
var _isLoading = false;
_showDialog(String title, String message) {
showDialog(
barrierDismissible: false,
context: context,
builder: (ctx) => WillPopScope(
onWillPop: () async => false,
child: new AlertDialog(
elevation: 15,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(8))),
title: Text(
title,
style: TextStyle(color: Colors.white),
),
content: Text(
message,
style: TextStyle(color: Colors.white),
),
backgroundColor: Theme.of(context).primaryColor,
actions: <Widget>[
FlatButton(
child: Text(
'OK',
style: TextStyle(color: Theme.of(context).accentColor),
),
onPressed: () {
Navigator.of(context).pop();
setState(
() {
_isLoading = false;
},
);
},
)
],
),
),
);
}
Future<void> _forgetPassword (String email) async {
try{
setState(() {
_isLoading = true;
});
await Provider.of<UserDetailsProvider>(context, listen: false).forgetPassword(email);
print('code are sent via email');
} on HttpException catch (error) {
_showDialog('Authentication Failed', error.message);
} on SocketException catch (_) {
_showDialog('An error occured',
'please check your internet connection and try again later');
} catch (error) {
_showDialog('Authentication Failed',
'Something went wrong, please try again later');
}
setState(() {
_isLoading = false;
});
}
@override
void dispose() {
emailController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Dialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16)
),
elevation: 8,
backgroundColor: Theme.of(context).accentColor,
child: dialogContent(context),
);
}
dialogContent(BuildContext context){
return Container(
padding: EdgeInsets.only(
top: 50,
right: 16,
left: 16,
bottom: 16,
),
margin: EdgeInsets.all(8),
width: double.infinity,
decoration: BoxDecoration(
color: Theme.of(context).accentColor,
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(17),
boxShadow: [
BoxShadow(
color: Colors.black87,
blurRadius: 10.0,
offset: Offset(0.0,10.0),
)
]
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
widget.title,
style: TextStyle(
fontSize: 24,
),
),
SizedBox(
height: 20,
),
Text(widget.description, style: TextStyle(fontSize: 16),
),
SizedBox(
height: 20,
),
TextField(
controller: emailController,
style: TextStyle(color: Colors.white),
keyboardType: TextInputType.emailAddress,
decoration: InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide(color:Theme.of(context).primaryColor)
),
fillColor: Colors.black87,
hintStyle: TextStyle(color:Colors.grey),
hintText: 'please enter your email',
labelText: 'Email',
labelStyle: TextStyle(color:Colors.white)
),
),
SizedBox(
height: 20,
),
Container(
width: double.infinity,
child: RaisedButton(
child: Text('Send'),
onPressed: (){
_isLoading
? CircularProgressIndicator()
: print(emailController.text);
_forgetPassword(emailController.text);
Navigator.of(context).pop();
}
),
),
Container(
width: double.infinity,
child: RaisedButton(
child: Text('Cancel'),
onPressed: (){
Navigator.of(context).pop();
}
),
),
],
),
);
}
}
最佳答案
更换您的setState((){});
与if (mounted) setState(() {});
。
The mounted checks Whether the [State] object is currently in a tree. That way, you would be able to avoid the error.
关于http - Flutter:我收到一个错误,指出状态为窗口小部件的对象不再出现在窗口小部件树中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63341823/
我正在尝试运行查询,但每当运行时都会收到一条错误消息,指出“列地址不能为空”。 这是我的代码。 package com.rajesh.action; import java.sql.*; public
当我运行此代码时: $addUniverseColumn = $db->prepare("ALTER TABLE spaceships ADD :universe int"); $addUnivers
我正在尝试从统一 ( https://unity3d.com/learn/tutorials/topics/analytics/integrating-unity-iap-your-game?play
我知道这个集合应该在 Date 对象上执行,但即使我在 Date 对象上执行。 reactdatepicker 根本不起作用。 第 12:3 行:“setHours”未定义 no-undef 第 12
我正在编写解析云代码,用于 ping eBay,返回带有项目结果的 JSON 数据,然后解析该数据并将前两个类别存储到数组中。发送到 eBay 的查询基于用户在我的 iOS 应用程序的 itemSea
这个问题在这里已经有了答案: 关闭 11 年前。 Possible Duplicate: Why can templates only be implemented in the header fi
下面是我的代码片段 //Search Bar Delegate func searchBar(searchBar: UISearchBar, textDidChange searchText: Str
在Android Studio中, 我在构建我的应用程序时遇到错误。 Error:Failed to find Build Tools revision 26.1.0 Install Build To
我应该添加一个方法并且不在 main 中调用 throws 吗?这样合适吗?我该怎么写呢?我不知道怎么写。 private static String fileName = "C:\\fruit.c
我试过这样做: select film.title,category.name,category.category_id from film inner join film_actor on film
我与 Parse 合作已经有一段时间了,并取得了巨大的成功。最近,我遇到了一个问题,促使我转向最新的基于 CDN 的 javascript API。在更改我的解析 API 版本(通过 cdn)后,我立
intro = new Audio.newMusic(Gdx.files.internal("core/assets/OpenSong.mp3")); 在javadocs中,这是它所说的这样做 htt
我的程序存在问题,该程序交叉引用文件并在按字母顺序排列的编号列表中显示某些信息。我不断收到 2 个错误,指出 newMyTree 以及 findOrInsert 的“ undefined refere
这个问题在这里已经有了答案: JavaScript setInterval and `this` solution (9 个回答) 关闭 3 年前。 我想做的是动画圆圈从 Canvas 边界弹起。我
我的理解是,进入 Mysql 字符串列 varchar(255) 的字符串理想情况下应该进入 varchar(255) 的 Redshift 列。 (utf8 字符集) 我被困在一个失败的用例中。 我
尝试在 Eclipse 中启动 Google App Engine 项目时,我不断收到错误消息,说 localhost 的 Server App Engine Standard 无法启动(错误日志如下
我正在尝试使用 NLTK 的朴素贝叶斯分类器训练数据集,但我的终端不断抛出此错误 # Applying Naive Bayes training_set = featursets[:2000] tes
我是大型机自动化的新手,正在尝试使用 Jagacy jar 和 java 来自动化应用程序。在一个特定的屏幕上,我必须输入一个从 0 到 9 的数字,从此我使用 jagacy 提供的 writePos
我需要一些关于该错误的帮助,不知道如何解决它。我是编程新手,我正在使用 Sublime Text 编辑器和 Cygwin64。这在我老师给我们的讲座中起作用了,现在我想知道我的编译器设置是否正确?
您好,我一直在尝试学习如何将 Stripe 预构建结帐页面集成到我的 django 项目中。 stripe 文档是针对 Flask 的,所以我正在尝试阅读或观看 YouTube 教程,了解如何将它们转
我是一名优秀的程序员,十分优秀!