SwiftFlutterMaterial class

A widget that wraps MaterialApp and automatically handles notification-based routing.

This widget checks if the app was launched from a notification and routes accordingly. It also handles navigation back to the initial screen when navigating back from a notification screen.

Example:

SwiftFlutterMaterial(
  initialRoute: '/home',
  routes: {
    '/home': (context) => HomeScreen(),
    '/notification': (context) => NotificationScreen(),
  },
  onNotificationLaunch: ({required isFromNotification, required payload}) {
    if (isFromNotification) {
      return '/notification';
    }
    return null; // Use initialRoute
  },
)
Inheritance

Constructors

SwiftFlutterMaterial({Key? key, required String initialRoute, String? homeRoute, Map<String, WidgetBuilder>? routes, Map<String, Widget Function(BuildContext, Map<String, dynamic>)>? routesWithPayload, NotificationRouteCallback? onNotificationLaunch, VoidCallback? onBackFromNotification, String? title, ThemeData? theme, ThemeData? darkTheme, ThemeMode? themeMode, bool? debugShowCheckedModeBanner, Widget builder(BuildContext, Widget?)?})
const

Properties

builder Widget Function(BuildContext, Widget?)?
Additional MaterialApp properties can be passed via this builder.
final
darkTheme ThemeData?
Dark theme for the app.
final
debugShowCheckedModeBanner bool?
Debug banner.
final
hashCode int
The hash code for this object.
no setterinherited
homeRoute String?
The route to navigate to when back is pressed from notification screen. If null, defaults to initialRoute.
final
initialRoute String
The initial route when app is launched normally (not from notification).
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onBackFromNotification VoidCallback?
Optional callback when navigation back occurs from notification screen. If null, navigates to homeRoute or initialRoute.
final
onNotificationLaunch NotificationRouteCallback?
Optional callback to determine route based on notification launch. If null, defaults to '/notification' when launched from notification.
final
routes Map<String, WidgetBuilder>?
The routes configuration for the app.
final
routesWithPayload Map<String, Widget Function(BuildContext, Map<String, dynamic>)>?
Routes with access to notification payload.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
theme ThemeData?
Theme for the app.
final
themeMode ThemeMode?
Theme mode.
final
title String?
The title of the app.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<SwiftFlutterMaterial>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited