SwiftFlutterMaterial class
A widget that wraps MaterialApp or GetMaterialApp and automatically handles notification and deep link routing.
This widget checks if the app was launched from a notification or deep link and routes accordingly. All app configuration (routes, initialRoute, themes, etc.) should be provided in the MaterialApp or GetMaterialApp. Only routing logic is handled via onNotificationLaunch and onDeepLink.
Deep links take priority over notifications when both are present.
You can pass either:
- A MaterialApp via materialApp to auto-manage all MaterialApp properties
- A
GetMaterialAppvia getMaterialApp to auto-manage all GetMaterialApp properties
Example with MaterialApp:
SwiftFlutterMaterial(
materialApp: MaterialApp(
title: 'My App',
theme: ThemeData.light(),
initialRoute: '/home',
routes: {
'/home': (context) => HomeScreen(),
'/notification': (context) => NotificationScreen(),
'/product': (context) => ProductScreen(),
},
),
onNotificationLaunch: ({required isFromNotification, required payload}) {
if (isFromNotification) {
return SwiftRouting(
route: '/notification',
payload: payload,
);
}
return null; // Use initialRoute from MaterialApp
},
onDeepLink: ({required url, required route, required queryParams}) {
if (route == '/product') {
return SwiftRouting(
route: '/product',
payload: {'productId': queryParams['id']},
);
}
return null; // Skip navigation
},
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- SwiftFlutterMaterial
Constructors
- SwiftFlutterMaterial({Key? key, MaterialApp? materialApp, GetMaterialApp? getMaterialApp, NotificationRouteCallback? onNotificationLaunch, DeepLinkCallback? onDeepLink})
-
const
Properties
- getMaterialApp → GetMaterialApp?
-
Optional GetMaterialApp instance. All GetMaterialApp properties (getPages, initialRoute, themes, etc.)
should be configured in this GetMaterialApp instance.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- materialApp → MaterialApp?
-
Optional MaterialApp instance. All MaterialApp properties (routes, initialRoute, themes, etc.)
should be configured in this MaterialApp instance.
final
- onDeepLink → DeepLinkCallback?
-
Optional callback to determine route and payload based on deep link URL.
If provided, this callback will be called when the app is launched from a deep link
or when a deep link is received while the app is running.
Return a SwiftRouting object with route and payload, or null to skip navigation.
final
- onNotificationLaunch → NotificationRouteCallback?
-
Optional callback to determine route and payload based on notification launch.
This callback is used for both initial notification launches and notifications received while the app is running.
Return a SwiftRouting object with route and payload, or null to skip navigation.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
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