### Example Usage of AirAdapter Source: https://pub.dev/documentation/air_framework/latest/core_air_adapter/AirAdapter-class.html An example demonstrating how to create a custom adapter, like DioAdapter. ```APIDOC ## Example ```dart class DioAdapter extends AirAdapter { final String baseUrl; DioAdapter({required this.baseUrl}); @override String get id => 'dio'; @override String get name => 'Dio HTTP Client'; @override void onBind(AirDI di) { di.registerLazySingleton(() => DioHttpClient(baseUrl)); } } ``` ``` -------------------------------- ### Setup Test Environment - Dart Source: https://pub.dev/documentation/air_framework/latest/framework_testing_testing/AirTestHarness/setup.html The setup method initializes the test environment by clearing all previous states and then setting the initial states defined in `_initialState`. It utilizes the Air framework's state management capabilities to set values from a specified source module ID. ```dart void setup() { // Clear existing state _clearAll(); // Set initial state for (final entry in _initialState.entries) { Air() .state(entry.key, initialValue: entry.value) .setValue(entry.value, sourceModuleId: 'test'); } } ``` -------------------------------- ### Install Air Framework CLI Tool Source: https://pub.dev/documentation/air_framework/latest/index.html This command demonstrates how to install the Air Framework's Command Line Interface (CLI) tool globally using Dart's package manager. The CLI tool is recommended for a complete development experience. ```bash dart pub global activate air_cli ``` -------------------------------- ### Route Precedence Example Source: https://pub.dev/documentation/air_framework/latest/air_framework/RouteBase-class.html Shows how to manage route precedence, ensuring predefined routes are matched before dynamic routes. ```APIDOC ## Route Precedence ### Description When multiple routes match a location, the first match is used. This example illustrates how to place dynamic routes (like `/:id`) at the end of the routes list to give precedence to predefined routes. ### Example Code ```dart final GoRouter _router = GoRouter( routes: [ GoRoute( path: '/', redirect: (_, __) => '/family/${Families.data[0].id}', ), GoRoute( path: '/family', pageBuilder: (BuildContext context, GoRouterState state) => ..., ), GoRoute( path: '/:username', pageBuilder: (BuildContext context, GoRouterState state) => ..., ), ], ); ``` In the above example, if the `/family` route is matched, it will be used. Otherwise, the `/:username` route will be used. ``` -------------------------------- ### Example Full Path Pattern Source: https://pub.dev/documentation/air_framework/latest/air_framework/RouteMatchList/fullPath.html An example of a 'fullPath' pattern string. This pattern includes parameters like ':fid' and ':pid', demonstrating how dynamic segments can be represented in the URI. ```plaintext '/family/:fid/person/:pid' ``` -------------------------------- ### Define GoRoute Path with Example Source: https://pub.dev/documentation/air_framework/latest/air_framework/GoRoute/path.html Demonstrates how to define the 'path' property for a GoRoute, including a basic example with a root path and its usage in a page builder. The path property is a String that specifies the route's URL. ```dart GoRoute( path: '/', pageBuilder: (BuildContext context, GoRouterState state) => MaterialPage( key: state.pageKey, child: HomePage(families: Families.data), ), ) ``` -------------------------------- ### Example createState Implementation for a Generic Widget Source: https://pub.dev/documentation/air_framework/latest/air_framework/AirView/createState.html This example shows a typical implementation of the createState method for a generic widget, 'SomeWidget'. It returns a new instance of the associated state class, '_SomeWidgetState'. This pattern is fundamental for managing widget state in Flutter-like frameworks. ```dart @override State createState() => _SomeWidgetState(); ``` -------------------------------- ### GoRoute Redirect Example Source: https://pub.dev/documentation/air_framework/latest/air_framework/GoRouter-class.html Illustrates how to define a redirect for an individual route using `GoRoute.redirect`. This is useful for handling specific route-based redirection logic, such as authentication checks. ```dart GoRoute( path: '/profile', builder: (context, state) => ProfileScreen(), redirect: (context, state) { // Example: Redirect if user is not logged in final isLoggedIn = checkLoginStatus(); // Assume this function exists if (!isLoggedIn) { return '/login'; // Redirect to login page } return null; // Allow navigation to profile }, ) ``` -------------------------------- ### Route Definition Example Source: https://pub.dev/documentation/air_framework/latest/air_framework/RouteBase-class.html Illustrates how to define nested routes using the GoRoute class, which inherits from RouteBase. ```APIDOC ## Route Definition Example ### Description This example demonstrates how to define a tree of routes using `GoRoute`, which extends `RouteBase`. It shows nested routes for a hierarchical navigation structure. ### Example Code ```dart final GoRouter _router = GoRouter( routes: [ GoRoute( path: '/', pageBuilder: (BuildContext context, GoRouterState state) => MaterialPage( key: state.pageKey, child: HomePage(families: Families.data), ), routes: [ GoRoute( path: 'family/:fid', pageBuilder: (BuildContext context, GoRouterState state) { final Family family = Families.family(state.pathParameters['fid']!); return MaterialPage( key: state.pageKey, child: FamilyPage(family: family), ); }, routes: [ GoRoute( path: 'person/:pid', pageBuilder: (BuildContext context, GoRouterState state) { final Family family = Families.family(state.pathParameters['fid']!); final Person person = family.person(state.pathParameters['pid']!); return MaterialPage( key: state.pageKey, child: PersonPage(family: family, person: person), ); }, ), ], ), ], ), ], ); ``` ``` -------------------------------- ### RouteConfiguration Implementation Source: https://pub.dev/documentation/air_framework/latest/air_framework/RouteConfiguration/RouteConfiguration.html Shows the implementation details of the RouteConfiguration constructor, including listener setup. ```APIDOC ## RouteConfiguration Implementation ### Description This section details the implementation of the RouteConfiguration constructor, including the initialization of internal properties and the setup of listeners for routing table changes. ### Method Constructor Implementation ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```dart RouteConfiguration( this._routingConfig, required this.navigatorKey, this.extraCodec, this.router, ) { _onRoutingTableChanged(); _routingConfig.addListener(_onRoutingTableChanged); } ``` ### Response #### Success Response (200) N/A (Constructor Implementation) #### Response Example N/A (Constructor Implementation) ``` -------------------------------- ### Setting Up and Tearing Down Test Environment with AirTestHarness Source: https://pub.dev/documentation/air_framework/latest/framework_testing_testing/AirTestHarness-class.html Illustrates the use of setup and teardown methods for initializing and cleaning up the test environment. These methods are typically called automatically by the testing framework. ```dart harness.setup(); // ... test logic ... harness.teardown(); ``` -------------------------------- ### ShellRoute Configuration Example Source: https://pub.dev/documentation/air_framework/latest/air_framework/ShellRoute-class.html This code demonstrates how to configure a ShellRoute within a GoRouter. It shows how to define a shell with a custom builder (ScaffoldWithNavBar) and nested routes, including an example of displaying a child route on the root Navigator using parentNavigatorKey. ```dart final GlobalKey _rootNavigatorKey = GlobalKey(); final GoRouter _router = GoRouter( navigatorKey: _rootNavigatorKey, initialLocation: '/a', routes: [ ShellRoute( navigatorKey: _shellNavigatorKey, builder: (context, state, child) { return ScaffoldWithNavBar(child: child); }, routes: [ // This screen is displayed on the ShellRoute's Navigator. GoRoute( path: '/a', builder: (context, state) { return const ScreenA(); }, routes: [ // This screen is displayed on the ShellRoute's Navigator. GoRoute( path: 'details', builder: (BuildContext context, GoRouterState state) { return const DetailsScreen(label: 'A'); }, ), ], ), // Displayed ShellRoute's Navigator. GoRoute( path: '/b', builder: (BuildContext context, GoRouterState state) { return const ScreenB(); }, routes: [ // Displayed on the root Navigator by specifying the // [parentNavigatorKey]. GoRoute( path: 'details', parentNavigatorKey: _rootNavigatorKey, builder: (BuildContext context, GoRouterState state) { return const DetailsScreen(label: 'B'); }, ), ], ), ], ), ], ); ``` -------------------------------- ### AirView Constructor Source: https://pub.dev/documentation/air_framework/latest/air_framework/AirView/AirView.html This section details the constructor for the AirView widget, outlining its parameters and providing an implementation example. ```APIDOC ## AirView Constructor ### Description This constructor initializes an AirView widget, requiring a builder function to define its content. ### Method constructor ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **builder** (WidgetBuilder) - Required - A function that returns the widget tree for the AirView. - **key** (Key?) - Optional - A key to identify the widget. ### Request Example ```dart const AirView( 1. WidgetBuilder builder, 2. Key? key, ) ``` ### Response #### Success Response (200) N/A (This is a constructor, not an endpoint) #### Response Example ```dart const AirView(this.builder, {super.key}); ``` ``` -------------------------------- ### AirView Widget Example Source: https://pub.dev/documentation/air_framework/latest/air_framework/AirView-class.html Demonstrates how to use the AirView widget to conditionally render UI based on state changes. The builder function tracks dependencies, and the widget rebuilds when these dependencies are updated. ```dart AirView((context) { if (CounterState.count.value > 5) return Text('High!'); return Text('${CounterState.count.value}'); }) ``` -------------------------------- ### SimpleStateKey Class Overview Source: https://pub.dev/documentation/air_framework/latest/air_framework/SimpleStateKey-class.html This section details the SimpleStateKey class, its purpose, usage examples, inheritance hierarchy, and available extensions. ```APIDOC ## SimpleStateKey Class A simple implementation of AirStateKey for quick usage. Use this when you don't need to create a custom subclass for your keys. ### Example ```dart static const counterKey = SimpleStateKey('counter', defaultValue: 0); ``` ### Inheritance - Object - AirStateKey - SimpleStateKey ### Available extensions - AirStateKeyBuilder ``` -------------------------------- ### PageKey Example Usage (Dart) Source: https://pub.dev/documentation/air_framework/latest/air_framework/GoRouterState/pageKey.html Illustrates how to use the 'pageKey' property with a sample route string. The 'pageKey' is essential for uniquely identifying and navigating between different sub-routes. ```dart ValueKey('/family/:fid') ``` -------------------------------- ### Get initialRoute Property - Dart Source: https://pub.dev/documentation/air_framework/latest/core_app_module/AppModule/initialRoute.html Retrieves the initial route path as a String. This property defines the starting point for a module, for example, '/counter'. No specific dependencies are mentioned, and it returns a string representing the route. ```dart String get initialRoute; ``` -------------------------------- ### Get Adapter ID - Dart Source: https://pub.dev/documentation/air_framework/latest/core_air_adapter/AirAdapter/id.html Retrieves the unique identifier for an adapter. This string is used for dependency resolution and debugging purposes within the Air Framework. Example: 'dio', 'sentry'. ```dart String get id; ``` -------------------------------- ### Get Adapter Name (Dart) Source: https://pub.dev/documentation/air_framework/latest/core_air_adapter/AirAdapter/name.html Retrieves the human-readable name of the adapter. This string is used in debugging logs and for display in tools like DevTools. For example, it might return 'Dio HTTP Client'. ```dart String get name; ``` -------------------------------- ### Initialize AirAnalyticsAdapter Source: https://pub.dev/documentation/air_framework/latest/framework_utils_analytics/AirAnalyticsAdapter/AirAnalyticsAdapter.html Demonstrates the basic instantiation of the AirAnalyticsAdapter. This is the primary way to create an instance of the adapter for use in your application. No specific parameters are required for the default constructor. ```air AirAnalyticsAdapter() ``` -------------------------------- ### AirView Constructor Implementation Source: https://pub.dev/documentation/air_framework/latest/air_framework/AirView/AirView.html Provides the concrete implementation of the AirView constructor. It initializes the builder and passes the key to the superclass constructor, ensuring proper widget setup and lifecycle management. ```dart const AirView(this.builder, {super.key}); ``` -------------------------------- ### Get Primary UI Color (Dart) Source: https://pub.dev/documentation/air_framework/latest/core_app_module/AppModule/color.html This snippet demonstrates how to retrieve the primary color associated with a module for UI branding. It utilizes Flutter's `Colors.teal` as an example. No external dependencies are required beyond the Flutter framework. ```dart Color get color => Colors.teal; ``` -------------------------------- ### Allow Constructor Source: https://pub.dev/documentation/air_framework/latest/air_framework/Allow/Allow.html Explains the `Allow` constructor, its purpose, parameters, and implementation details. ```APIDOC ## Allow Constructor ### Description Creates an `Allow` result with an optional `then` callback executed after navigation completes. ### Method Constructor ### Endpoint N/A (Dart Constructor) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```dart const Allow({ this.then, }); ``` ### Response #### Success Response (Constructor) N/A #### Response Example N/A ### Implementation Details ```dart const Allow({super.then}); ``` ``` -------------------------------- ### Create Allow Constructor with Callback (Dart) Source: https://pub.dev/documentation/air_framework/latest/air_framework/Allow/Allow.html Demonstrates the creation of an Allow constructor in Dart, which accepts an optional `then` callback. This callback is executed after the navigation process is completed. The implementation shown is a concise way to initialize the constructor with the provided callback. ```dart const Allow({ 1. OnEnterThenCallback? then, }) // Implementation const Allow({super.then}); ``` -------------------------------- ### AppModule Lifecycle Example in Dart Source: https://pub.dev/documentation/air_framework/latest/core_app_module/AppModule-class.html Demonstrates how to extend the AppModule class to implement module-specific logic for binding dependencies, asynchronous initialization, and resource cleanup. ```dart class MyModule extends AppModule { @override String get id => 'my_module'; @override String get name => 'My Module'; @override void onBind(AirDI di) { di.register(MyService()); } @override Future onInit(AirDI di) async { final service = di.get(); await service.loadInitialData(); } @override Future onDispose(AirDI di) async { final service = di.get(); await service.cleanup(); } } ``` -------------------------------- ### Air CLI Commands for Project Scaffolding Source: https://pub.dev/documentation/air_framework/latest/index.html This section provides examples of using the Air Command Line Interface (CLI) to manage Air Framework projects. It includes commands for creating new projects from templates, generating new modules, scaffolding adapters, and generating state code for modules. ```bash # Create a new project air create my_app --template=starter # Generate a new module air generate module inventory # Generate an adapter air generate adapter sentry # Generate state code air generate state cart --module=inventory ``` -------------------------------- ### Offset Get Unit Implementation (Dart) Source: https://pub.dev/documentation/air_framework/latest/framework_devtools_tabs_air_graph_tab/OffsetExt/unit.html Implements the 'get unit' property for an Offset. It calculates a normalized offset by dividing the offset by its magnitude (distance). If the distance is zero, it returns Offset.zero to avoid division by zero. ```dart Offset get unit { final double l = distance; if (l == 0) return Offset.zero; return this / l; } ``` -------------------------------- ### ModuleInstalledEvent Constructor (Dart) Source: https://pub.dev/documentation/air_framework/latest/framework_communication_event_bus/ModuleInstalledEvent-class.html Defines the constructor for the ModuleInstalledEvent class. It requires the IDs and name of the source and installed modules, along with the installed module's version. This constructor is essential for creating event objects that capture details of a module installation. ```dart ModuleInstalledEvent({ required String sourceModuleId, required String installedModuleId, required String installedModuleName, required String version }) ``` -------------------------------- ### Retrieve Registered Dependency using get in Dart Source: https://pub.dev/documentation/air_framework/latest/framework_di_di/AirDI/get.html The get method retrieves a registered dependency of a specified type T. It looks up the dependency in an internal map and returns it, cast to type T. If the dependency is not found, it throws a DependencyNotFoundException. ```dart T get() { final dependency = _registrations[T]; if (dependency == null) { throw DependencyNotFoundException(T); } return dependency.get() as T; } ``` -------------------------------- ### GoRouter Error Handling Example Source: https://pub.dev/documentation/air_framework/latest/air_framework/GoRouter-class.html Shows how to configure GoRouter to handle exceptions during navigation using `onException`, `errorPageBuilder`, or `errorBuilder`. If `onException` is not provided, the exception is passed to `errorPageBuilder` or `errorBuilder`. ```dart GoRouter( routes: [ // ... your routes ], onException: (context, state, exception) { print('An error occurred: $exception'); // Handle the exception, e.g., log it or show a specific message }, errorPageBuilder: (context, state) => MaterialPage( key: state.pageKey, child: Scaffold( appBar: AppBar(title: Text('Error')), body: Center(child: Text('Page not found or error occurred.')), ), ), // Alternatively, use errorBuilder for non-page errors // errorBuilder: (context, state) => Text('Error: ${state.error}'), ) ``` -------------------------------- ### Constructors Source: https://pub.dev/documentation/air_framework/latest/air_framework/AirStateKey-class.html Details on how to create an instance of AirStateKey. ```APIDOC ## Constructors ### AirStateKey(String key, {T? defaultValue}) Creates an AirStateKey with a required `key` and optional `defaultValue`. **Parameters** * **key** (String) - Required - The unique string identifier for the state. * **defaultValue** (T?) - Optional - The default value for the state if not initialized. ``` -------------------------------- ### Get Registered Dependency Source: https://pub.dev/documentation/air_framework/latest/framework_di_di/AirDI/get.html Retrieves a registered dependency of a specified type. Throws an exception if the type is not found. ```APIDOC ## GET /dependency/{type} ### Description Retrieves a registered dependency of type `T`. Throws `DependencyNotFoundException` if the type is not registered. ### Method GET ### Endpoint `/dependency/{type}` ### Parameters #### Path Parameters - **type** (Type) - Required - The type of the dependency to retrieve. ### Response #### Success Response (200) - **dependency** (T) - The registered dependency instance. #### Error Response (404) - **message** (string) - Indicates that the dependency type was not found. ### Request Example (No request body for GET method) ### Response Example (Success) ```json { "dependency": "instance_of_type_T" } ``` ### Response Example (Error) ```json { "message": "Dependency of type 'SomeType' not found." } ``` ``` -------------------------------- ### Build Reactive UI with Air Framework's AirView Source: https://pub.dev/documentation/air_framework/latest/index.html This example showcases how to build a reactive User Interface using `AirView` in the Air Framework. `AirView` efficiently listens to state changes by automatically tracking accessed flows, ensuring that only necessary widgets are rebuilt. It also demonstrates how to trigger state updates (pulses) via user interactions. ```dart class CounterPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: Center( child: AirView((context) { // Auto-subscribes to 'count' return Text('Count: ${CounterFlows.count.value}'); }), ), floatingActionButton: FloatingActionButton( // Triggers the 'increment' pulse onPressed: () => CounterPulses.increment.pulse(null), child: const Icon(Icons.add), ), ); } } ``` -------------------------------- ### Example of DiagnosticsProperty with showSeparator Source: https://pub.dev/documentation/air_framework/latest/air_framework/InheritedGoRouter/debugFillProperties.html Demonstrates the usage of the showSeparator parameter in DiagnosticsProperty to control the output format when a property is null. This example shows how to achieve a more polished output string. ```dart DiagnosticsProperty('child(3, 4)', null, ifNull: 'is null', showSeparator: false).toString() ``` -------------------------------- ### Implement Asynchronous Initialization with onInit (Dart) Source: https://pub.dev/documentation/air_framework/latest/core_air_adapter/AirAdapter/onInit.html The onInit method in the Air Framework handles asynchronous initialization logic for an adapter. It's called after onBind and is suitable for intensive setup tasks like establishing connections or loading configurations. The method receives an AirDI instance for dependency injection. ```dart Future onInit(AirDI di) async { _state = AdapterLifecycleState.initializing; debugPrint('[Adapter:$id] onInit'); _state = AdapterLifecycleState.initialized; } ``` -------------------------------- ### Declare Optional Dependencies (Dart) Source: https://pub.dev/documentation/air_framework/latest/core_app_module/AppModule/optionalDependencies.html Example of how to declare optional module dependencies using the `optionalDependencies` getter in Dart. This example specifies 'analytics' as an optional dependency. ```dart @override List get optionalDependencies => ['analytics']; ``` -------------------------------- ### Implementing a Dio HTTP Client Adapter Source: https://pub.dev/documentation/air_framework/latest/core_air_adapter/AirAdapter-class.html This example demonstrates how to create a custom adapter for the Dio HTTP client. It extends the AirAdapter class and registers a DioHttpClient instance within the AirDI container during the onBind phase. This adapter requires a baseUrl for its configuration. ```dart class DioAdapter extends AirAdapter { final String baseUrl; DioAdapter({required this.baseUrl}); @override String get id => 'dio'; @override String get name => 'Dio HTTP Client'; @override void onBind(AirDI di) { di.registerLazySingleton(() => DioHttpClient(baseUrl)); } } ``` -------------------------------- ### Initialize Air Framework App in main.dart Source: https://pub.dev/documentation/air_framework/latest/index.html This code snippet shows the essential steps for initializing an Air Framework application within the `main.dart` file. It covers configuring Air State, registering adapters for infrastructure services, and registering feature modules before running the application with the Air Router. ```dart void main() async { WidgetsFlutterBinding.ensureInitialized(); // 1. Configure Air State configureAirState(); // 2. Register Adapters (infrastructure — BEFORE modules) final adapters = AdapterManager(); await adapters.register(DioAdapter(baseUrl: 'https://api.example.com')); // 3. Register Modules (features — can use adapter services) await ModuleManager().register(CounterModule()); runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp.router( title: 'Air App', routerConfig: AirRouter().router, ); } } ``` -------------------------------- ### Get Recent Security Violations (Dart) Source: https://pub.dev/documentation/air_framework/latest/framework_security_air_audit/AirAudit/recentViolations.html Retrieves the 20 most recent security violations from the audit entries. It filters entries by `AuditType.securityViolation`, reverses the list to get the latest first, and then takes the top 20. ```dart List get recentViolations { return _entries .where((e) => e.type == AuditType.securityViolation) .toList() .reversed .take(20) .toList(); } ``` -------------------------------- ### AirAnalyticsAdapter Constructor Source: https://pub.dev/documentation/air_framework/latest/framework_utils_analytics/AirAnalyticsAdapter/AirAnalyticsAdapter.html Initializes a new instance of the AirAnalyticsAdapter. ```APIDOC ## AirAnalyticsAdapter() ### Description Initializes a new instance of the AirAnalyticsAdapter. ### Method CONSTRUCTOR ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ``` AirAnalyticsAdapter() ``` ### Response #### Success Response (200) - **instance** (AirAnalyticsAdapter) - A new instance of AirAnalyticsAdapter. #### Response Example ```json { "instance": "" } ``` ``` -------------------------------- ### ModuleInstalledEvent Properties (Dart) Source: https://pub.dev/documentation/air_framework/latest/framework_communication_event_bus/ModuleInstalledEvent-class.html Lists the properties of the ModuleInstalledEvent class. These properties store information about the module installation event, including source and installed module identifiers, module name, and version. Some properties are inherited from parent classes. ```dart final String installedModuleId; final String installedModuleName; final String sourceModuleId; final String version; final DateTime timestamp; ``` -------------------------------- ### Get Last Leaf RouteMatch (Dart) Source: https://pub.dev/documentation/air_framework/latest/air_framework/RouteMatchList/last.html Retrieves the last leaf RouteMatch from a list of matches. It handles nested ShellRouteMatches by recursively accessing their matches until a non-ShellRouteMatch is found. Throws a StateError if the matches list is empty. ```dart RouteMatch get last { if (matches.last is RouteMatch) { return matches.last as RouteMatch; } return (matches.last as ShellRouteMatch)._lastLeaf; } ``` -------------------------------- ### Instantiate and Execute Commands with DevToolsCLI Source: https://pub.dev/documentation/air_framework/latest/framework_devtools_devtools_cli/DevToolsCLI-class.html Demonstrates how to instantiate the DevToolsCLI class and execute various commands for debugging and interaction with the Air Framework. This includes commands for getting state, logging out, listing dependencies, and accessing help. ```dart final cli = DevToolsCLI(); // Process commands cli.execute('state get user.profile'); cli.execute('pulse auth.logout'); cli.execute('di list'); cli.execute('help'); ``` -------------------------------- ### Get isStop Property - Dart Source: https://pub.dev/documentation/air_framework/latest/air_framework/OnEnterResult/isStop.html This Dart code snippet defines how to get the 'isStop' property. It checks if the current object is an instance of 'Block' and if its 'then' property is null. This property is crucial for determining if an operation should terminate without further actions. ```dart bool get isStop => this is Block && then == null; ``` -------------------------------- ### BatchingAnalyticsAdapter Constructor Source: https://pub.dev/documentation/air_framework/latest/framework_utils_analytics/BatchingAnalyticsAdapter-class.html Initializes a new instance of the BatchingAnalyticsAdapter class. ```APIDOC ## BatchingAnalyticsAdapter Constructor ### Description Initializes a new instance of the BatchingAnalyticsAdapter class with an optional batch size and maximum delay. ### Method Constructor ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```dart BatchingAnalyticsAdapter(_delegate, {batchSize: 10, maxDelay: const Duration(seconds: 30)}) ``` ### Response #### Success Response (200) None (Constructors do not return values in the same way as methods). #### Response Example None ``` -------------------------------- ### Dart noSuchMethod Example: Custom Behavior with MockList Source: https://pub.dev/documentation/air_framework/latest/framework_devtools_module_logger/ModuleLogging/noSuchMethod.html Illustrates how to override noSuchMethod in a class to provide custom behavior for invalid dynamic invocations. This example uses a MockList class that logs invocations instead of throwing an error immediately. ```dart class MockList implements List { noSuchMethod(Invocation invocation) { log(invocation); super.noSuchMethod(invocation); // Will throw. } } void main() { MockList().add(42); } ``` -------------------------------- ### Implement Asynchronous Initialization with onInit (Dart) Source: https://pub.dev/documentation/air_framework/latest/core_app_module/AppModule/onInit.html The onInit method in Dart is designed for asynchronous initialization tasks within a module. It's called after onBind and ensures all mandatory dependencies are ready. Use this method to perform 'heavy lifting' such as initializing databases, loading configurations, or establishing connections, and await services before the module is marked as initialized. The `di` parameter provides access to the dependency injection container. ```dart Future onInit(AirDI di) async { _state = ModuleLifecycleState.initializing; debugPrint('[$id] onInit'); _state = ModuleLifecycleState.initialized; } ``` -------------------------------- ### Navigation API - Go Method Source: https://pub.dev/documentation/air_framework/latest/air_framework/RouteInformationState/go.html Initiates a 'go' navigation action, allowing for optional extra data to be passed along with the navigation event. ```APIDOC ## POST /websites/pub_dev_air_framework/go ### Description Initiates a 'go' navigation action. This method is a factory constructor used for navigation, allowing an optional 'extra' object to be passed. ### Method POST ### Endpoint /websites/pub_dev_air_framework/go ### Parameters #### Query Parameters - **extra** (Object?) - Optional - Additional data to be passed with the navigation. ### Request Example ```json { "extra": { "userId": "123", "source": "homepage" } } ``` ### Response #### Success Response (200) - **RouteInformationState** (Object) - Represents the state of the navigation, including the type and any extra data. #### Response Example ```json { "type": "NavigatingType.go", "extra": { "userId": "123", "source": "homepage" } } ``` ``` -------------------------------- ### Get Air Singleton Instance (Dart) Source: https://pub.dev/documentation/air_framework/latest/air_framework/Air/Air.html This snippet shows how to get the singleton instance of the Air framework. It utilizes a factory constructor, ensuring only one instance of Air is ever created. This is a common pattern for managing global state or resources. ```dart factory Air() => _instance; ``` -------------------------------- ### GoRouterDelegate Methods Source: https://pub.dev/documentation/air_framework/latest/air_framework/GoRouterDelegate-class.html Documentation for the methods provided by the GoRouterDelegate class, including navigation control, lifecycle management, and listener registration. ```APIDOC ## GoRouterDelegate Methods ### Description Methods available on the GoRouterDelegate class for managing navigation, handling route changes, and interacting with the Router architecture. ### Methods - **addListener(VoidCallback listener)** - void - Register a closure to be called when the object changes. (inherited) - **build(BuildContext context)** - Widget - For use by the Router architecture as part of the RouterDelegate. (override) - **canPop()** - bool - Returns `true` if the active Navigator can pop. - **dispose()** - void - Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded. (inherited) - **noSuchMethod(Invocation invocation)** - dynamic - Invoked when a nonexistent method or property is accessed. (inherited) - **notifyListeners()** - void - Call all the registered listeners. (inherited) - **pop([T? result])** - void - Pops the top-most route. - **popRoute()** - Future - Called by the Router when the Router.backButtonDispatcher reports that the operating system is requesting that the current route be popped. (override) - **removeListener(VoidCallback listener)** - void - Remove a previously registered closure from the list of closures that are notified when the object changes. (inherited) - **setInitialRoutePath(RouteMatchList configuration)** - Future - Called by the Router at startup with the structure that the RouteInformationParser obtained from parsing the initial route. (inherited) - **setNewRoutePath(RouteMatchList configuration)** - Future - For use by the Router architecture as part of the RouterDelegate. (override) - **setRestoredRoutePath(RouteMatchList configuration)** - Future - Called by the Router during state restoration. (inherited) - **toString()** - String - A string representation of this object. (inherited) ``` -------------------------------- ### ShellRouteContext Implementation Source: https://pub.dev/documentation/air_framework/latest/air_framework/ShellRouteContext/ShellRouteContext.html Shows the implementation details of the ShellRouteContext constructor. ```APIDOC ## ShellRouteContext Implementation ### Description This code block shows the actual implementation of the ShellRouteContext constructor, assigning the provided parameters to the object's properties. ### Method Constructor Implementation ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```dart ShellRouteContext({ required this.route, required this.routerState, required this.navigatorKey, required this.match, required this.routeMatchList, required this.navigatorBuilder, }); ``` ### Response #### Success Response (200) N/A (This is a constructor implementation) #### Response Example N/A ``` -------------------------------- ### SimpleStateKey Constructor Implementation Source: https://pub.dev/documentation/air_framework/latest/air_framework/SimpleStateKey/SimpleStateKey.html Provides the implementation for the SimpleStateKey constructor, which calls the superclass constructor with the provided key and defaultValue. This is a concise way to initialize the state key. ```dart const SimpleStateKey(super.key, {super.defaultValue}); ``` -------------------------------- ### Example Usage of testState for CartState (Dart) Source: https://pub.dev/documentation/air_framework/latest/framework_testing_testing/testState.html This example demonstrates how to use the testState function to test a CartState. It initializes the state with an empty cart, adds an item using a signal, pumps the state to process the signal, and then asserts that the cart contains one item. ```dart await testState( createState: () => CartState(), initialState: {'cart.items': []}, test: (state, harness) async { harness.emitSignal('cart.add', {'productId': '123'}); await harness.pump(); expect(harness.getState('cart.items'), hasLength(1)); }, ); ``` -------------------------------- ### Flutter initState Method Implementation Source: https://pub.dev/documentation/air_framework/latest/air_framework/StatefulNavigationShellState/initState.html Demonstrates the standard implementation of the initState method in a Flutter State object. It includes calling the superclass's initState and performing custom initialization logic. ```dart @override void initState() { super.initState(); _updateCurrentBranchStateFromWidget(); } ``` -------------------------------- ### GET /websites/pub_dev_air_framework/history Source: https://pub.dev/documentation/air_framework/latest/framework_devtools_devtools_cli/DevToolsCLI/history.html Retrieves the command history as a list of strings. ```APIDOC ## GET /websites/pub_dev_air_framework/history ### Description Retrieves the command history as an unmodifiable list of strings. ### Method GET ### Endpoint /websites/pub_dev_air_framework/history ### Parameters None ### Request Example None ### Response #### Success Response (200) - **history** (List) - An unmodifiable list containing the command history strings. #### Response Example { "history": [ "command1", "command2", "command3" ] } ``` -------------------------------- ### Get Module Context Source: https://pub.dev/documentation/air_framework/latest/core_module_manager/ModuleManager/getContext.html Retrieves the context of a module by its unique identifier. ```APIDOC ## GET /websites/pub_dev_air_framework/getContext ### Description Get module context by ID. ### Method GET ### Endpoint /websites/pub_dev_air_framework/getContext ### Parameters #### Query Parameters - **moduleId** (String) - Required - The ID of the module for which to retrieve the context. ### Response #### Success Response (200) - **ModuleContext?** (Object) - The context object for the specified module, or null if not found. #### Response Example ```json { "context": { "someField": "someValue" } } ``` ``` -------------------------------- ### TypedGoRoute Constructor Source: https://pub.dev/documentation/air_framework/latest/air_framework/TypedGoRoute/TypedGoRoute.html Documentation for the TypedGoRoute constructor, including its parameters and their types. ```APIDOC ## TypedGoRoute constructor ### Description Defines a typed route with a path, optional name, nested routes, and case sensitivity. ### Method Constructor ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```dart const TypedGoRoute( path: '/example', name: 'exampleRoute', routes: [ // nested routes ], caseSensitive: false, ); ``` ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Get Configuration Source: https://pub.dev/documentation/air_framework/latest/air_framework/AirStatePersistence/config.html Retrieves the current state persistence configuration of the application. ```APIDOC ## GET /websites/pub_dev_air_framework/config ### Description Retrieves the current state persistence configuration. ### Method GET ### Endpoint /websites/pub_dev_air_framework/config ### Parameters None ### Request Example None ### Response #### Success Response (200) - **config** (StatePersistenceConfig?) - The current state persistence configuration. #### Response Example ```json { "config": { "someField": "someValue" } } ``` ``` -------------------------------- ### GoRouter Constructor Example Source: https://pub.dev/documentation/air_framework/latest/air_framework/GoRouter-class.html Demonstrates the default constructor for GoRouter, used to configure the app's routes and error handling. It requires a list of routes and can optionally take callbacks for onEnter, onException, errorPageBuilder, errorBuilder, and redirect. ```dart GoRouter( routes: [ GoRoute( path: '/', builder: (context, state) => HomePage(), ), // Add more routes here ], onEnter: (context, state) { // Optional: Intercept navigation before routes are processed print('Entering route: ${state.uri}'); return NavigationDecision.allow; }, errorPageBuilder: (context, state) => MaterialPage( key: state.pageKey, child: ErrorScreen(error: state.error), ), redirect: (context, state) { // Optional: Global redirect logic if (state.uri.toString() == '/old') { return '/new'; } return null; // No redirect }, // ... other optional parameters ) ``` -------------------------------- ### GET /websites/pub_dev_air_framework/getModuleServices Source: https://pub.dev/documentation/air_framework/latest/framework_security_secure_service_registry/SecureServiceRegistry/getModuleServices.html Retrieves a list of all services registered by a given module ID. ```APIDOC ## GET /websites/pub_dev_air_framework/getModuleServices ### Description Get all services registered by a module. ### Method GET ### Endpoint /websites/pub_dev_air_framework/getModuleServices ### Parameters #### Query Parameters - **moduleId** (String) - Required - The ID of the module for which to retrieve services. ### Response #### Success Response (200) - **services** (List) - A list of service descriptors registered by the module. #### Response Example ```json { "services": [ { "serviceId": "service1", "ownerModuleId": "moduleA", "serviceName": "Example Service 1" }, { "serviceId": "service2", "ownerModuleId": "moduleA", "serviceName": "Example Service 2" } ] } ``` ``` -------------------------------- ### ShellRoute Constructor Implementation Source: https://pub.dev/documentation/air_framework/latest/air_framework/ShellRoute/ShellRoute.html Provides the implementation details for the ShellRoute constructor. It initializes the route with provided parameters, sets up a default navigator key if none is provided, and includes assertions to validate route configurations, ensuring that routes are not empty and that sub-route navigator keys are correctly set. ```dart ShellRoute({ super.redirect, this.builder, this.pageBuilder, super.notifyRootObserver, this.observers, required super.routes, super.parentNavigatorKey, GlobalKey? navigatorKey, this.restorationScopeId, }) : assert(routes.isNotEmpty), navigatorKey = navigatorKey ?? GlobalKey(), super._() { assert(() { ShellRouteBase._debugCheckSubRouteParentNavigatorKeys( routes, this.navigatorKey, ); return true; }()); } ``` -------------------------------- ### AirAdapter Constructors and Properties Source: https://pub.dev/documentation/air_framework/latest/core_air_adapter/AirAdapter-class.html Details on the constructors and properties available for the AirAdapter class. ```APIDOC ## Constructors ### AirAdapter() ## Properties ### dependencies → List List of other adapter IDs that this adapter depends on. * **no setter** ### hashCode → int The hash code for this object. * **no setter** * inherited ### id → String Unique identifier for the adapter (e.g., 'dio', 'sentry'). Used for dependency resolution and debugging. * **no setter** ### name → String Human-readable name of the adapter (e.g., 'Dio HTTP Client'). Used in DevTools and debug logs. * **no setter** ### runtimeType → Type A representation of the runtime type of the object. * **no setter** * inherited ### state → AdapterLifecycleState Current lifecycle state of the adapter * **no setter** ### version → String Version of the adapter following Semantic Versioning (semver). Defaults to '1.0.0'. * **no setter** ``` -------------------------------- ### GET /websites/pub_dev_air_framework/debugRegistrationInfo Source: https://pub.dev/documentation/air_framework/latest/framework_di_di/AirDI/debugRegistrationInfo.html Retrieves a map of registered types and their owner modules for debugging and DevTools. ```APIDOC ## GET /websites/pub_dev_air_framework/debugRegistrationInfo ### Description Returns a map of registered types and their owner modules for debugging/DevTools purposes. ### Method GET ### Endpoint /websites/pub_dev_air_framework/debugRegistrationInfo ### Parameters #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **debugRegistrationInfo** (Map) - A map where keys are the string representation of registered types and values are their owner module names. #### Response Example ```json { "debugRegistrationInfo": { "TypeA": "ModuleX", "TypeB": "ModuleY" } } ``` ``` -------------------------------- ### Get Module by ID Source: https://pub.dev/documentation/air_framework/latest/core_module_manager/ModuleManager/getModule.html Retrieves a specific module using its unique identifier. ```APIDOC ## GET /websites/pub_dev_air_framework/modules/{id} ### Description Retrieves a module by its unique ID. ### Method GET ### Endpoint /websites/pub_dev_air_framework/modules/{id} ### Parameters #### Path Parameters - **id** (String) - Required - The unique identifier of the module. ### Response #### Success Response (200) - **AppModule** (Object) - The module object if found. - **id** (String) - The unique identifier of the module. - **name** (String) - The name of the module. #### Response Example ```json { "id": "module123", "name": "Example Module" } ``` ``` -------------------------------- ### GoRouterState Methods Source: https://pub.dev/documentation/air_framework/latest/air_framework/GoRouterState-class.html Documentation for the methods available on the GoRouterState class. ```APIDOC ## Methods ### namedLocation ```dart String namedLocation( String name, { Map pathParameters = const {}, Map queryParameters = const {}, String? fragment, } ) ``` **Description**: Get a location from route name and parameters. This is useful for redirecting to a named location. ### noSuchMethod ```dart dynamic noSuchMethod(Invocation invocation) ``` **Description**: Invoked when a nonexistent method or property is accessed. ### toString ```dart String toString() ``` **Description**: A string representation of this object. ``` -------------------------------- ### AirStateKey Constructor Source: https://pub.dev/documentation/air_framework/latest/air_framework/AirStateKey/AirStateKey.html Details on how to instantiate an AirStateKey object. ```APIDOC ## const AirStateKey(String key, {T? defaultValue}) ### Description Creates an AirStateKey with a required `key` and optional `defaultValue`. ### Method Constructor ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```dart // Example usage (not a direct request body, but instantiation) final myKey = AirStateKey('user_token', defaultValue: 'guest'); ``` ### Response #### Success Response (200) N/A (This is a constructor) #### Response Example N/A ## Implementation ```dart const AirStateKey(this.key, {this.defaultValue}); ``` ``` -------------------------------- ### HotReloadable Mixin Overview Source: https://pub.dev/documentation/air_framework/latest/framework_utils_hot_reload/HotReloadable-mixin.html This section provides an overview of the HotReloadable mixin, its purpose, and an example of its usage. ```APIDOC ## HotReloadable Mixin ### Description Mixin to add HMR support to modules. ### Example Usage ```dart class MyModule extends AppModule with HotReloadable { @override List get stateKeysToPreserve => ['my_module.data', 'my_module.user']; @override Future onHotReload() async { // Re-subscribe to events, etc. } } ``` ### Properties - **hashCode** (int) - The hash code for this object. (inherited) - **runtimeType** (Type) - A representation of the runtime type of the object. (inherited) - **stateKeysToPreserve** (List) - State keys that should be preserved during hot reload. ### Methods - **noSuchMethod**(Invocation invocation) → dynamic - Invoked when a nonexistent method or property is accessed. (inherited) - **onHotReload**() → Future - Called after hot reload completes. - **toString**() → String - A string representation of this object. (inherited) ### Operators - **operator ==**(Object other) → bool - The equality operator. (inherited) ``` -------------------------------- ### StateMatcher Class Overview Source: https://pub.dev/documentation/air_framework/latest/framework_testing_testing/StateMatcher-class.html Provides details on how to use the StateMatcher class for asserting state values. ```APIDOC ## StateMatcher Class Matcher for checking state values. ### Constructors #### StateMatcher(String key, AirTestHarness harness) - **key** (String) - Required - The key of the state to match. - **harness** (AirTestHarness) - Required - The AirTestHarness instance. ### Properties - **harness** (AirTestHarness) - The AirTestHarness instance associated with this matcher. - **hashCode** (int) - The hash code for this object. - **isNotNull** (bool) - Check if the state is not null. - **isNull** (bool) - Check if the state is null. - **key** (String) - The key of the state. - **runtimeType** (Type) - A representation of the runtime type of the object. ### Methods #### equals(T expected) → bool - **expected** (T) - Required - The value to compare the state against. - **Description**: Check if the state equals the expected value. #### noSuchMethod(Invocation invocation) → dynamic - **invocation** (Invocation) - Required - The invocation details. - **Description**: Invoked when a nonexistent method or property is accessed. #### toString() → String - **Description**: Returns a string representation of this object. #### value() → T? - **Description**: Get the current value of the state. ### Operators #### operator ==(Object other) → bool - **other** (Object) - Required - The object to compare with. - **Description**: The equality operator. ``` -------------------------------- ### StatefulNavigationShellState Constructor and Methods Source: https://pub.dev/documentation/air_framework/latest/air_framework/StatefulNavigationShellState-class.html Demonstrates the constructor and key methods of the StatefulNavigationShellState class, including navigation and state management functions. ```dart StatefulNavigationShellState() build(BuildContext context) → Widget didUpdateWidget(covariant StatefulNavigationShell oldWidget) → void dispose() → void goBranch(int index, {bool initialLocation = false}) → void initState() → void restoreState(RestorationBucket? oldBucket, bool initialRestore) → void ``` -------------------------------- ### GET /websites/pub_dev_air_framework/registeredModules Source: https://pub.dev/documentation/air_framework/latest/framework_utils_federated_modules/FederatedModuleLoader/registeredModules.html Retrieves a list of all registered module configurations within the Air Framework. ```APIDOC ## GET /websites/pub_dev_air_framework/registeredModules ### Description Get all registered module configurations. ### Method GET ### Endpoint /websites/pub_dev_air_framework/registeredModules ### Parameters #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **registeredModules** (List) - A list containing the configuration objects for all registered modules. #### Response Example ```json { "registeredModules": [ { "moduleName": "exampleModule", "version": "1.0.0", "entryPoint": "/modules/exampleModule/index.js" } ] } ``` ``` -------------------------------- ### GET /websites/pub_dev_air_framework/getEmittedSignals Source: https://pub.dev/documentation/air_framework/latest/framework_testing_testing/AirTestHarness/getEmittedSignals.html Retrieves a list of all emitted signals that match the provided signal name. ```APIDOC ## GET /websites/pub_dev_air_framework/getEmittedSignals ### Description Retrieves a list of all emitted signals that match the provided signal name. ### Method GET ### Endpoint /websites/pub_dev_air_framework/getEmittedSignals ### Parameters #### Query Parameters - **signalName** (String) - Required - The name of the signal to filter by. ### Request Example ``` GET /websites/pub_dev_air_framework/getEmittedSignals?signalName=mySignal ``` ### Response #### Success Response (200) - **data** (List) - A list of data associated with the emitted signals. #### Response Example ```json { "data": [ "data1", "data2" ] } ``` ```