helpers/ny_helpers library

Classes

Auth
Authentication class for managing user sessions.
Backpack
Backpack class for storing data This class is not designed to store huge amounts of data.
ButtonAnimationStyle
ButtonAnimationStyle defines composable animation styles for buttons. Use factory constructors to create different animation effects.
ButtonSplashStyle
ButtonSplashStyle defines customizable splash effects for buttons. Use factory constructors to create different splash styles.
CurrencyInputMatcher
Currency input matcher
CurrencyMeta
Currency meta data
LoadingStyle
The LoadingStyle class is used to determine the type of loading widget
Model<T>
Nylo's Model class
NyAction
Nylo's NyAction class
NyAppUsage
Nylo's NyAppUsage class This class is used to monitor app usage.
NyCache
Cache helper
NyColor
Helper to find correct color from the context.
NyConnectivity
Connectivity helper for checking network status.
NyEnv
Base class for environment configuration.
NyEnvRegistry
Registry for the user's generated Env class.
NyLogEntry
Represents a single log entry with metadata.
NyLogger
Logger used for messages you want to print to the console.
NyScheduler
Nylo's Scheduler class This class is used to schedule tasks to run at a later time.
NySession
StateAction
StateAction class

Enums

ButtonAnimationType
The type of button animation
ButtonSplashType
The type of splash effect for buttons
LoadingStyleType
The LoadingStyleType enum is used to determine the type of loading widget
NyConnectivityState
Connectivity state enum for NyConnective widget.
SkeletonizerEffect
The effect to use for the skeletonizer loading style
UrlLaunchModeType
Launch mode for opening URLs.

Mixins

HasApiService<T extends NyApiService>
HasApiService mixin for classes that need access to an API service.

Extensions

ColorOpacityExt on Color
ConnectivityResultExtension on ConnectivityResult
Extension to convert ConnectivityResult to NyConnectivityState.
DarkModeExt on BuildContext
Check if the device is in Dark Mode
FormValidatorExtensionExt on List<FormValidator>
ListFormValidationResponseExtensionExt on FormValidationResponseBag
ListUpdateExtensionExt on List<T>
Extensions for List
NyAssetImageExt on AssetImage
Extensions for AssetImage
NyBoolExt on bool?
Extensions for bool
NyBoxScrollViewExt on BoxScrollView
Extensions for ListView
NyColumnExt on Column
Extensions for Column
NyContextExt on BuildContext
NyDateTimeExt on DateTime?
Extensions for DateTime
NyDoubleExt on double?
Extensions for double
NyImageExt on Image
Extensions for Image
NyIntExt on int?
Extensions for int
NyListExt on List?
Extensions for List
NyListGenericExt on List<T>
Extensions for List
NyListWidgetExt on List<Widget>
Extensions for List
NyMapEntryExt on Iterable<MapEntry<String, dynamic>>
NyMapExt on Map?
Extensions for Map
NyResponseExt on Response
Extensions for Response
NyRowExt on Row
Extensions for Row
NySingleChildRenderObjectWidgetExt on SingleChildRenderObjectWidget
Extensions for SingleChildRenderObjectWidget
NyStatefulExt on StatefulWidget
NyStatelessWidgetExt on StatelessWidget
Extensions for StatelessWidget
NyStorageKeyExt on StorageKey
NyStrExt on String?
Extensions for String
NyStringExt on String
Extensions for String
NyTextExt on Text
Extensions for Text
NyWidgetExt on Widget
Extensions for Widget
PaginateExt on List<T>
Extension on the List<T> class that adds a paginate method for easy pagination of list elements.
RouteViewExt on RouteView
StringExtensionExt on String
Extensions for String

Functions

api<T extends NyApiService>(dynamic request(T request), {Map<String, dynamic> headers = const {}, String? bearerToken, String? baseUrl, int? page, String? queryNamePage, String? queryNamePerPage, int? perPage, int retry = 0, Duration? retryDelay, bool retryIf(DioException dioException)?, bool? shouldSetAuthHeaders, dynamic onSuccess(Response response, dynamic data)?, dynamic onError(DioException dioException)?, Duration? cacheDuration, String? cacheKey, List<Type> events = const []}) Future
api helper Example:
authAuthenticate({dynamic data, String? session}) Future<void>
Authenticate a session.
authData({String? field, String? session}) → dynamic
Get auth data for a session.
authDeviceId() Future<String>
Get the device ID.
authIsAuthenticated({String? session}) Future<bool>
Check if a session is authenticated.
authKey([String? session]) String
Get the storage key for a session.
authLogout({String? session}) Future<void>
Logout from a session.
authLogoutAll({List<String> sessions = const []}) Future<void>
Logout from all sessions.
authSet(dynamic update(dynamic data), {String? session}) Future<void>
Update auth data for a session.
authSyncToBackpack({String? session}) Future<void>
Sync auth data to backpack for a session.
backpackDelete(String key) → void
Delete a value using a key.
backpackDeleteAll() → void
Delete all values from Backpack.
backpackNylo({String key = 'nylo'}) Nylo
Returns an instance of Nylo.
backpackRead<T>(String key, {dynamic defaultValue}) → T?
Read data from the Backpack with a key.
backpackSave(String key, dynamic value) → void
Save a value using a key and value.
cache() NyCache
Get the cache instance. Throws StateError if cache is not initialized.
canOpenUrl(String url) Future<bool>
Check if a URL can be opened.
clearBadgeNumber() Future<void>
Clear badge number
dataToModel<T>({required dynamic data, Map<Type, dynamic>? modelDecoders}) → T
Return an object from your modelDecoders using data.
dump(dynamic value, {String? tag, bool alwaysPrint = false}) → void
Dump a message to the console. Example:
event<T>({Map? data, bool? broadcast}) Future
Event helper for Nylo Example:
getAppTextTheme(TextStyle appThemeFont, TextTheme textTheme) TextTheme
Returns a text theme for a app font. Returns a TextTheme.
getAsset(String asset) String
Returns the full path for an asset in /assets directory. Usage e.g. getAsset('videos/welcome.mp4');
getEnv(String key, {dynamic defaultValue}) → dynamic
Returns a value from the generated env.g.dart file. The key must exist as a string value e.g. APP_NAME.
getImageAsset(String imageName, {String? path = '/images'}) String
Returns the full image path for a image in /assets/images/ directory. Provide the name of the image, using imageName parameter.
loadJson<T>(String fileName, {bool cache = true}) Future<T?>
Load a json file from the assets folder.
match<T>(dynamic value, Map<dynamic, T> values(), {T? defaultValue}) → T
Match a value from a Map of data. Returns defaultValue if no match is found, or throws if no default provided.
now() DateTime
Get the DateTime.now() value.
nyApi<T>({required dynamic request(T), Map<Type, dynamic> apiDecoders = const {}, Map<String, dynamic> headers = const {}, String? bearerToken, String? baseUrl, int? page, int? perPage, String queryParamPage = "page", String? queryParamPerPage, int retry = 0, Duration? retryDelay, bool retryIf(DioException dioException)?, bool? shouldSetAuthHeaders, dynamic onSuccess(Response response, dynamic data)?, dynamic onError(DioException dioException)?, Duration? cacheDuration, String? cacheKey, List<Type> events = const []}) Future
API helper
nyColorStyle<T>(BuildContext context, {String? themeId}) → T
Helper to get the color styles Find a color style from the Nylo's appThemes.
nyEvent<T>({Map? params, Map<Type, NyEvent> events = const {}, bool? broadcast}) Future<void>
Event helper
nyHexColor(String hexColor) Color
Hex Color
openUrl(String url, {UrlLaunchModeType mode = UrlLaunchModeType.externalApplication, bool webOnly = false, Map<String, String>? headers}) Future<bool>
Opens a URL in the browser.
printAlert(dynamic message, {Map<String, dynamic>? context, bool alwaysPrint = false}) → void
Print a message to the console. Log level: Alert Use context to interpolate values into the message, e.g. 'User {id}' with {'id': '123'}.
printDebug(dynamic message, {Map<String, dynamic>? context, bool alwaysPrint = false}) → void
Print a message to the console. Log level: Debug Use context to interpolate values into the message, e.g. 'User {id}' with {'id': '123'}.
printEmergency(dynamic message, {Map<String, dynamic>? context, bool alwaysPrint = false}) → void
Print a message to the console. Log level: Emergency (highest severity) Use context to interpolate values into the message, e.g. 'User {id}' with {'id': '123'}.
printError(dynamic message, {Map<String, dynamic>? context, bool alwaysPrint = false}) → void
Print a message to the console. Log level: Error Use context to interpolate values into the message, e.g. 'User {id}' with {'id': '123'}.
printInfo(dynamic message, {Map<String, dynamic>? context, bool alwaysPrint = false}) → void
Print a message to the console. Log level: Info Use context to interpolate values into the message, e.g. 'User {id}' with {'id': '123'}.
printJson(dynamic message, {bool alwaysPrint = false}) → void
Print a message to the console as JSON.
printSuccess(dynamic message, {Map<String, dynamic>? context, bool alwaysPrint = false}) → void
Print a message to the console. Log level: Success Use context to interpolate values into the message, e.g. 'User {id}' with {'id': '123'}.
printVerbose(dynamic message, {Map<String, dynamic>? context, bool alwaysPrint = false}) → void
Print a message to the console. Log level: Verbose Use context to interpolate values into the message, e.g. 'User {id}' with {'id': '123'}.
printWarning(dynamic message, {Map<String, dynamic>? context, bool alwaysPrint = false}) → void
Print a message to the console. Log level: Warning Use context to interpolate values into the message, e.g. 'User {id}' with {'id': '123'}.
session(String name, [Map<String, dynamic> items = const {}]) NySession
Create a new session
setBadgeNumber(int number) Future<void>
Set badge number
showNextLog() → void
If you call showNextLog it will force the app to display the next 'NyLogger' log even if your app's APP_DEBUG is set to false.
sleep(int seconds, [int microseconds = 0]) Future<void>
Delays execution for the specified duration.
stateAction(String action, {required dynamic state, dynamic data}) → void
Send a state action to a NyState or NyPage in your application. Provide the state and the action you want to send.
trans(String key, {Map<String, String>? arguments}) String
Returns the translation value from the key you provide. E.g. trans("hello") lang translation will be returned for the app locale.
updateState<T>(dynamic name, {dynamic data, dynamic setValue(T? currentValue)?}) → void
Update's the state of a NyState Widget in your application. Provide the name of the state and then return a value in the callback setValue.

Typedefs

EnvContainsKey = bool Function(String key)
Type definition for the env containsKey function.
EnvGetter = dynamic Function(String key, {dynamic defaultValue})
Type definition for the env getter function.
FormValidationResponseBag = List<FormValidationResult>
NyLogCallback = void Function(NyLogEntry entry)
Callback type for log listeners.
StorageKey = String
StorageKey typedef