import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:ysairplane2/base/YSBase.dart'; import 'package:ysairplane2/tools/YSNetWorking.dart'; import 'package:ysairplane2/tools/YSTools.dart'; class YSSettleIn extends StatefulWidget { @override _YSSettleInState createState() => _YSSettleInState(); } class _YSSettleInState extends State { TextEditingController _nameField = TextEditingController(); TextEditingController _phoneField = TextEditingController(); @override Widget build(BuildContext context) { return YSBase( ystitle: '入驻信息', ysright: GestureDetector( child: Text('保存',style: TextStyle(fontSize: zsp(36),color: Color(0xFF007AFF)),), onTap: (){ _postSettleInData(); }, ), yscolor: Color(0xFFF5F6F8), yschild: ListView.builder( shrinkWrap: true, itemCount: 2, itemBuilder: (context,index){ return Container( margin: EdgeInsets.only(top: hsp(10)), color: Colors.white, height: hsp(100), padding: EdgeInsets.only(left: hsp(30),right: hsp(30)), width: MediaQuery.of(context).size.width, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text(index==0?'姓名':'电话',style: TextStyle(fontSize: zsp(32),color: Color(0xFF000000)),), Container( width: MediaQuery.of(context).size.width-hsp(150), child: CupertinoTextField( placeholder: index==0?'请输入姓名':'请输入电话', style: TextStyle(fontSize: zsp(32),color: Color(0xFF000000)), decoration: BoxDecoration(), controller: index==0?_nameField:_phoneField, keyboardType: index==0?TextInputType.text:TextInputType.phone, ), ) ], ), ); }, ), ); } _postSettleInData() async{ if(_nameField.text.isEmpty){ ysFlutterToast(context, '请输入姓名'); return; } if(_phoneField.text.isEmpty){ ysFlutterToast(context, '请输入电话'); return; } Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/appsettled/add',parameter: {'name':_nameField.text,'phone':_phoneField.text}, refresh: (){_postSettleInData();},isLoading: true,isToken: true); if(dict!=null){ ysFlutterToast(context, '入驻信息已提交'); Navigator.pop(context); } } }