comm_utils 0.0.5 comm_utils: ^0.0.5 copied to clipboard
This is a fullter tool class, which encapsulates various tool processing classes.
import 'package:comm_utils/comm_http.dart';
import 'package:comm_utils/xutils.dart';
import 'package:example/generated/l10n.dart';
import 'package:example/page/home_page.dart';
import 'package:example/http/api_repository.dart';
import 'package:example/http/throw_handler.dart';
import 'package:example/page_manager.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:get/get.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
/// 初始化utils
await XUtils.get.init(debug: kDebugMode);
///初始化网络
var config = HttpConfig("https://consumer.maxspos.com", ThrowHandler());
var httpClient = HttpServer(config);
///创建数据仓库
Get.lazyPut(fenix: true, () => ApiRepository(httpClient));
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return GetMaterialApp(
localizationsDelegates: const [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
locale: const Locale("en"),
supportedLocales: S.delegate.supportedLocales,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
initialRoute: PageManger.home,
getPages: PageManger.pages,
);
}
}