comm_utils 0.1.1 comm_utils: ^0.1.1 copied to clipboard
This is a fullter tool class, which encapsulates various tool processing classes.
import 'package:comm_utils/app_config.dart';
import 'package:comm_utils/export_khttp.dart';
import 'package:comm_utils/module/language/klanguage_utils.dart';
import 'package:comm_utils/module/language/language_vo.dart';
import 'package:example/http/api_repository.dart';
import 'package:example/http/throw_handler.dart';
import 'package:example/init_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitDown,
DeviceOrientation.portraitUp,
]);
/// 初始化全局配置
await AppConfig.init(() {
///初始化网络
var config = KHttpConfig("https://consumer.maxspos.com", ThrowHandler());
var httpClient = KHttpServer(config);
///创建数据仓库
Get.lazyPut(fenix: true, () => ApiRepository(httpClient));
///添加多语言
KLanguageUtils.get.initLanguage(
[LanguageVo.toSystem(), LanguageVo.toEn(), LanguageVo.toCN()]);
});
///会有警告,先去掉
// runZonedGuarded<Future<void>>(() async {
// var onError = FlutterError.onError; //先将 onerror 保存起来
// FlutterError.onError = (FlutterErrorDetails details) {
// onError?.call(details); //调用默认的onError
// };
runApp(const InitPage());
// }, (error, stack) => KLog.e(error.toString()));
}