MoneyApp
平台
1 - Android
2 - iOS
3 - macOS
4 - Web
5 - Windows
架构
使用 GetX 进行层间通信的项目
库和工具
核心
本地存储
UI
Utils
开发依赖项
目录结构
这是 Flutter 提供的核心目录结构。
flutter-app/
|- android
|- build
|- ios
|- lib
|- macos
|- test
|- web
|- windows
这是我们在本项目中使用的目录结构
lib/
|- data/
|- domain/
|- presentation/
|- shared/
|- main.dart
现在,让我们深入 lib 目录,其中包含应用程序的主要代码。
1 - data - Contains the data layer of project, includes directories for local, network and shared pref/cache.
2 - domain - Contains abstraction and business logic of project, includes models, responses, request, etc.
3 - presentation - Contains all the ui of project, contains sub directory for each screen.
4 - shared - Contains the utilities/common functions, styles of application.
5 - main.dart - This is the starting point of the application. All the application level configurations are defined in this file i.e, theme, routes, title etc.
Main
这是应用程序的起点。所有应用程序级别的配置都定义在此文件中,例如主题、路由、标题等。
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:money_app/presentation/bindings/global_binding.dart';
import 'package:money_app/presentation/router/router.dart';
import 'package:money_app/presentation/router/routes.dart';
import 'package:money_app/shared/constants/app_values.dart';
import 'package:money_app/shared/core/localization/keys.dart';
import 'package:money_app/shared/core/localization/translations.dart';
import 'package:money_app/shared/styles/themes.dart';
import 'package:overlay_support/overlay_support.dart';
import 'package:url_strategy/url_strategy.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await GetStorage.init();
if (kIsWeb) {
setPathUrlStrategy();
}
runApp(const MoneyApp());
}
class MoneyApp extends StatelessWidget {
const MoneyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return OverlaySupport.global(
child: GetMaterialApp(
navigatorKey: Get.key,
getPages: AppRouter.routes,
initialRoute: AppRoutes.splash,
title: StringsKeys.moneyApp.tr,
initialBinding: GlobalBinding(),
translations: AppTranslations(),
locale: const Locale(AppValues.langCodeEN),
theme: AppThemes.getTheme(),
debugShowCheckedModeBanner: false,
),
);
}
}