import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; class EditName extends StatefulWidget { final Map arguments; EditName({this.arguments}); @override State createState() { return _EditName(); } } class _EditName extends State { TextEditingController _controller = TextEditingController(); @override Widget build(BuildContext context) { return Scaffold( appBar: MyAppBar( title: "修改用户名", titleColor: Colors.black, leadingColor: Colors.black, background: Colors.white, action: Container( alignment: Alignment.center, margin: EdgeInsets.only(right: 16.w), child: GestureDetector( onTap: () { String name = _controller.text; if (name != null && name != "") { Navigator.of(context).pop(name); } else { SmartDialog.showToast("请输入用户名", alignment: Alignment.center); } }, child: Text( "保存", style: TextStyle( color: Colors.black, fontSize: 18.sp, fontWeight: FontWeight.bold), ), ), ), ), body: Container( margin: EdgeInsets.all(16), child: Column( children: [ TextField( style: TextStyle( height: 1.h, fontSize: 16.sp, ), onChanged: (value) {}, controller: _controller, keyboardType: TextInputType.text, decoration: InputDecoration( errorBorder: InputBorder.none, focusedBorder: InputBorder.none, enabledBorder: InputBorder.none, hintText: widget.arguments['nick'], // contentPadding: EdgeInsets.only(top: 12, bottom: 12, left: 12), hintStyle: TextStyle( fontSize: 10.sp, color: Color(0xFFA29E9E), ), ), textInputAction: TextInputAction.next, inputFormatters: [LengthLimitingTextInputFormatter(10)], maxLines: 1, ), Container( height: 1.h, color: Color(0xFF32A060), ), ], ), ), ); } }