AsyncRoute class

Navigator's AsyncRoute.

AsyncRoute allows using async-await in page controllers which can be used to do deferred imports or build widgets that requires async computation.

Example:

import 'package:something/aPage.dart' deferred as aPage;

Navigator(
  routes: [
    // asynchronous route

    AsyncRoute(
      name: 'home',
      page: () async {
        await aPage.loadLibrary();

        return aPage.SomeWidget();
      }
    ),

    // synchronous route
    Route(name: 'profile', ...),

    // you can mix async routes with synchronous routes

    AsyncRoute(name: 'settings', ...),

    Route(name: 'info', ...),
  ]
)

See also:

  • Route, for synchronous routes.
Inheritance

Constructors

AsyncRoute({Key? key, String? errorRoute, String? waitingRoute, bool keepInitialBuilder = true, bool shouldRetryFailedBuilder = false, bool enableErrorHistory = false, bool enableWaitingHistory = false, Widget errorPlaceholderWidget = const _AsyncRoutePlaceholder(), Widget waitingPlaceholderWidget = const _AsyncRoutePlaceholder(), String? path, required String name, required AsyncOrSyncWidgetBuilder page})
Create AsyncRoute with name, and associate route with page builder.

Properties

builder AsyncOrSyncWidgetBuilder
Async Page builder.
final
child Widget
Child widget.
finalinherited
correspondingTag DomTagType
Corresponding HTML tag to use to render this widget
no setterinherited
enableErrorHistory bool
Whether to log error route in history.
final
enableWaitingHistory bool
Whether to log waiting route in history.
final
errorPlaceholderWidget Widget
Placeholder widget to show when page loading has failed.
final
errorRoute String?
Name of the route to open when page loading encounters an error.
final
hashCode int
The hash code for this object.
no setterinherited
keepInitialBuilder bool
Whether to rebind builder(page) on updates.
final
key Key?
Keys help Rad identify which widgets have changed, are added, or are removed when a widget has multiple sibling widgets.
finalinherited
name String
Name of the Route.
finalinherited
path String
Actual Route's path.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shouldRetryFailedBuilder bool
Whether to retry a failed page if user re-opens it.
final
waitingPlaceholderWidget Widget
Placeholder widget to show while page is loading.
final
waitingRoute String?
Name of the route to open while page is loading.
final
widgetCaptureEventListeners Map<DomEventType, EventCallback?>
Events that this widget is listening to in capturing phase.
no setterinherited
widgetEventListeners Map<DomEventType, EventCallback?>
Events that this widget is listening to in bubbling phase.
no setterinherited

Methods

createRenderElement(RenderElement parent) RenderElement
Create element for current widget.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
shouldUpdateWidget(Widget oldWidget) bool
Whether to update current widget.
inherited
shouldUpdateWidgetChildren(Widget oldWidget, bool shouldUpdateWidget) bool
Whether to update current widget's children.
inherited
toString() String
A string representation of this object.
inherited

Operators

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