import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:track_common/view.dart'; abstract class InitController extends GetxController { Future isNeedLogin(); Future allInit(); final _use = true.obs; @override void onInit() { super.onInit(); init(); } Future init() async { await allInit(); if (await isNeedLogin()) { LoginView.to( canBack: false, thenToPageCall: () { Get.offAllNamed(HomeView.name); }); } else { Get.offAllNamed(HomeView.name); } } } class InitView extends GetView { const InitView({super.key}); static const name = '/InitView'; @override Widget build(BuildContext context) { return Scaffold( body: Obx(() => Text('${controller._use}', style: const TextStyle(color: Colors.transparent)))); } } // class _State extends State { // @override // Widget build(BuildContext context) { // return const Scaffold(body: Center()); // } // // void init() async { // await allInit(); // await 1.seconds.delay(); // // // // // try { // // await api.ApiService.to.stub.toMapListV2(api.MapListRequestV2()); // Get.offAll(() => const HomeView(), binding: HomeView.bindings()); // } catch (e) { // LoginView.to( // canBack: false, // thenToPageCall: () { // Get.offAll(() => const HomeView(), binding: HomeView.bindings()); // }); // } // } // // @override // void initState() { // super.initState(); // // init(); // } // }