feat: 整体常用控件封装,常用工具类。首页数据对接
This commit is contained in:
1 parent
d90d023e85
commit
fbcd33ea2b
50 files changed
+4558
-264
No files matched your search
@@ -0,0 +1,57 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:skywood/main/lib_file.dart';
|
||||
|
||||
import '../../global/client/user_client.dart';
|
||||
import '../../main/main_root.dart';
|
||||
import '../../utils/tools/help_nav.dart';
|
||||
import '../../utils/tools/token_manage.dart';
|
||||
|
||||
class SplashPage extends StatefulWidget {
|
||||
|
||||
const SplashPage({super.key});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _SplashPageState();
|
||||
}
|
||||
}
|
||||
|
||||
class _SplashPageState extends State<SplashPage> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_userRegister();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
bottom: false,
|
||||
child: HelpImg.asset(ConstImg.splashPage, fit: BoxFit.cover)),
|
||||
);
|
||||
}
|
||||
|
||||
void _userRegister() async {
|
||||
// 先拿token没有的话去注册
|
||||
final tm = TokenManager();
|
||||
String token = tm.get();
|
||||
print('tokkkkkk: $token');
|
||||
if (token.isNotEmpty) {
|
||||
// 成功后去到主页面
|
||||
print('object去主页面');
|
||||
Future.delayed(const Duration(seconds: 1), () {
|
||||
HelpNav.off(MainRoot());
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
final res = await UserClient.register();
|
||||
if (res != null) {
|
||||
tm.save(res.token);
|
||||
HelpNav.off(MainRoot());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user