Browser class

The main widget for the Browser navigation system.

It acts as a wrapper around a root application widget (like WidgetsApp, MaterialApp, or CupertinoApp) and provides the necessary logic for route generation, observation, and management.

This widget should be placed at the root of your application. It provides the onGenerateRoute function and the RouteObserver to be used by your app widget.

Example:

void main() {
  runApp(
    Browser(
      routes: [...],
      defaultRoute: ...,
      builder: (context, routeObserver, generate) {
        // Use the provided parameters with your app widget
        return WidgetsApp(
          color: const Color(0xFFFFFFFF),
          onGenerateRoute: generate,
          navigatorObservers: [routeObserver],
          // ... other properties
        );
      },
    ),
  );
}
Inheritance

Constructors

Browser({required BrowserBuilder builder, required List<BrowserRoute> routes, required BrowserRoute defaultRoute, OnNavigation? onNavigation, RouteTransition adaptiveTransition(BrowserRoute route)?, TraceRoute? adaptiveTrace(String? name)?, Future<void> openUrl(Uri uri)?, Key? key})
Creates a Browser widget.
const

Properties

adaptiveTrace TraceRoute? Function(String? name)?
A function to determine the TraceRoute adaptively based on the route name.
final
adaptiveTransition RouteTransition Function(BrowserRoute route)?
A function to determine the RouteTransition adaptively.
final
builder BrowserBuilder
A builder for the main application widget.
final
defaultRoute BrowserRoute
The default BrowserRoute to navigate to when a specified route is not found or its arguments fail validation.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onNavigation OnNavigation?
An optional callback that is invoked on every navigation event. Useful for logging, analytics, or other side effects.
final
openUrl Future<void> Function(Uri uri)?
An optional function to handle external URL opening.
final
routes List<BrowserRoute>
A list of all BrowserRoutes available in the application. This list acts as the "route map" for the app.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
generate(RouteSettings settings) Route
The core route generation logic for the browser.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

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

Static Properties

routeObserver RouteObserver<ModalRoute<void>>
The central RouteObserver for the browser navigation stack.
final

Static Methods

dismissOverlay(BuildContext context) → void
Dismisses the currently visible overlay modal.
enqueueBanner(BuildContext context, ContentBuilder content, {double? topPadding}) → void
Enqueues a banner to be displayed by the OverlayManager.
showModalBottomSheet<T>({required BuildContext context, required WidgetBuilder builder, required Color backgroundColor, double heightFactor = 0.5, EdgeInsetsGeometry padding = const EdgeInsets.only(top: 19), AxisDirection animationDirection = AxisDirection.up, RouteSettings? routeSettings, bool isDismissible = true, Color? modalBarrierColor, bool enableDrag = true, bool useSafeAre = false, List<BoxShadow>? boxShadow}) Future<T?>
Shows a customizable modal bottom sheet.
showOverlay(BuildContext context, {required Widget builder(void dismiss()), required Color backgroundColor, required bool isDismissible, bool useSafeArea = false, Alignment builderAlignment = Alignment.center, OverlayTraceRoute? transitionParams}) → void
Shows a custom overlay modal.
watch({Key? key, void onDisappear(BuildContext context)?, void onAppear(BuildContext context, DeepLinkParam? deepLinkParam)?, Widget? child}) → SingleChildStatelessWidget
Provides a widget that can listen to page appearance and disappearance events.