setting_page.dart
2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:wow_english/common/widgets/we_app_bar.dart';
import 'package:wow_english/utils/toast_util.dart';
import '../../../route/route.dart';
class SettingPage extends StatefulWidget {
const SettingPage({super.key});
@override
State<StatefulWidget> createState() {
return SettingPageState();
}
}
class SettingPageState extends State<SettingPage> {
String? _version;
String? _buildNum;
@override
void initState() {
super.initState();
_retrieveVersionInfo();
}
Future<void> _retrieveVersionInfo() async {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
setState(() {
_version = packageInfo.version;
_buildNum = packageInfo.buildNumber;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: const WEAppBar(
titleText: '设置',
),
body: Container(
color: Colors.white,
padding: EdgeInsets.only(left: 17.w, right: 17.w),
child: SafeArea(
child: Center(
child: ListView(
children: [
34.verticalSpace,
_buildItemWidget('注销账号', onPress: () {
pushNamed(AppRouteName.deleteAccount);
}),
12.verticalSpace,
_buildItemWidget('清除缓存', onPress: () {
EasyLoading.show();
Future.delayed(const Duration(seconds: 1), (){
showToast("清除成功");
EasyLoading.dismiss();
});
}),
12.verticalSpace,
_buildItemWidget('帮助与反馈', onPress: () {
pushNamed(AppRouteName.reBack);
}),
12.verticalSpace,
_buildItemWidget('Version: $_version Build:$_buildNum',
onPress: () {}),
],
),
),
),
),
);
}
Widget _buildItemWidget(String text, {VoidCallback? onPress}) {
return OutlinedButton(
onPressed: () => onPress?.call(),
style: ButtonStyle(
side: MaterialStateProperty.all(
BorderSide(color: const Color(0xFF140C10), width: 1.5.w)),
shape: MaterialStateProperty.all(
RoundedRectangleBorder(borderRadius: BorderRadius.circular(15.r))),
minimumSize: MaterialStateProperty.all(Size(double.infinity, 58.h)),
backgroundColor: MaterialStateProperty.all(Colors.white),
),
child: Text(
text,
style: TextStyle(
//fontWeight: FontWeight.w600,
color: const Color(0xFF333333),
fontSize: 21.sp,
),
),
);
}
}