index.dart 3.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import 'package:get/get.dart';
  2. import 'package:get_storage/get_storage.dart';
  3. import './widgets/OtherColumn.dart';
  4. import './widgets/UserAddress.dart';
  5. import './widgets/UserInfo.dart';
  6. import 'package:flutter/material.dart';
  7. import 'package:flutter_screenutil/flutter_screenutil.dart';
  8. class MainPage extends StatefulWidget {
  9. const MainPage({Key? key}) : super(key: key);
  10. @override
  11. State<MainPage> createState() => _MainPageState();
  12. }
  13. class _MainPageState extends State<MainPage> {
  14. GetStorage box = GetStorage();
  15. @override
  16. Widget build(BuildContext context) {
  17. return Container(
  18. alignment: Alignment.center,
  19. child: ListView(
  20. children: [
  21. Column(
  22. children: [
  23. UserInfo(), //头部,头像手机号姓名
  24. UserAddress(), //用户地址
  25. OtherColumn(), //功能菜单栏
  26. Container(
  27. height: 70.h,
  28. margin: EdgeInsets.only(top: 0, bottom: 40.0),
  29. alignment: Alignment.bottomCenter,
  30. decoration: BoxDecoration(
  31. boxShadow: [
  32. BoxShadow(
  33. blurRadius: 10, //阴影范围
  34. spreadRadius: 0.1, //阴影浓度
  35. color: Colors.grey.withOpacity(0.2), //阴影颜色
  36. ),
  37. ],
  38. ),
  39. child: SizedBox(
  40. width: 315.w,
  41. height: 49.h,
  42. child: ElevatedButton(
  43. onPressed: () {
  44. showDialog(
  45. context: context,
  46. builder: (context) {
  47. return AlertDialog(
  48. content: Text("您确定退出登录吗?"),
  49. actions: <Widget>[
  50. TextButton(
  51. child: Text("取消"),
  52. onPressed: () {
  53. Navigator.pop(context, 'Cancle');
  54. },
  55. ),
  56. TextButton(
  57. child: Text("确定"),
  58. onPressed: () {
  59. Navigator.pop(context, "Ok");
  60. box.remove('token');
  61. Get.offNamed('/login');
  62. })
  63. ]);
  64. });
  65. },
  66. child: const Text(
  67. "退出登陆",
  68. style: TextStyle(
  69. fontSize: 18,
  70. color: Colors.black,
  71. fontWeight: FontWeight.bold),
  72. ),
  73. style: ButtonStyle(
  74. elevation: MaterialStateProperty.all(0),
  75. backgroundColor:
  76. MaterialStateProperty.all(const Color(0xFFFFFFFF)),
  77. shape: MaterialStateProperty.all(
  78. const RoundedRectangleBorder(
  79. borderRadius:
  80. BorderRadius.all(Radius.circular(24.4)))),
  81. ),
  82. ),
  83. ),
  84. ),
  85. ],
  86. ),
  87. ],
  88. ),
  89. );
  90. }
  91. }