Nylo class

Constructors

Nylo({NyRouter? router, bool useNyRouteObserver = true})
Create a new Nylo instance.

Properties

appLifecycleStates → Map<AppLifecycleState, dynamic Function()>?
Get AppLifecycleState
no setter
authStorageKey ↔ String?
getter/setter pair
deepLinkStatus → Map<String, Object?>
How deep links are set up in this build, for metro live:run deeplink.
no setter
getAppLoader → Widget
Get appLoader
no setter
Get appLogo
no setter
getCache → NyCache?
Get the cache instance
no setter
hashCode → int
The hash code for this object.
no setterinherited
isFlutterLocalNotificationsInitialized ↔ bool
getter/setter pair
locale → String
Get the current locale
no setter
onDeepLinkAction ↔ dynamic Function(String route, dynamic data)?
getter/setter pair
onIncomingLinkAction ↔ Future<bool> Function(Uri uri)?
Callback invoked for each incoming external URI when useDeepLinks is enabled. Return true to let Nylo route automatically; return false to suppress automatic routing (e.g. to handle the URI manually).
getter/setter pair
router ↔ NyRouter?
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

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
addLiveCommands(Map<String, LiveCommand Function()> commands) → void
Register commands that run inside the app when called from Metro.
addLoader(Widget appLoader) → void
Add appLoader
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.
addSeeders(Map<String, Seeder Function()> seeders) → void
Register seeders that seed <name> in metro live runs inside the app.
addThemes<T extends ThemeColor>(List<BaseThemeConfig<T>> themes, {String? initialThemeId}) → void
Add themes to Nylo.
addToastNotifications(Map<String, dynamic> styles) → void
Add toast notification styles to the registry. Pass a map of style IDs to widget factory functions. Accepts both ToastStyleFactory (static) and ToastStyleDataFactory (data-aware) values.
broadcastEvents([bool broadcast = true]) → void
Set if you want to broadcast all events
configure({Widget? loader, List<BaseThemeConfig>? themes, String? initialThemeId, Map<String, dynamic>? toastNotifications, Map<Type, dynamic>? modelDecoders, Map<Type, dynamic>? controllers, Map<Type, dynamic>? apiDecoders, Map<Type, NyEvent>? events, String? authKey, dynamic syncKeys, bool useErrorStack = false, ErrorStackLogLevel? errorStackLevel, Widget errorStackWidget(FlutterErrorDetails)?, bool monitorAppUsage = false, bool showDateTimeInLogs = false, bool broadcastEvents = false, NyLogCallback? onLog, Map<String, LiveCommand Function()>? liveCommands, Map<String, Seeder Function()>? seeders, bool? useLive, 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.
getInitializationSettings() → InitializationSettings?
Get initialization settings
getInitialRoute() → String
Get the initial route.
getLiveCommands() → Map<String, LiveCommand Function()>
The commands registered with addLiveCommands.
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
getSeeders() → Map<String, Seeder Function()>
The seeders registered with addSeeders.
Sends uri through the deep link chain, as if the platform had delivered it, and reports what each step did.
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
Set the deep link action. e.g. nylo.onDeepLink((route, data) { print("Deep link route: $route"); print("Deep link data: $data"); });
Register a callback fired for every incoming external URI captured by useDeepLinks. Return true to let Nylo route automatically; return false to handle the URI yourself.
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
shouldUseLive() → bool
Whether Nylo Live should be installed when the app boots.
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
Enable platform deep-link capture (Android App Links, iOS Universal Links, custom URL schemes, web URLs).
useErrorStack({ErrorStackLogLevel level = ErrorStackLogLevel.verbose, Widget errorWidget(FlutterErrorDetails)?}) → void
Use ErrorStack level is the log level for ErrorStack errorWidget is a custom error widget
useLive([bool enabled = true]) → void
Enable or disable Nylo Live (metro live:* and live commands).
useLocalNotifications({DarwinInitializationSettings? iosSettings, AndroidInitializationSettings? androidSettings, LinuxInitializationSettings? linuxSettings, dynamic onDidReceiveLocalNotification(NotificationResponse notificationResponse)?, dynamic onDidReceiveBackgroundNotificationResponse(NotificationResponse notificationResponse)?}) → void
Use local notifications

Operators

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

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
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).