flutter flutter_easyloading全局初始化

麻阳
2023-12-01

参考
flutter_easyloading全局初始化

flutter_easyloading: ^3.0.3

在main里面使用builder: EasyLoading.init(),在其他界面就直接展示消失就可以了

import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:music/Login.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'RegisterDart.dart';
import 'MusicPlayer.dart';
import 'SplashPageLoading.dart';

//main函数的runApp方法设置首页界面
void main() {
  // SharedPreferences.setMockInitialValues({});
  // runApp(Login());
  runApp(MyApp());
  // runApp(SplashPageLoading());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      //全局加载弹窗初始化,其他地方就直接显示和消失就可以了
      builder: EasyLoading.init(),
      home: Login(),
    );
  }
}


 类似资料: