init_view.dart 956 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import 'package:flutter/material.dart';
  2. import 'package:get/get.dart';
  3. import '../service/all_init.dart';
  4. import '../service/api.dart' as api;
  5. import 'home/home_view.dart';
  6. import 'login/login_view.dart';
  7. class InitView extends StatefulWidget{
  8. const InitView({super.key});
  9. @override
  10. State<StatefulWidget> createState() {
  11. return _State();
  12. }
  13. }
  14. class _State extends State<InitView>{
  15. @override
  16. Widget build(BuildContext context) {
  17. return const Scaffold(body: Center());
  18. }
  19. void init()async{
  20. await allInit();
  21. await 1.seconds.delay();
  22. try{
  23. await api.ApiService.to.stub.toMapListV2(api.MapListRequestV2());
  24. Get.offAll(()=>const HomeView(), binding: HomeView.bindings());
  25. }catch(e){
  26. LoginView.to(canBack: false, thenToPageCall: (){
  27. Get.offAll(()=>const HomeView(), binding: HomeView.bindings());
  28. });
  29. }
  30. }
  31. @override
  32. void initState() {
  33. super.initState();
  34. init();
  35. }
  36. }