如何開始
歡迎來到校務通系列共用工程,此套件提供給使用 Flutter 開發校務系統 App 的工具
事前準備
- Flutter v3.22 以後 並建立專案
安裝流程
確認你需要的範圍
在 v0.26 以後套件依據程式語言 Dart、框架 Flutter 及作業系統原生套件整合將套件拆成以下圖
可能會有哪些使用情境
-
使用套件所有功能
可直接使用
ap_common,在pubspec.yaml中加入 packagepubspec.yaml# 官方多國語套件
dependencies:
flutter_localizations:
sdk: flutter
ap_common: ^0.26.0在檔案中加入 main.dart
registerOneForAll();main.dartvoid main() {
WidgetsFlutterBinding.ensureInitialized();
/// Register all ap_common injection util
registerOneForAll();
runApp(MyApp());
} -
如果你只需要此只需要 UI,不希望整合過多原生作業系統套件,則
在
pubspec.yaml中加入 packagepubspec.yamldependencies:
# 官方多國語套件
flutter_localizations:
sdk: flutter
ap_common_flutter_core: ^0.1.0
ap_common_flutter_ui: ^0.1.0因沒使用套件
ap_common_flutter_platorm,每個此用到的介面會有特定 Util 類別需要實作,以CourseScaffold來說,就需要實作NotificationUtil及PlatformCalendarUtil,並在main.dart註冊你使用的實作:main.dartvoid main() {
WidgetsFlutterBinding.ensureInitialized();
registerApCommonFlutter({
ui: YourUiUtil(),
platform: YourPlatformUtil(),
media: YourMediaUtil(),
platformCalendar: YourPlatformCalendarUtil(),
notification: YourNotificationUtil(),
appStore: YourAppStoreUtil(),
});
registerApCommonCore(
preference: YourPreferenceUtil(),
);
runApp(MyApp());
}
執行取得套件
flutter pub get
執行範例專案(可選)
可嘗試執行範例專案測試環境可以正常使用此套件
至 GitHub 下載 專案
git clone https://github.com/abc873693/ap_common/
切換目錄至 example
cd apps/example/
並執行
flutter run