flutterx_application 1.5.3 flutterx_application: ^1.5.3 copied to clipboard
Core functionalities of a flutter application including translations, lifecycle events, navigation, dialogs
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.supportedLabels, onLabel: Labels.onLabel, storage: sessionStorage),
appFactory: (routeInformationProvider, routeInformationParser, routerDelegate, onGenerateTitle, locale,
localizationsDelegates, 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._({Key? key, required this.location}) : super(key: key);
@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));
}
}