FeatureRoute constructor

FeatureRoute({
  1. required String description,
  2. Map<String, dynamic> parameters = const {},
  3. required String path,
  4. required Widget builder(
    1. BuildContext,
    2. GoRouterState
    ),
  5. required String? name,
  6. bool includeChat = true,
  7. GoRouterPageBuilder? pageBuilder,
  8. GoRouterRedirect? redirect,
  9. List<RouteBase> routes = const <RouteBase>[],
  10. Map<String, Map<String, dynamic>> extras = const {},
})

Implementation

FeatureRoute({
  required this.description,
  this.parameters = const {},
  required super.path,
  required Widget Function(BuildContext, GoRouterState) builder,
  required super.name,
  this.includeChat = true,
  super.pageBuilder,
  super.redirect,
  super.routes = const <RouteBase>[],
  this.extras = const {},
}) : super(
        builder: (context, state) {
          final child = builder(context, state);
          final settings = FeatureSettings();

          if (includeChat && settings.aiApiKey != null) {
            return Stack(
              children: [
                child,
                Positioned(
                  right: 24.0,
                  bottom: 40.0,
                  child: FloatingActionButton(
                    onPressed: () {
                      Navigator.push(
                        context,
                        MaterialPageRoute(
                            builder: (context) => const ChatPage()),
                      );
                    },
                    child: const Icon(Icons.chat),
                  ),
                ),
              ],
            );
          }
          return child;
        },
      ) {
  // Add this route to the global list of all routes
  _allRoutes.add(this);
}