https://github.com/octmon/flutter_easy
A common Flutter package.
https://github.com/octmon/flutter_easy
app common fast flutter
Last synced: about 1 year ago
JSON representation
A common Flutter package.
- Host: GitHub
- URL: https://github.com/octmon/flutter_easy
- Owner: OctMon
- License: mit
- Created: 2019-08-12T14:48:53.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2024-05-02T13:32:49.000Z (about 2 years ago)
- Last Synced: 2024-05-03T03:29:15.010Z (about 2 years ago)
- Topics: app, common, fast, flutter
- Language: Dart
- Homepage:
- Size: 8.33 MB
- Stars: 7
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://octmon.github.io/)
# flutter_easy
[](https://pub.dev/packages/flutter_easy)
[](https://flutter.dev)
[](https://github.com/OctMon/flutter_easy/blob/main/LICENSE)
[](https://github.com/OctMon/flutter_easy/actions)
A common Flutter package.
[Example](https://octmon.github.io/flutter_easy/)
## Getting Started
Additional arguments:
```
--dart-define=app-debug-flag=true
```
Run:
```bash
flutter run --release --dart-define=app-debug-flag=true
```
[Example:](https://www.octmon.com/example)
main.dart
```dart
void main() async {
await initEasyApp(
appBaseURLChangedCallback: () {
// Reload API
configAPI(null);
},
);
await initApp();
runApp(const MyApp());
if (isAndroid) {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
// Set overlay style status bar. It must run after MyApp(), because MaterialApp may override it.
SystemUiOverlayStyle systemUiOverlayStyle =
const SystemUiOverlayStyle(statusBarColor: Colors.transparent);
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
}
}
```
app.dart
```dart
Future initApp() async {
// Encrypt password
StorageUtil.setEncrypt("XxXxXxXxXxXxXxXxX");
// Load user info
await Get.putAsync(() => UserService().load());
// Load API
configAPI(null);
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return BaseApp(
initialRoute: Routes.splash,
getPages: Routes.routes,
localizationsDelegates: const [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
LocaleNamesLocalizationsDelegate(),
],
supportedLocales: S.delegate.supportedLocales,
locale: Get.deviceLocale,
localeResolutionCallback:
(Locale? locale, Iterable supportedLocales) {
logDebug("localeResolutionCallback: $locale");
if (locale == null || !S.delegate.isSupported(locale)) {
return null;
}
if (locale.languageCode == "zh") {
return const Locale("zh", "CN");
}
return locale;
},
);
}
}
```
routes.dart
```dart
class Routes {
static final String root = '/';
static final String splash = '/splash';
Routes._();
static final List routes = [
GetPage(
name: Routes.root,
page: () => RootPage(),
),
GetPage(
name: Routes.splash,
page: () => SplashPage(),
),
GetPage(
name: routesLoginNamed,
page: () => LoginPage(),
),
}
```
# Installing
Add flutter_easy to your pubspec.yaml file:
```yaml
dependencies:
flutter_easy:
```
Import flutter_easy in files that it will be used:
```dart
import 'package:flutter_easy/flutter_easy.dart';
```