问题描述
我是扑朔迷离的新手,我尝试了很多api来访问此api,并且正在访问,但问题是那.. 当我打电话给onpress按钮未激活时... 我将参数传递给textfileds及其传递...。实际地 您可以检查没有激活Sign Up功能代码的“取消激活”按钮的问题吗?
在我描述的SignUp方法中查找,如果响应为!= null,我将描述该方法 然后我要导航! 但就我而言,代码中不会发生 请帮我
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),top: 380,child: TextFormField(
controller: passwordController,decoration: Inputdecoration(
icon: Icon(Icons.lock,hintText: "Password",Positioned(
top: 460,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)),child: Text(
"SEND OTP",style:
GoogleFonts.nunito( color: const Color(0xffffffff),fontSize: 12
),)
],);
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)