flutterx_application 1.6.7 copy "flutterx_application: ^1.6.7" to clipboard
flutterx_application: ^1.6.7 copied to clipboard

outdated

Core functionalities of a flutter application including translations, lifecycle events, navigation, dialogs

example/lib/main.dart

import 'package:example/localization/labels.dart';
import 'package:example/ui/activity_data_delegate.dart';
import 'package:example/ui/activity_data_insert.dart';
import 'package:example/ui/activity_fragment.dart';
import 'package:example/ui/activity_home.dart';
import 'package:example/ui/activity_login.dart';
import 'package:example/ui/activity_private.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutterx_application/flutterx_application.dart';
import 'package:flutterx_preferences/flutterx_preferences.dart';

void main() => runApplication(
    name: 'Flutterx Application Demo',
    routes: {
      HomeActivity.route,
      DataDelegateActivity.route,
      DataInsertActivity.route,
      LoginActivity.route,
      PrivateActivity.route,
      FragmentActivity.route,
    },
    onUnknownRoute: (args) => _UnknownRouteActivity.route,
    initialize: () => HomeActivity.route,
    locale: LocaleData<Labels>(labels: Labels.supportedLabels, onLabel: Labels.onLabel, storage: sessionStorage),
    appFactory: ({
      required routeInformationProvider,
      required routeInformationParser,
      required routerDelegate,
      required onGenerateTitle,
      required locale,
      required localizationsDelegates,
      required supportedLocales,
    }) =>
        MaterialApp.router(
            routeInformationProvider: routeInformationProvider,
            routeInformationParser: routeInformationParser,
            routerDelegate: routerDelegate,
            theme: _appTheme,
            onGenerateTitle: onGenerateTitle,
            locale: locale,
            localizationsDelegates: localizationsDelegates,
            supportedLocales: supportedLocales,
            debugShowCheckedModeBanner: false));

final _appTheme = ThemeData(
    primaryColor: Colors.blueGrey,
    colorScheme: ColorScheme.fromSwatch(
      primarySwatch: Colors.blueGrey,
    ),
    bottomSheetTheme: BottomSheetThemeData(
      backgroundColor: Colors.blueGrey[600],
    ));

class _UnknownRouteActivity extends StatelessWidget {
  static final ActivityRoute<String?> route =
      ActivityRoute(location: '/404', builder: (context, args) => _UnknownRouteActivity._(location: args['location']));

  final String location;

  const _UnknownRouteActivity._({required this.location});

  @override
  Widget build(BuildContext context) => Scaffold(
        body: Center(
          child: Column(mainAxisSize: MainAxisSize.min, children: [
            const Text('404', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 32)),
            const SizedBox(height: 48),
            Text('Requested page not found: $location'),
            const SizedBox(height: 24),
            ElevatedButton(
                onPressed: () async =>
                    await Navigator.of(context).maybePop() ? null : Application.of(context).restart(),
                child: const Text('Back')),
          ]),
        ),
      );

  @override
  void debugFillProperties(DiagnosticPropertiesBuilder properties) {
    super.debugFillProperties(properties);
    properties.add(StringProperty('location', location));
  }
}
4
likes
0
points
164
downloads

Publisher

unverified uploader

Weekly Downloads

Core functionalities of a flutter application including translations, lifecycle events, navigation, dialogs

Repository (GitLab)
View/report issues

License

unknown (license)

Dependencies

collection, flutter, flutter_localizations, flutter_web_plugins, flutterx_live_data, flutterx_preferences, flutterx_utils

More

Packages that depend on flutterx_application