Api ON按下按钮未激活!请给我任何解决办法……谢谢
我是一个新手,我尝试了很多次这个api访问,它正在访问,但问题是。。 当我呼叫ON时,按下按钮未激活。。。 我将参数传递给textfileds并传递它。。。。!实际上 您是否可以在未读取注册功能代码的情况下检查problm fr未激活按钮的原因 如果我的回答是!=无效的 那我要导航! 但在我的情况下,在我的代码中不会发生 请帮帮我Api ON按下按钮未激活!请给我任何解决办法……谢谢,api,flutter,onpress,Api,Flutter,Onpress,我是一个新手,我尝试了很多次这个api访问,它正在访问,但问题是。。 当我呼叫ON时,按下按钮未激活。。。 我将参数传递给textfileds并传递它。。。。!实际上 您是否可以在未读取注册功能代码的情况下检查problm fr未激活按钮的原因 如果我的回答是!=无效的 那我要导航! 但在我的情况下,在我的代码中不会发生 请帮帮我 import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:goog
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:http/http.dart' as http;
import 'package:shared_preferences/shared_preferences.dart';
import 'package:sms_snd/data.dart';
import 'new.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Loginpage(),
);
}
}
class Loginpage extends StatefulWidget {
@override
_LoginpageState createState() => _LoginpageState();
}
class _LoginpageState extends State<Loginpage> {
Signup(String email,String Password) async{
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
Map data = {
"APIKEY":"QVBAMTIjMllIRC1TREFTNUQtNUFTRksyMjE4Ng==",
"SECRETKEY":"MjQ1QDEyIzJZSEQtODVEQTJTM0RFQTg1Mz1JRTVCNEE1ODY=",
"Email": email,
"Password":Password
};
var jsonResponse;
var response = await http.post("http://services.edbrix.net/auth/login",
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
body: jsonEncode(data));
if (response.statusCode == 200){
jsonResponse = json.decode(response.body);
print("Response status : ${response.statusCode}");
print("Response status : ${response.body}");
if(jsonResponse != null){
setState(() {
_isLoading = false;
});
sharedPreferences.setString("AccessToken", jsonResponse["AccessToken"]);
Navigator.of(context).pushAndRemoveUntil(MaterialPageRoute(builder: (BuildContext context) =>
newapp()), (Route<dynamic> route) => false);
}
else{
setState(() {
_isLoading = false;
});
print("Response status : ${response.body}");
}
}
}
String _email;
bool _isLoading = false;
String _pass;
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final TextEditingController emailController = new TextEditingController();
final TextEditingController passwordController = new TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white10,
body:_isLoading ? Center(child: CircularProgressIndicator()) : Form(
key: _formKey,
child: Stack(
children: <Widget>[
Positioned(
left: 40,
right: 40,
top: 250,
child: Center(
child: Text(
'Welcome!',
style: GoogleFonts.nunito(
fontSize: 31,
color: const Color(0xfff58634),
fontWeight: FontWeight.w700,
height: 1.1290322580645162,
),
textAlign: TextAlign.center,
),
),
),
Positioned(
left: 30,
right: 30,
top: 320,
child: SizedBox(
height: 50,
width: 170,
child: TextFormField(
controller: emailController,
cursorColor: Colors.black,
style: TextStyle(color: Colors.white70),
decoration: InputDecoration(
icon: Icon(Icons.email, color: Colors.white70),
hintText: "Email",
border: UnderlineInputBorder(borderSide: BorderSide(color: Colors.white70)),
hintStyle: TextStyle(color: Colors.white70),
),
),
),
),
Positioned(
left: 30,
right: 30,
top: 380,
child: SizedBox(
height: 50,
width: 170,
child: TextFormField(
controller: passwordController,
cursorColor: Colors.black,
style: TextStyle(color: Colors.white70),
decoration: InputDecoration(
icon: Icon(Icons.lock, color: Colors.white70),
hintText: "Password",
border: UnderlineInputBorder(borderSide: BorderSide(color: Colors.white70)),
hintStyle: TextStyle(color: Colors.white70),
),
),
),
),
Positioned(
top: 460,
right: 30,
child:SizedBox(
height: 45,
child: RaisedButton(
onPressed:
emailController.text == "" || passwordController.text == "" ? null : () {
Signup(emailController.text.toString(), passwordController.text.toString());
},
shape: new RoundedRectangleBorder(borderRadius: new BorderRadius.circular(5.0)),
color: const Color(0xfff58634),
child: Text(
"SEND OTP",style:
GoogleFonts.nunito( color: const Color(0xffffffff),
fontSize: 12
),
),
),
),
)
],
),
),
);
}
}
导入'dart:convert';
进口“包装:颤振/材料.省道”;
导入“package:google_fonts/google_fonts.dart”;
将“package:http/http.dart”导入为http;
导入“package:shared_preferences/shared_preferences.dart”;
导入“包:sms_snd/data.dart”;
导入“new.dart”;
void main(){
runApp(MyApp());
}
类MyApp扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
返回材料PP(
debugShowCheckedModeBanner:false,
主页:登录页面(),
);
}
}
类Loginpage扩展StatefulWidget{
@凌驾
_LoginPagentate createState()=>_LoginPagentate();
}
类_loginpagentate扩展状态{
异步注册(字符串电子邮件、字符串密码){
SharedReferences SharedReferences=等待SharedReferences.getInstance();
地图数据={
“APIKEY”:“QVBAMTIjMllIRC1TREFTNUQtNUFTRksyMjE4Ng=”,
“保密密钥”:“MJQ1QDEYIZZSEQTODVEQTJTM0RFQTG1MZ1JRTVCNEE1ODY=”,
“电子邮件”:电子邮件,
“密码”:密码
};
var-jsonResponse;
var response=wait http.post(“http://services.edbrix.net/auth/login",
标题:{
“内容类型”:“应用程序/json;字符集=UTF-8”,
},
正文:JSONECODE(数据));
如果(response.statusCode==200){
jsonResponse=json.decode(response.body);
打印(“响应状态:${Response.statusCode}”);
打印(“响应状态:${Response.body}”);
if(jsonResponse!=null){
设置状态(){
_isLoading=false;
});
setString(“AccessToken”,jsonResponse[“AccessToken”]);
Navigator.of(context).pushandremoveintil(MaterialPageRoute(builder:(BuildContext context)=>
newapp(),(路由)=>false);
}
否则{
设置状态(){
_isLoading=false;
});
打印(“响应状态:${Response.body}”);
}
}
}
字符串\u电子邮件;
bool_isLoading=false;
字符串传递;
最终的GlobalKey _formKey=GlobalKey();
final TextEditingController emailController=新TextEditingController();
final TextEditingController密码控制器=新TextEditingController();
@凌驾
小部件构建(构建上下文){
返回脚手架(
背景颜色:Colors.white10,
正文:_isLoading?中心(子项:CircularProgressIndicator()):窗体(
键:_formKey,
子:堆栈(
儿童:[
定位(
左:40,,
右:40,,
排名:250,
儿童:中心(
子:文本(
“欢迎!”,
风格:GoogleFonts.nunito(
尺码:31,
颜色:常量颜色(0xfff58634),
fontWeight:fontWeight.w700,
身高:1.1290322580645162,
),
textAlign:textAlign.center,
),
),
),
定位(
左:30,,
右:30,,
top:320,
孩子:大小盒子(
身高:50,
宽度:170,
子项:TextFormField(
控制器:emailController,
光标颜色:颜色。黑色,
样式:TextStyle(颜色:Colors.white70),
装饰:输入装饰(
图标:图标(Icons.email,颜色:Colors.white70),
hintText:“电子邮件”,
边框:下划线输入边框(borderSide:borderSide(颜色:Colors.white70)),
hintStyle:TextStyle(颜色:Colors.white70),
),
),
),
),
定位(
左:30,,
右:30,,
top:380,
孩子:大小盒子(
身高:50,
宽度:170,
子项:TextFormField(
控制器:密码控制器,
光标颜色:颜色。黑色,
样式:TextStyle(颜色:Colors.white70),
装饰:输入装饰(
图标:图标(Icons.lock,color:Colors.white70),
hintText:“密码”,
边框:下划线输入边框(borderSide:borderSide(颜色:Colors.white70)),
hintStyle:TextStyle(颜色:Colors.white70),
),
),
),
),
定位(
排名:460,
右:30,,
孩子:大小盒子(
身高:45,
孩子:升起按钮(
按下按钮:
emailController.text==“”| | passwordController.text==“”?null:(){
注册(emailController.text.toString(),passwordController.text.toString());
},
形状:新的RoundedRectangleBorder(borderRadius:新的borderRadius.circular(5.0)),
颜色:常量颜色(0xfff58634),
子:文本(
“发送OTP”,样式:
GoogleFonts.nunito(颜色:const color(0xFFFFFF),
字体大小:12
),
),
),
),
)
],
),
),
);
}
}