import 'package:flutter/material.dart'; class RegisterPage extends StatefulWidget { @override _RegisterPageState createState() => _RegisterPageState(); } class _RegisterPageState extends State { TextEditingController _usernameContrller = TextEditingController(); TextEditingController _passwordContrller = TextEditingController(); @override Widget build(BuildContext context) { return Scaffold( body: Column( children: [ SizedBox( height: 20, ), Image.asset( "assets/images/leaf.jpg", width: 200, ), Text("注册页面"), TextFormField( controller: _usernameContrller, decoration: InputDecoration(hintText: "用户名", icon: Icon(Icons.person)), ), TextFormField( decoration: InputDecoration(icon: Icon(Icons.lock), hintText: "密码"), controller: _passwordContrller, ), SizedBox( height: 20, ), TextButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.all(Colors.blue), minimumSize: MaterialStateProperty.all(Size(200, 40))), onPressed: () { register(); }, child: Text( "注册", style: TextStyle(color: Colors.white), )) ], ), ); } void register() {} }