1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import 'package:flutter/material.dart';
- import 'package:flutter_green/dao/user_dao.dart';
- import 'package:flutter_green/routes/Routes.dart';
- /// 登录页面
- class LoginPage extends StatefulWidget {
- @override
- _LoginPageState createState() => _LoginPageState();
- }
- class _LoginPageState extends State<LoginPage> {
- TextEditingController _usernameContrller = TextEditingController();
- TextEditingController _passwordContrller = TextEditingController();
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- body: Container(
- padding: EdgeInsets.only(left: 20, right: 20),
- child: 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: () {
- login();
- },
- child: Text(
- "登录",
- style: TextStyle(color: Colors.white),
- ))
- ],
- ),
- ),
- );
- }
- login() {
- var user = UserDao.login(_usernameContrller.text, _passwordContrller.text);
- // if(user.success)
- Navigator.pushNamed(context, Routes.homePage);
- }
- }
|