flutter_mediator_persistence 1.0.0 copy "flutter_mediator_persistence: ^1.0.0" to clipboard
flutter_mediator_persistence: ^1.0.0 copied to clipboard

unlistedoutdated

A super easy state management package with built in persistence capability, base on the Flutter Mediator Lite.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:flutter_i18n/loaders/decoders/json_decode_strategy.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_mediator_persistence/mediator.dart';

import 'route.dart';
import 'theme.dart';
import 'var.dart';

Future<void> main() async {
  //* Step1: Initial the persistent store.
  await initGlobalPersist();

  runApp(
    //* Step2: Create the host with `globalHost`
    //* at the top of the widget tree.
    globalHost(
      child: MyApp(),
    ),
  );
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return themeIdx.consume(
      () => MaterialApp(
        title: 'Login to REST server example',
        debugShowCheckedModeBanner: false,
        theme: themeData(themeIdx.value),
        // home: LoginPage(),
        // initialRoute: ,
        routes: routes,
        localizationsDelegates: [
          FlutterI18nDelegate(
            translationLoader: FileTranslationLoader(
              forcedLocale: Locale(locale.value),
              // useCountryCode: true,
              fallbackFile: DefaultLocale,
              basePath: 'assets/flutter_i18n',
              decodeStrategies: [JsonDecodeStrategy()],
            ),
            missingTranslationHandler: (key, locale) {
              print(
                  '--- Missing Key: $key, languageCode: ${locale!.languageCode}');
            },
          ),
          GlobalMaterialLocalizations.delegate,
          GlobalWidgetsLocalizations.delegate,
        ],
      ),
    );
  }
}
2
likes
0
pub points
0%
popularity

Publisher

unverified uploader

A super easy state management package with built in persistence capability, base on the Flutter Mediator Lite.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, shared_preferences

More

Packages that depend on flutter_mediator_persistence