我将一些用户信息从第一个屏幕传递到第二个屏幕,在第二个屏幕上,我尝试在文本字段内编辑该信息。我的第二个屏幕的代码如下。
class EditProfile extends StatefulWidget {
String profName;
String profOcc;
EditProfile({Key? key, required this.profName, required this.profOcc,}): super(key: key);
@override
_EditProfileState createState() => _EditProfileState();
}
class _EditProfileState extends State<EditProfile> {
@override
Widget build(BuildContext context) {
var nameController = TextEditingController()..text = widget.profName;
var occController = TextEditingController()..text = widget.profOcc;
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
elevation: 1,
leading: IconButton(
icon: Icon(
Icons.arrow_back,
color: Color(0xFF6f6bdb),
),
onPressed: (){
Navigator.pop(context);
},
),
),
body: Container(
padding: EdgeInsets.fromLTRB(30.0, 30.0, 30.0, 0.0),
child: GestureDetector(
onTap: () {FocusScope.of(context).unfocus();}, …Run Code Online (Sandbox Code Playgroud)