flutter_easy

flutter_easy

pub flutter license build

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

Example:

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("963K3REfb30szs1n");
  // 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

adapt_util
base
base64_image
base_animation_image
base_animation_number_text
base_cycle_view
base_loading_view
base_placeholder_view
base_progress_bar
base_refresh
base_segment_bar
base_sliver_persistent_header
base_state
base_tab_page
base_tag_list_view
base_web_image
color_util
crypto_util
date_util
duration_extensions
dynamic_extensions
export
export
export
flutter_easy
global_util
hw_html
hw_io
hw_mp
https://dart.dev/guides/libraries/create-library-packages
hw_none
json_util
keep_alive
loading_util
locale_util
logger_util
lunar_calendar_converter
map_extensions
network_util
num_extensions
package_info_util
picker_util
routes
shared_preferences_util
storage_util
string_extensions
string_util
timer_util
toast_util
uuid_util