flutter_easy
A common Flutter package. Example
Getting Started
Additional arguments:
--dart-define=app-debug-flag=true
Run:
flutter run --release --dart-define=app-debug-flag=true
main.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
Future<void> 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<Locale> 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
class Routes {
static final String root = '/';
static final String splash = '/splash';
Routes._();
static final List<GetPage> 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:
dependencies:
flutter_easy:
Import flutter_easy in files that it will be used:
import 'package:flutter_easy/flutter_easy.dart';
Libraries
- components/export
- components/src/base
- components/src/base64_image
- components/src/base_animation_image
- components/src/base_animation_number_text
- components/src/base_cycle_view
- components/src/base_example_view
- components/src/base_loading_view
- components/src/base_placeholder_view
- components/src/base_progress_bar
- components/src/base_refresh
- components/src/base_segment_bar
- components/src/base_shimmer
- components/src/base_sliver_expanded
- components/src/base_sliver_persistent_header
- components/src/base_state
- components/src/base_tab_page
- components/src/base_tag_list_view
- components/src/base_web_image
- components/src/keep_alive
- extension/export
- extension/src/duration_extensions
- extension/src/dynamic_extensions
- extension/src/font_extensions
- extension/src/function_extensions
- extension/src/map_extensions
- extension/src/num_extensions
- extension/src/string_extensions
- extension/src/widget_extension
- flutter_easy
- routes/routes
- utils/export
- utils/src/adapt_util
- utils/src/color_util
- utils/src/connectivity_util
- utils/src/crypto_util
- utils/src/date_util
- utils/src/device_info_util
- utils/src/global_util
- utils/src/hw/hw_html
- utils/src/hw/hw_io
- utils/src/hw/hw_mp
- https://dart.dev/guides/libraries/create-library-packages
- utils/src/hw/hw_none
- utils/src/image_util
- utils/src/intl_util
- utils/src/json_util
- utils/src/loading_util
- utils/src/locale_util
- utils/src/logger_util
- utils/src/lunar/lunar_solar_converter
- utils/src/network_util
- utils/src/package_info_util
- utils/src/picker_util
- utils/src/storage_util
- utils/src/string_util
- utils/src/timer_util
- utils/src/toast_util
- utils/src/uuid_util
- utils/src/vendor_util