login_page.dart 4.0 KB

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