### Metro CLI Usage Examples Source: https://nylo.dev/docs/7.x/installation Common examples for creating pages, models, and API services using the Metro CLI. ```bash # Create a new page metro make:page settings_page # Create a model metro make:model User # Create an API service metro make:api_service user_api_service ``` -------------------------------- ### Toast Assertions Setup Source: https://nylo.dev/docs/7.x/testing Setup required for toast assertions: call NyToastRecorder.setup() in test setUp. ```dart setUp(() { NyToastRecorder.setup(); }); ``` -------------------------------- ### NyPageTestMixin example Source: https://nylo.dev/docs/7.x/testing Mixin providing common page testing utilities. This example verifies init was called and loading state is shown. ```dart class HomePageTest with NyPageTestMixin { void runTests(WidgetTester tester) async { // Verify init was called and loading completed await verifyInitCalled(tester, HomePage(), timeout: Duration(seconds: 5)); // Verify loading state is shown during init await verifyLoadingState(tester, HomePage()); } } ``` -------------------------------- ### English language file (lang/en.json) Source: https://nylo.dev/docs/7.x/localization Example English JSON file with welcome, settings, and navigation keys. ```json { "welcome": "Welcome", "settings": "Settings", "navigation": { "home": "Home", "profile": "Profile" } } ``` -------------------------------- ### Arguments example lang/en.json Source: https://nylo.dev/docs/7.x/localization JSON file with keys containing placeholders for arguments. ```json { "greeting": "Hello {{name}}", "items_count": "You have {{count}} items" } ``` -------------------------------- ### nyTest basic example Source: https://nylo.dev/docs/7.x/testing Primary function for writing tests. This example saves and reads from storage using backpackSave and backpackRead. ```dart nyTest('can save and read from storage', () async { backpackSave("name", "Anthony"); expect(backpackRead("name"), equals("Anthony")); }); ``` -------------------------------- ### nylo clean: Clean Flutter project and optionally iOS/Android Source: https://nylo.dev/docs/7.x/installation Runs `flutter clean` then `flutter pub get`. Add `--ios` to also remove iOS pods and run `pod install --repo-update`, `--android` to run `gradlew clean`, or `--all` for both. Platforms without the corresponding folder are skipped with a warning; `pod install` only runs on macOS. ```bash # flutter clean, then flutter pub get nylo clean # Also remove ios/Pods, ios/.symlinks and ios/Podfile.lock, then run pod install --repo-update nylo clean --ios # Also run gradlew clean in android/ nylo clean --android # Both of the above nylo clean --all ``` -------------------------------- ### Example language file lang/en.json Source: https://nylo.dev/docs/7.x/localization Shows a basic JSON language file with a simple key and a key with a placeholder. ```json { "welcome": "Welcome", "greeting": "Hello {{name}}" } ``` -------------------------------- ### nylo test options examples Source: https://nylo.dev/docs/7.x/testing Examples of using --filter, --coverage, --path, and --no-format options. --filter runs only tests matching a pattern, --coverage collects coverage, --path runs tests in another folder (default: test), --no-format skips formatting. ```bash # Only tests with "login" in their name, with coverage nylo test --filter "login" --coverage # Integration tests, without formatting nylo test --path integration_test --no-format ``` -------------------------------- ### Spanish language file (lang/es.json) Source: https://nylo.dev/docs/7.x/localization Example Spanish JSON file with translations for welcome, settings, and navigation keys. ```json { "welcome": "Bienvenido", "settings": "Configuración", "navigation": { "home": "Inicio", "profile": "Perfil" } } ``` -------------------------------- ### Expected output of flutter --version Source: https://nylo.dev/docs/7.x/requirements Example output from running flutter --version, showing the expected Flutter and Dart SDK versions. ```text Flutter 3.38.4 • channel stable Dart SDK version: 3.10.7 ``` -------------------------------- ### Create a new Nylo project Source: https://nylo.dev/docs/7.x/installation Clones the Nylo template, renames it to your app, and installs dependencies. ```bash nylo new my_app ``` -------------------------------- ### nylo --version: Show installed CLI version Source: https://nylo.dev/docs/7.x/installation Displays the currently installed version of the Nylo CLI. ```bash nylo --version ``` -------------------------------- ### Full Test File Source: https://nylo.dev/docs/7.x/testing Complete example of a test file using NyTest.init, nyGroup, nyTest, NyFactory, NyMockApi, and authentication assertions. ```dart import 'package:flutter_test/flutter_test.dart'; import 'package:nylo_framework/nylo_framework.dart'; void main() { NyTest.init(); nyGroup('User Authentication', () { nyTest('can authenticate a user', () async { NyFactory.define((faker) => User( name: faker.name(), email: faker.email(), )); User user = NyFactory.make(); NyTest.actingAs(user); expectAuthenticated(); }); nyTest('guest has no access', () async { expectGuest(); }); }); nyGroup('API Integration', () { nyTest('can fetch users', () async { NyMockApi.setRecordCalls(true); NyMockApi.respond('/api/users', { 'users': [ {'id': 1, 'name': 'Anthony'}, {'id': 2, 'name': 'Jane'}, ] }); // ... trigger API call ... }); }); } ``` -------------------------------- ### Nested keys example lang/en.json Source: https://nylo.dev/docs/7.x/localization JSON file with nested navigation keys for demonstrating dot notation access. ```json { "navigation": { "home": "Home", "profile": "Profile" } } ``` -------------------------------- ### English language file lang/en.json Source: https://nylo.dev/docs/7.x/localization Example English JSON file with nested navigation keys. ```json { "welcome": "Welcome", "settings": "Settings", "navigation": { "home": "Home", "profile": "Profile" } } ``` -------------------------------- ### Nested keys JSON example Source: https://nylo.dev/docs/7.x/localization JSON file with nested navigation keys to demonstrate dot notation access. ```json { "navigation": { "home": "Home", "profile": "Profile" } } ``` -------------------------------- ### nyWidgetTest basic example Source: https://nylo.dev/docs/7.x/testing For testing Flutter widgets with a WidgetTester. This example pumps a MaterialApp with an ElevatedButton and checks its text. ```dart nyWidgetTest('renders a button', (WidgetTester tester) async { await tester.pumpWidget(MaterialApp( home: Scaffold( body: ElevatedButton( onPressed: () {}, child: Text("Tap me"), ), ), )); expect(find.text("Tap me"), findsOneWidget); }); ``` -------------------------------- ### Spanish language file lang/es.json Source: https://nylo.dev/docs/7.x/localization Example Spanish JSON file with nested navigation keys. ```json { "welcome": "Bienvenido", "settings": "Configuración", "navigation": { "home": "Inicio", "profile": "Perfil" } } ``` -------------------------------- ### Language directory structure Source: https://nylo.dev/docs/7.x/localization Shows the expected layout of the lang/ directory with example JSON files for English, Spanish, and French. ```text lang/ ├── en.json # English ├── es.json # Spanish ├── fr.json # French └── ... ``` -------------------------------- ### Toast assertions with NyToastRecorder.setup() Source: https://nylo.dev/docs/7.x/testing Assert on toast notifications recorded during a test. Requires NyToastRecorder.setup() in test setUp. Use expectToastShown and expectNoToastShown to verify toast display. ```dart setUp(() { NyToastRecorder.setup(); }); nyWidgetTest('shows success toast', (tester) async { await tester.pumpNyWidget(MyPage()); // ... trigger action that shows a toast ... expectToastShown(id: 'success'); expectToastShown(id: 'danger', description: 'Something went wrong'); expectNoToastShown(id: 'info'); }); ``` -------------------------------- ### Check Flutter version with flutter --version Source: https://nylo.dev/docs/7.x/requirements Run this command to verify the installed Flutter version. The output should show Flutter 3.38.4 or higher and Dart SDK 3.10.7 or higher. ```bash flutter --version ``` -------------------------------- ### Check Flutter version with flutter --version Source: https://nylo.dev/docs/7.x/requirements Check the installed Flutter version to verify it meets the minimum requirement of 3.38.4 or higher. ```bash flutter --version ``` -------------------------------- ### Install Nylo CLI globally Source: https://nylo.dev/docs/7.x/installation Activates the nylo command on your system using the Dart package manager. ```bash dart pub global activate nylo_installer ``` -------------------------------- ### Expected output of flutter --version Source: https://nylo.dev/docs/7.x/requirements Expected output when Flutter 3.38.4 is installed on the stable channel. ```text Flutter 3.38.4 • channel stable Dart SDK version: 3.10.7 ``` -------------------------------- ### Show toast alerts from a NyController Source: https://nylo.dev/docs/7.x/alerts Example of using toast convenience methods inside a controller class. Shows success and danger toasts in a try-catch block. ```dart class ProfileController extends NyController { void updateProfile() async { try { await api.updateProfile(); showToastSuccess(description: "Profile updated"); } catch (e) { showToastDanger(description: "Failed to update profile"); } } } ``` -------------------------------- ### tester.navigateBack - Pop route and settle Source: https://nylo.dev/docs/7.x/testing Pops the current route and settles. Example shows navigating to a page, then back. ```dart await tester.visit(DashboardPage.path); await tester.tapText('Profile'); tester.assertNavigatedTo(ProfilePage.path); await tester.navigateBack(); tester.assertOnRoute(DashboardPage.path); ``` -------------------------------- ### NyMockChannels Source: https://nylo.dev/docs/7.x/testing NyMockChannels automatically mocks common platform channels so tests don't crash. It provides setup, path overrides, and secure storage mocking. ```APIDOC ## NyMockChannels ### Description NyMockChannels automatically mocks common platform channels so tests don't crash. It can be set up automatically via `NyTest.init()` or manually via `NyMockChannels.setup()`. ### Usage ```dart void main() { NyTest.init(); // Automatically sets up mock channels // Or set up manually NyMockChannels.setup(); } ``` ### Mocked Channels - **path_provider** -- documents, temporary, application support, library, and cache directories - **flutter_secure_storage** -- in-memory secure storage - **flutter_timezone** -- timezone data - **flutter_local_notifications** -- notification channel - **sqflite** -- database operations ### Methods #### setup() - **Return Type**: void - **Description**: Sets up mock channels manually. #### overridePathProvider({documentsPath, temporaryPath}) - **Parameters**: `documentsPath` (String, optional), `temporaryPath` (String, optional) - **Return Type**: void - **Description**: Overrides the paths returned by the path_provider mock. #### setSecureStorageValue(key, value) - **Parameters**: `key` (String), `value` (String) - **Return Type**: void - **Description**: Sets a value in the mocked secure storage. #### getSecureStorage() - **Return Type**: Map - **Description**: Returns the current contents of the mocked secure storage. #### clearSecureStorage() - **Return Type**: void - **Description**: Clears all values from the mocked secure storage. ``` -------------------------------- ### Run Flutter Doctor Source: https://nylo.dev/docs/7.x/requirements Verifies that the development environment is properly configured, including the Flutter SDK installation and the Android toolchain for Android development. ```bash flutter doctor -v ``` -------------------------------- ### Using NyLocaleHelper methods Source: https://nylo.dev/docs/7.x/localization Shows how to use NyLocaleHelper to get the current locale, language and country codes, check locale matches, detect RTL languages, get text direction, and create a Locale from strings. The comments indicate expected return values for example inputs. ```dart // Get the current system locale Locale locale = NyLocaleHelper.getCurrentLocale(context: context); // Get language and country codes String langCode = NyLocaleHelper.getLanguageCode(context: context); // 'en' String? countryCode = NyLocaleHelper.getCountryCode(context: context); // 'US' or null // Check if current locale matches bool isEnglish = NyLocaleHelper.matchesLocale(context, 'en'); bool isUsEnglish = NyLocaleHelper.matchesLocale(context, 'en', 'US'); // RTL detection bool isRtl = NyLocaleHelper.isRtlLanguage('ar'); // true bool currentIsRtl = NyLocaleHelper.isCurrentLocaleRtl(context: context); // Get text direction TextDirection direction = NyLocaleHelper.getTextDirection('ar'); // TextDirection.rtl TextDirection currentDir = NyLocaleHelper.getCurrentTextDirection(context: context); // Create a Locale from strings Locale newLocale = NyLocaleHelper.toLocale('en', 'US'); ``` -------------------------------- ### NyMockChannels: Secure Storage Operations Source: https://nylo.dev/docs/7.x/testing Set, retrieve, and clear secure storage values in tests using NyMockChannels. The example shows setting a token, getting the storage map, and clearing it. ```dart NyMockChannels.setSecureStorageValue("token", "test_abc123"); Map storage = NyMockChannels.getSecureStorage(); NyMockChannels.clearSecureStorage(); ``` -------------------------------- ### Add custom constructor for icons folder to LocalAsset Source: https://nylo.dev/docs/7.x/assets Extend LocalAsset with a custom constructor for the icons subdirectory. The example adds LocalAsset.icons and shows usage with width and height parameters. ```dart // /resources/widgets/local_asset_widget.dart class LocalAsset extends StatelessWidget { // images const LocalAsset.image(String assetName, {super.key, this.width, this.height, this.fit, this.opacity, this.borderRadius}) : assetName = "images/$assetName"; // icons <- new constructor for icons folder const LocalAsset.icons(String assetName, {super.key, this.width, this.height, this.fit, this.opacity, this.borderRadius}) : assetName = "images/icons/$assetName"; } // Usage examples LocalAsset.icons("icon_name.png", width: 32, height: 32) LocalAsset.image("logo.png", width: 100, height: 100) ``` -------------------------------- ### Initialize NyMockChannels Source: https://nylo.dev/docs/7.x/testing Shows how to set up mock platform channels automatically with NyTest.init() or manually with NyMockChannels.setup(). ```dart void main() { NyTest.init(); // Automatically sets up mock channels // Or set up manually NyMockChannels.setup(); } ``` -------------------------------- ### nylo ios:pod-refresh: Refresh iOS pods Source: https://nylo.dev/docs/7.x/installation Deletes `ios/Pods`, `ios/.symlinks` and `ios/Podfile.lock`, then runs `pod install --repo-update` in the `ios/` folder. Run from the project root on macOS. Unlike `nylo clean --ios`, it does not run `flutter clean` or `flutter pub get`. ```bash nylo ios:pod-refresh ``` -------------------------------- ### Show toast alerts from a NyState page Source: https://nylo.dev/docs/7.x/alerts Example of using toast convenience methods inside a page state class. Shows success, warning, info, danger, oops, sorry, and custom toasts with optional parameters like description, duration, and data. ```dart class _MyPageState extends NyState { void onSave() { // Success — description is optional showToastSuccess(description: "Saved!"); // With custom title showToastSuccess(title: "Done", description: "Your profile was updated."); // Warning with custom duration showToastWarning(description: "Check your input", duration: Duration(seconds: 4)); // Info — no description required showToastInfo(); // Danger with a data payload forwarded to data-aware styles showToastDanger(description: "Something went wrong", data: {"code": "ERR_500"}); // Oops (uses danger style) showToastOops(description: "That didn't work"); // Sorry (uses danger style) showToastSorry(description: "We couldn't process your request"); // Custom style by ID showToastCustom(id: "custom", description: "Custom alert!"); } } ``` -------------------------------- ### Toast Assertions Example Source: https://nylo.dev/docs/7.x/testing Example test that triggers a toast and asserts on it using expectToastShown and expectNoToastShown. ```dart nyWidgetTest('shows success toast', (tester) async { await tester.pumpNyWidget(MyPage()); // ... trigger action that shows a toast ... expectToastShown(id: 'success'); expectToastShown(id: 'danger', description: 'Something went wrong'); expectNoToastShown(id: 'info'); }); ``` -------------------------------- ### Get app first launch date Source: https://nylo.dev/docs/7.x/app-usage Use Nylo.appFirstLaunchDate() to get the date the app was first launched. ```dart DateTime? firstLaunchDate = await Nylo.appFirstLaunchDate(); print("App was first launched on $firstLaunchDate"); ``` -------------------------------- ### nylo metro: Run Metro without the alias Source: https://nylo.dev/docs/7.x/installation Passes everything after `nylo metro` to Metro (`dart run nylo_framework:main`). Use before running `nylo init` or on Windows where the alias cannot be added. Examples show creating a page and a model. ```bash nylo metro make:page settings_page ``` ```bash nylo metro make:model User ``` -------------------------------- ### Initialize NyTest and write a basic test Source: https://nylo.dev/docs/7.x/testing Sets up the test environment with NyTest.init() and defines a simple test using nyTest. Automatic state reset is enabled by default when autoReset is true. ```dart import 'package:flutter_test/flutter_test.dart'; import 'package:nylo_framework/nylo_framework.dart'; void main() { NyTest.init(); nyTest('my first test', () async { expect(1 + 1, equals(2)); }); } ``` -------------------------------- ### nyGroup example Source: https://nylo.dev/docs/7.x/testing Group related tests together. This example shows authentication tests using NyTest.actingAs and expectAuthenticated/expectGuest. ```dart nyGroup('Authentication', () { nyTest('can login', () async { NyTest.actingAs(User(name: "Anthony")); expectAuthenticated(); }); nyTest('can logout', () async { NyTest.actingAs(User(name: "Anthony")); NyTest.logout(); expectGuest(); }); }); ``` -------------------------------- ### Configure test environment with NyWidgetTest.configure Source: https://nylo.dev/docs/7.x/testing Call in setUpAll to disable Google Fonts fetching and optionally set a custom theme. Reset with NyWidgetTest.reset(). ```dart nySetUpAll(() async { NyWidgetTest.configure(testTheme: ThemeData.light()); await setupApplication(providers); }); ``` -------------------------------- ### Using a custom toast style Source: https://nylo.dev/docs/7.x/alerts Shows how to display a toast using the 'promo' style registered earlier. ```dart showToastNotification(context, id: "promo", description: "50% off today!"); ``` -------------------------------- ### View Metro CLI menu Source: https://nylo.dev/docs/7.x Displays the Metro CLI help menu and list of available commands. ```output $ metro Metro - Nylo's Companion to Build Flutter apps by Anthony Gordon Usage: command [options] [arguments] Options -h All commands: [Widget Commands] make:page make:stateful_widget make:stateless_widget make:state_managed_widget make:navigation_hub make:journey_widget make:bottom_sheet_modal make:button make:form [Helper Commands] make:model make:provider make:api_service make:controller make:event make:route_guard make:config make:interceptor make:command make:env ``` -------------------------------- ### Get total days since first launch Source: https://nylo.dev/docs/7.x/app-usage Use Nylo.appTotalDaysSinceFirstLaunch() to get the total number of days since the app was first launched. ```dart int totalDaysSinceFirstLaunch = await Nylo.appTotalDaysSinceFirstLaunch(); print("It's been $totalDaysSinceFirstLaunch days since the app was first launched"); ``` -------------------------------- ### Use asset helper functions Source: https://nylo.dev/docs/7.x/assets Shows how to use getAsset and getImageAsset without including the 'assets/' prefix, as it is prepended automatically. ```dart // These are equivalent: getAsset("videos/intro.mp4") // Returns: "assets/videos/intro.mp4" getImageAsset("logo.png") // Returns: "assets/images/logo.png" ``` -------------------------------- ### Time boundaries with NyTime.travelToStartOfDay and similar Source: https://nylo.dev/docs/7.x/testing Travel to specific time boundaries like start of day, end of day, start of month, etc. ```dart NyTime.travelToStartOfDay(); // 00:00:00.000 NyTime.travelToEndOfDay(); // 23:59:59.999 NyTime.travelToStartOfMonth(); // 1st of current month NyTime.travelToEndOfMonth(); // Last day of current month NyTime.travelToStartOfYear(); // Jan 1st NyTime.travelToEndOfYear(); // Dec 31st ``` -------------------------------- ### Get app launch count Source: https://nylo.dev/docs/7.x/app-usage Use Nylo.appLaunchCount() to get the number of times the app has been launched. App launches are counted each time the app is opened from a closed state. ```dart int? launchCount = await Nylo.appLaunchCount(); print('App has been launched $launchCount times'); ``` -------------------------------- ### NyLocaleHelper.getTextDirection(languageCode) Source: https://nylo.dev/docs/7.x/localization Gets the TextDirection for a language. ```APIDOC ## getTextDirection(languageCode) ### Description Gets the TextDirection for a language. ### Method getTextDirection ### Parameters - **languageCode** (String) - Required - The language code. ### Returns - **TextDirection** - The TextDirection for the language. ### Example ```dart TextDirection direction = NyLocaleHelper.getTextDirection('ar'); ``` ``` -------------------------------- ### NyLocalization.instance.locale Source: https://nylo.dev/docs/7.x/localization Gets the current Locale object. ```APIDOC ## locale ### Description Gets the current Locale object. ### Property locale ### Returns - **Locale** - The current Locale object. ### Example ```dart Locale currentLocale = NyLocalization.instance.locale; ``` ``` -------------------------------- ### NyLocaleHelper.getCurrentTextDirection({context}) Source: https://nylo.dev/docs/7.x/localization Gets the TextDirection for the current locale. ```APIDOC ## getCurrentTextDirection({context}) ### Description Gets the TextDirection for the current locale. ### Method getCurrentTextDirection ### Parameters - **context** (BuildContext) - Optional - The build context. ### Returns - **TextDirection** - The TextDirection for the current locale. ### Example ```dart TextDirection currentDir = NyLocaleHelper.getCurrentTextDirection(context: context); ``` ``` -------------------------------- ### NyLocaleHelper.getCountryCode({context}) Source: https://nylo.dev/docs/7.x/localization Gets the current country code. ```APIDOC ## getCountryCode({context}) ### Description Gets the current country code. ### Method getCountryCode ### Parameters - **context** (BuildContext) - Optional - The build context. ### Returns - **String?** - The current country code, or null if not available. ### Example ```dart String? countryCode = NyLocaleHelper.getCountryCode(context: context); ``` ``` -------------------------------- ### Initialize NyTest and write a test Source: https://nylo.dev/docs/7.x/testing Call NyTest.init() in main() to set up the test environment. Enables automatic state reset between tests when autoReset: true (the default). ```dart import 'package:flutter_test/flutter_test.dart'; import 'package:nylo_framework/nylo_framework.dart'; void main() { NyTest.init(); nyTest('my first test', () async { expect(1 + 1, equals(2)); }); } ``` -------------------------------- ### NyLocaleHelper.getLanguageCode({context}) Source: https://nylo.dev/docs/7.x/localization Gets the current language code. ```APIDOC ## getLanguageCode({context}) ### Description Gets the current language code. ### Method getLanguageCode ### Parameters - **context** (BuildContext) - Optional - The build context. ### Returns - **String** - The current language code. ### Example ```dart String langCode = NyLocaleHelper.getLanguageCode(context: context); ``` ``` -------------------------------- ### Use getAsset with video player and rootBundle Source: https://nylo.dev/docs/7.x/assets Shows how to use getAsset with VideoPlayerController and rootBundle.loadString for loading assets. ```dart // Video player VideoPlayerController.asset(getAsset("videos/intro.mp4")) // Loading JSON final String jsonString = await rootBundle.loadString(getAsset("data/settings.json")); ``` -------------------------------- ### tester.navigateBack() Source: https://nylo.dev/docs/7.x/testing Pops the current route and settles. ```APIDOC ## tester.navigateBack() ### Description Pop the current route and settle. ### Method WidgetTester.navigateBack() ### Parameters None ### Request Example ```dart await tester.navigateBack(); ``` ### Response No return value. ``` -------------------------------- ### NyLocaleHelper.getCurrentLocale({context}) Source: https://nylo.dev/docs/7.x/localization Gets the current system locale. ```APIDOC ## getCurrentLocale({context}) ### Description Gets the current system locale. ### Method getCurrentLocale ### Parameters - **context** (BuildContext) - Optional - The build context. ### Returns - **Locale** - The current system locale. ### Example ```dart Locale locale = NyLocaleHelper.getCurrentLocale(context: context); ``` ``` -------------------------------- ### Create instances with NyFactory.make, create, and sequence Source: https://nylo.dev/docs/7.x/testing Use NyFactory.make to create a single instance, optionally with overrides and states. Use NyFactory.create for multiple instances and NyFactory.sequence for index-based data. ```dart // Create a single instance User user = NyFactory.make(); // Create with overrides User admin = NyFactory.make(overrides: {'name': 'Admin User'}); // Create with states applied User premiumAdmin = NyFactory.make(states: ['admin', 'premium']); // Create multiple instances List users = NyFactory.create(count: 5); // Create a sequence with index-based data List numbered = NyFactory.sequence(3, (int index, NyFaker faker) { return User(name: "User ${index + 1}", email: faker.email()); }); ``` -------------------------------- ### NyLocalization.instance.delegates Source: https://nylo.dev/docs/7.x/localization Gets Flutter localization delegates (used in MaterialApp). ```APIDOC ## delegates ### Description Gets Flutter localization delegates (used in MaterialApp). ### Property delegates ### Returns - **Iterable** - The localization delegates. ### Example ```dart var delegates = NyLocalization.instance.delegates; ``` ``` -------------------------------- ### NyLocalization.instance.languageCode Source: https://nylo.dev/docs/7.x/localization Gets the current language code (e.g., 'en'). ```APIDOC ## languageCode ### Description Gets the current language code (e.g., 'en'). ### Property languageCode ### Returns - **String** - The current language code. ### Example ```dart String code = NyLocalization.instance.languageCode; ``` ``` -------------------------------- ### Using getAsset with various widgets Source: https://nylo.dev/docs/7.x/assets Shows how to use getAsset with VideoPlayerController and rootBundle.loadString to load video and JSON assets. ```dart // Video player VideoPlayerController.asset(getAsset("videos/intro.mp4")) // Loading JSON final String jsonString = await rootBundle.loadString(getAsset("data/settings.json")); ``` -------------------------------- ### Set up the Metro alias Source: https://nylo.dev/docs/7.x/installation Lets you type 'metro' instead of the full 'dart run' syntax. Restart your terminal afterwards or run the source command that nylo init prints. ```bash cd my_app nylo init ``` -------------------------------- ### JSON with argument placeholders Source: https://nylo.dev/docs/7.x/localization JSON file with {{name}} and {{count}} placeholders for dynamic values. ```json { "greeting": "Hello {{name}}", "items_count": "You have {{count}} items" } ``` -------------------------------- ### NyLocalization.instance.restart(context) Source: https://nylo.dev/docs/7.x/localization Restarts the app. ```APIDOC ## restart(context) ### Description Restarts the app. ### Method restart ### Parameters - **context** (BuildContext) - Required - The build context. ### Returns - **void** - No return value. ### Example ```dart NyLocalization.instance.restart(context); ``` ``` -------------------------------- ### Update Flutter to stable channel Source: https://nylo.dev/docs/7.x/requirements Update Flutter to the latest stable release if the installed version is below 3.38.4. ```bash flutter channel stable flutter upgrade ``` -------------------------------- ### General Toast Method: showToast Source: https://nylo.dev/docs/7.x/alerts Shows the general showToast method with parameters for id, title, description, and duration. ```dart showToast( id: 'success', title: 'Hello', description: 'Welcome back!', duration: Duration(seconds: 3), ); ``` -------------------------------- ### Metro CLI Help Output Source: https://nylo.dev/docs/7.x/installation Displays the help menu for the Metro CLI, listing all available widget and helper commands. ```plaintext $ metro Metro - Nylo's Companion to Build Flutter apps by Anthony Gordon Usage: command [options] [arguments] Options -h All commands: [Widget Commands] make:page make:stateful_widget make:stateless_widget make:state_managed_widget make:navigation_hub make:journey_widget make:bottom_sheet_modal make:button make:form [Helper Commands] make:model make:provider make:api_service make:controller make:event make:route_guard make:config make:interceptor make:command make:env ``` -------------------------------- ### General toast method with showToast Source: https://nylo.dev/docs/7.x/alerts Shows the generic showToast method with parameters for id, title, description, and duration. ```dart showToast( id: 'success', title: 'Hello', description: 'Welcome back!', duration: Duration(seconds: 3), ); ``` -------------------------------- ### NyLocalization.instance.setDebugMissingKeys(enabled) Source: https://nylo.dev/docs/7.x/localization Enables or disables missing key logging. ```APIDOC ## setDebugMissingKeys(enabled) ### Description Enables or disables missing key logging. ### Method setDebugMissingKeys ### Parameters - **enabled** (bool) - Required - Whether to enable missing key logging. ### Returns - **void** - No return value. ### Example ```dart NyLocalization.instance.setDebugMissingKeys(true); ``` ``` -------------------------------- ### View Metro CLI menu Source: https://nylo.dev/docs/7.x/installation Displays the Metro CLI menu and available commands. ```bash $ metro ``` -------------------------------- ### Run tests with nylo CLI Source: https://nylo.dev/docs/7.x/testing Runs all tests in the test/ directory with formatting and prints a summary. Requires nylo_installer 1.5.0+. ```bash nylo test ``` -------------------------------- ### Get all translation keys with getAllKeys Source: https://nylo.dev/docs/7.x/localization Use `NyLocalization.instance.getAllKeys()` to retrieve a list of all loaded translation keys, useful for debugging. ```dart List keys = NyLocalization.instance.getAllKeys(); // ['welcome', 'settings', 'navigation', ...] ``` -------------------------------- ### Monitor app first launch date with Nylo.appFirstLaunchDate Source: https://nylo.dev/docs/7.x/app-usage Use Nylo.appFirstLaunchDate() to get the date the app was first launched. ```dart DateTime? firstLaunchDate = await Nylo.appFirstLaunchDate(); print("App was first launched on $firstLaunchDate"); ``` -------------------------------- ### tester.visit() Source: https://nylo.dev/docs/7.x/testing Navigates to a route and waits for the page to settle. ```APIDOC ## tester.visit() ### Description Navigate to a route and wait for the page to settle. ### Method WidgetTester.visit() ### Parameters - **route** (String) - Required - The route path to navigate to. ### Request Example ```dart await tester.visit(DashboardPage.path); ``` ### Response No return value. ``` -------------------------------- ### Return asset paths with getAsset Source: https://nylo.dev/docs/7.x/assets Shows how to use getAsset to return the full path for various file types in the assets directory, such as videos, JSON data, and fonts. ```dart // Video file String videoPath = getAsset("videos/welcome.mp4"); // JSON data file String jsonPath = getAsset("data/config.json"); // Font file String fontPath = getAsset("fonts/custom_font.ttf"); ``` -------------------------------- ### Update Flutter to latest stable release Source: https://nylo.dev/docs/7.x/requirements Upgrades Flutter to the latest stable release when the installed version is below 3.38.4. ```bash flutter channel stable flutter upgrade ``` -------------------------------- ### Update and check Nylo CLI version Source: https://nylo.dev/docs/7.x Commands to update the CLI tool from pub.dev and verify the currently installed version. ```bash nylo self-update ``` ```bash nylo --version ``` -------------------------------- ### Run tests with nylo CLI Source: https://nylo.dev/docs/7.x/testing Run the test suite from the project root. Requires nylo_installer 1.5.0+. Formats test files with dart format, runs flutter test, and prints each test with duration and a summary. ```bash nylo test ``` -------------------------------- ### NyTest.seedBackpack() Source: https://nylo.dev/docs/7.x/testing Pre-populates the Backpack with test data. ```APIDOC ## NyTest.seedBackpack() ### Description Pre-populate Backpack with test data. ### Method NyTest.seedBackpack() ### Parameters - **data** (Map) - Required - A map of key-value pairs to seed into the Backpack. ### Request Example ```dart NyTest.seedBackpack({ "user_name": "Anthony", "auth_token": "test_token", "settings": {"theme": "dark"}, }); ``` ### Response No return value. ``` -------------------------------- ### Get All Translation Keys with getAllKeys Source: https://nylo.dev/docs/7.x/localization Use NyLocalization.instance.getAllKeys() to retrieve a list of all loaded translation keys. Useful for debugging to see which keys are loaded. ```dart List keys = NyLocalization.instance.getAllKeys(); // ['welcome', 'settings', 'navigation', ...] ``` -------------------------------- ### NyWidgetTest.simpleTestTheme Source: https://nylo.dev/docs/7.x/testing A built-in light theme for font-free testing. ```APIDOC ## NyWidgetTest.simpleTestTheme ### Description A built-in light theme that can be used for font-free testing. ### Type ThemeData ### Example ```dart ThemeData light = NyWidgetTest.simpleTestTheme; ``` ``` -------------------------------- ### Default asset directory structure Source: https://nylo.dev/docs/7.x/assets Shows the default folder layout under assets/ for images, fonts, and videos. ```text assets/ ├── images/ │ ├── nylo_logo.png │ └── icons/ ├── fonts/ └── videos/ ``` -------------------------------- ### Time Boundaries with NyTime Source: https://nylo.dev/docs/7.x/testing Travel to start or end of day, month, or year using NyTime methods like travelToStartOfDay, travelToEndOfDay, etc. ```dart NyTime.travelToStartOfDay(); // 00:00:00.000 NyTime.travelToEndOfDay(); // 23:59:59.999 NyTime.travelToStartOfMonth(); // 1st of current month NyTime.travelToEndOfMonth(); // Last day of current month NyTime.travelToStartOfYear(); // Jan 1st NyTime.travelToEndOfYear(); // Dec 31st ``` -------------------------------- ### simulateLifecycleState Source: https://nylo.dev/docs/7.x/testing Simulates AppLifecycleState changes on any NyPage in the widget tree. ```APIDOC ## simulateLifecycleState ### Description Simulates AppLifecycleState changes on any NyPage in the widget tree. ### Method simulateLifecycleState ### Parameters - **state** (AppLifecycleState) - Required - The lifecycle state to simulate. ### Example ```dart await tester.pumpNyWidget(MyPage()); await tester.simulateLifecycleState(AppLifecycleState.paused); await tester.pump(); ``` ``` -------------------------------- ### Monitor total days since first launch with Nylo.appTotalDaysSinceFirstLaunch Source: https://nylo.dev/docs/7.x/app-usage Use Nylo.appTotalDaysSinceFirstLaunch() to get the total number of days since the app was first launched. ```dart int totalDaysSinceFirstLaunch = await Nylo.appTotalDaysSinceFirstLaunch(); print("It's been $totalDaysSinceFirstLaunch days since the app was first launched"); ```