comm_app 0.0.1-dev copy "comm_app: ^0.0.1-dev" to clipboard
comm_app: ^0.0.1-dev copied to clipboard

flutter app encapsulates basic app functions.

example/lib/main.dart

import 'package:comm_app/language/language.dart';
import 'package:comm_app/language/language_utils.dart';
import 'package:comm_app/language/vo/language_vo.dart';
import 'package:comm_utils/xutils.dart';
import 'package:example/generated/l10n.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 languageList = <LanguageVo>[];
  languageList.add(LanguageVo(
      Language.en.name, Language.en.languageCode, Language.en.countryCode));
  languageList.add(LanguageVo(
      Language.cn.name, Language.cn.languageCode, Language.cn.countryCode));
  languageList.add(LanguageVo(
      Language.tw.name, Language.tw.languageCode, Language.tw.countryCode));
  LanguageUtils.get.init(languageList, (p0) => S.load(p0));
  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: LanguageUtils.get.getCurrentLocal(),
      supportedLocales: S.delegate.supportedLocales,
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      initialRoute: PageManger.home,
      getPages: PageManger.pages,
    );
  }
}
0
likes
130
pub points
0%
popularity

Publisher

unverified uploader

flutter app encapsulates basic app functions.

Homepage

Documentation

API reference

License

Apache-2.0 (LICENSE)

Dependencies

comm_utils, flutter, json_annotation

More

Packages that depend on comm_app