Nylo class
Constructors
Nylo ({NyRouter ? router , bool useNyRouteObserver = true })
Create a new Nylo instance.
Methods
addApiDecoders (Map <Type , dynamic > apiDecoders )
→ void
Set API decoders
addAuthKey (String key )
→ void
Add an auth key to the Nylo instance
addControllers (Map <Type , dynamic > controllers )
→ void
Add Controllers to your Nylo project.
addEventBus ({int maxHistoryLength = 10 , bool allowLogging = false })
→ void
Add an EventBus to your Nylo project.
addEvents (Map <Type , NyEvent > events )
→ void
Add events to Nylo
addFormCasts (Map <String , dynamic > formTypes )
→ void
Add form casts to Nylo
addLoader (Widget appLoader )
→ void
Add appLoader
addLogo (Widget appLogo )
→ void
Add appLogo
addModelDecoders (Map <Type , dynamic > modelDecoders )
→ void
Add modelDecoders to Nylo
addNavigatorObserver (NavigatorObserver observer )
→ void
Add a navigator observer.
addRouter (NyRouter router )
→ void
Allows you to add additional Router's to your project.
addThemes <T extends ThemeColor > (List <BaseThemeConfig <T > > themes , {String ? initialThemeId })
→ void
Add themes to Nylo.
addToastNotifications (Map <String , ToastStyleFactory > styles )
→ void
Add toast notification styles to the registry.
Pass a map of style IDs to widget factory functions.
broadcastEvents ([bool broadcast = true ])
→ void
Set if you want to broadcast all events
configure ({Widget ? loader , Widget ? logo , List <BaseThemeConfig > ? themes , String ? initialThemeId , Map <String , ToastStyleFactory > ? toastNotifications , Map <Type , dynamic > ? modelDecoders , Map <Type , dynamic > ? controllers , Map <Type , dynamic > ? apiDecoders , Map <Type , NyEvent > ? events , Map <String , dynamic > ? formCasts , String ? authKey , dynamic syncKeys , bool useErrorStack = false , ErrorStackLogLevel? errorStackLevel , Widget errorStackWidget (FlutterErrorDetails )?, bool monitorAppUsage = false , bool showDateTimeInLogs = false , bool broadcastEvents = false , NyLogCallback ? onLog , NyLocalizationConfig ? localization })
→ Future <void >
Configure Nylo with all settings in a single call.
getApiDecoders ()
→ Map <Type , NyApiService Function() >
Get API decoders
getAuthKey ()
→ String ?
Get the auth key
getController (dynamic controller )
→ dynamic
Find a controller
getEvent (Type event )
→ NyEvent ?
Return an event.
getEvents ()
→ Map <Type , NyEvent >
Return all the registered events.
getFormCasts ()
→ Map <String , dynamic >
Get form types from Nylo
getInitializationSettings ()
→ InitializationSettings?
Get initialization settings
getInitialRoute ()
→ String
Get the initial route.
getLocalNotifications ()
→ FlutterLocalNotificationsPlugin?
Get local notifications
getModelDecoders ()
→ Map <Type , dynamic >
Return all the registered events.
getNavigatorObservers ()
→ List <NavigatorObserver >
Return all the registered navigator observers.
getOnDidReceiveBackgroundNotificationResponse ()
→ dynamic Function(NotificationResponse notificationResponse ) ?
Get on did receive background notification response
getOnDidReceiveNotificationResponse ()
→ dynamic Function(NotificationResponse notificationResponse ) ?
Get on did receive notification response
initializeLocalNotifications ()
→ Future <bool ? > ?
Initialize local notifications
initRoutes ({String ? initialRoute })
→ void
Initialize routes
monitorAppUsage ()
→ void
Set if the app should monitor app usage like:
noSuchMethod (Invocation invocation )
→ dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onDeepLink (dynamic callback (String route , dynamic data ) )
→ void
Set the deep link action.
e.g. nylo.onDeepLink((route, data) {
print("Deep link route: $route");
print("Deep link data: $data");
});
removeNavigatorObserver (NavigatorObserver observer )
→ void
Remove a navigator observer.
setInitialRoute (String routeName )
→ void
Set the initial route from a routeName.
setLocalNotifications (FlutterLocalNotificationsPlugin localNotifications )
→ void
Set local notifications
shouldBroadcastEvents ()
→ bool
Check if the app should broadcast events
shouldMonitorAppUsage ()
→ bool
Check if the app should monitor app usage
shouldShowDateTimeInLogs ()
→ bool
Check if the app should show date time in logs
showDateTimeInLogs ()
→ void
Show date time in logs
syncKeys (dynamic keys )
→ Future <void >
Sync keys to the backpack instance.
syncToBackpack (String key , dynamic data )
→ void
Sync a model to the backpack instance.
toString ()
→ String
A string representation of this object.
inherited
useDevPanelLogging ({void onLog (String message , String level , {Map <String , dynamic > ? metadata , String ? stackTrace , String ? tag })?, void onRouteChange (String action , String routeName , {Object ? arguments , String ? previousRoute })? })
→ void
Enable external dev panel logging integration.
useErrorStack ({ErrorStackLogLevel level = ErrorStackLogLevel.verbose , Widget errorWidget (FlutterErrorDetails errorDetails )? })
→ void
Use ErrorStack
level is the log level for ErrorStack
errorWidget is a custom error widget
useLocalNotifications ({DarwinInitializationSettings? iosSettings , AndroidInitializationSettings? androidSettings , LinuxInitializationSettings? linuxSettings , dynamic onDidReceiveLocalNotification (NotificationResponse details )?, dynamic onDidReceiveBackgroundNotificationResponse (NotificationResponse details )? })
→ void
Use local notifications
Static Properties
instance
→ Nylo
Get Nylo from Backpack.
Throws StateError if Nylo has not been initialized via Nylo.init() .
no setter
isTestMode
↔ bool
Flag to indicate if the app is running in test mode.
When true, certain operations like timezone configuration are skipped,
and in-memory cache is used instead of file-based cache.
getter/setter pair
services
→ List <Runnable >
Get the registered services
no setter
Static Methods
addRouteHistory (Route route )
→ void
Add a route to the route history.
apiDecoder <T > ()
→ NyApiService
Get a API Decoder
apiDecoders ()
→ Map <Type , NyApiService >
Get api decoders
appFirstLaunchDate ()
→ Future <DateTime ? >
Days since first launch
appLaunchCount ()
→ Future <int ? >
App launch count - this method will return the app launch count.
appLaunched ()
→ Future <void >
App launched - this method will increment the app launch count.
appLoader ()
→ Widget
Get appLoader
appLogo ()
→ Widget
Get appLogo
appTotalDaysSinceFirstLaunch ()
→ Future <int >
Days since first launch
authKey ()
→ String
Get the auth user
canMonitorAppUsage ()
→ void
Check if the app can monitor data
containsRoute (String route )
→ bool
Check if the router contains specific route
containsRoutes (List <String > routes )
→ bool
Check if the router contains specific routes
events ()
→ Map <Type , NyEvent >
Get events
getCurrentRoute ()
→ Route ?
Get current route
getCurrentRouteArguments ()
→ dynamic
Get current route arguments
getCurrentRouteName ()
→ String ?
Get current route name
getCurrentTheme ()
→ BaseThemeConfig ?
Get the current theme.
getLocale ()
→ String
Get the current locale
getPreviousRoute ()
→ Route ?
Get previous route
getPreviousRouteArguments ()
→ dynamic
Get previous route arguments
getPreviousRouteName ()
→ String ?
Get previous route name
getRouteHistory ()
→ List
Get the route history.
getService <T extends Runnable > ()
→ T?
Get a service by type.
getThemeData ()
→ ThemeData ?
Get the current theme data.
getThemes ()
→ List <BaseThemeConfig >
Get all registered themes.
hasService <T extends Runnable > ()
→ bool
Check if a service is registered.
init ({required EnvGetter env , BootConfig ? setup , Map <AppLifecycleState , dynamic Function() > ? appLifecycle , List <FutureOr <Runnable > > ? services })
→ Future <Nylo >
Initialize Nylo
isCurrentRoute (String routeName )
→ bool
Check if the current route is routeName
isDebuggingEnabled ()
→ bool
Check if the app is in debug mode
isEnvDeveloping ()
→ bool
Check if the app is in developing
isEnvProduction ()
→ bool
Check if the app is in production
isInitialized ()
→ bool
Check if Nylo is initialized
localNotifications (dynamic callback (FlutterLocalNotificationsPlugin localNotifications ) )
→ Future <void >
Get the local notifications plugin
notificationTapBackground (NotificationResponse notificationResponse )
→ void
onDidReceiveNotificationResponse (NotificationResponse notificationResponse )
→ void
On did receive notification response
removeLastRouteHistory ()
→ void
Remove a route from the route history.
removeRouteHistory (Route route )
→ void
Remove a route from the route history.
scheduleOnce (String name , dynamic callback () )
→ Future <void >
Schedule something to happen once
scheduleOnceAfterDate (String name , dynamic callback (), {required DateTime date })
→ Future <void >
Schedule something to happen once after a date
scheduleOnceDaily (String name , dynamic callback (), {DateTime ? endAt })
→ Future <void >
Schedule something to happen once daily
updateRouteStack (List <String > routes , {bool replace = true , bool deepLink = false , Map <String , dynamic > ? dataForRoute })
→ void
Update the stack on the router.
routes is a list of routes to navigate to. E.g. HomePage.path, SettingPage.path
replace is a boolean that determines if the current route should be replaced.
dataForRoute is a map of data to pass to the route. E.g. {HomePage.path: {"name": "John Doe"}}
Example:
user <T > ()
→ T?
Get the auth user
wipeStorage ({List <String > ? excludeKeys , bool andFromBackpack = true })
→ Future <void >
Wipe all storage data.
excludeKeys - Optional list of keys to exclude from deletion.
andFromBackpack - Whether to also remove data from Backpack (default: true).