login_page.dart 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'home_page.dart';
  4. import 'util/api.dart';
  5. class LoginPage extends StatefulWidget {
  6. LoginPage({
  7. Key key,
  8. }): super(key: key);
  9. _LoginPageState createState() => _LoginPageState();
  10. }
  11. class _LoginPageState extends State < LoginPage > {
  12. String phone;
  13. String password;
  14. @override
  15. Widget build(BuildContext context) {
  16. ScreenUtil.instance = ScreenUtil(width: 750, height: 1334,allowFontScaling:false)..init(context);
  17. return Scaffold(
  18. body: Container(
  19. color: Colors.white,
  20. child: ListView(
  21. children: < Widget > [
  22. Container(
  23. padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setHeight(55), 0, ScreenUtil.getInstance().setHeight(55), 0),
  24. child: Column(
  25. children: < Widget > [
  26. Padding(
  27. padding: EdgeInsets.fromLTRB(0, ScreenUtil.getInstance().setHeight(150), 0, ScreenUtil.getInstance().setHeight(60)),
  28. child: Center(
  29. child: Image.asset(
  30. 'lib/images/icon_logo.png',
  31. width: ScreenUtil.getInstance().setWidth(210),
  32. height: ScreenUtil.getInstance().setHeight(210),
  33. fit: BoxFit.cover,
  34. ),
  35. ),
  36. ),
  37. Padding(
  38. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(60)),
  39. child: TextField(
  40. keyboardType: TextInputType.phone,
  41. decoration: InputDecoration(
  42. border: UnderlineInputBorder(),
  43. hintText: "请输入手机号",
  44. hintStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32), color: Color.fromRGBO(155, 155, 155, 1)),
  45. ),
  46. onChanged: (value){
  47. setState(() {
  48. phone = value;
  49. });
  50. print(phone);
  51. },
  52. ),
  53. ),
  54. Padding(
  55. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(125)),
  56. child: TextField(
  57. cursorColor: Color.fromRGBO(153, 153, 153, 0.5),
  58. keyboardType: TextInputType.text,
  59. obscureText:true,
  60. decoration: InputDecoration(
  61. hintText: "请输入密码",
  62. hintStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32), color: Color.fromRGBO(155, 155, 155, 1)),
  63. ),
  64. onChanged: (value){
  65. setState(() {
  66. password =value;
  67. });
  68. print(password);
  69. print('111');
  70. },
  71. )
  72. ),
  73. GestureDetector(
  74. child: Container(
  75. height: ScreenUtil.getInstance().setHeight(100),
  76. decoration: BoxDecoration(
  77. color: Color.fromRGBO(64, 98, 254, 1),
  78. borderRadius: BorderRadius.circular(4),
  79. ),
  80. child: Center(
  81. child: Text('登录', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36), color: Colors.white)),
  82. ),
  83. ),
  84. onTap: () {
  85. Navigator.pushReplacement(context, MaterialPageRoute(builder: (context){
  86. return HomePage();
  87. }));
  88. },
  89. )
  90. ],
  91. ),
  92. )
  93. ],
  94. ),
  95. ),
  96. );
  97. }
  98. }