helpers/src/helper library

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:
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
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'}.
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.
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.