toRoutes method

Map<String, WidgetBuilder> toRoutes({
  1. Map<String, WidgetBuilder>? otherRoutes,
})

Implementation

Map<String, WidgetBuilder> toRoutes({
  Map<String, WidgetBuilder>? otherRoutes,
}) {
  final Map<String, WidgetBuilder> result = {};
  for (final element in _route.entries) {
    result[element.key] = (context) {
      final RouteSettings routeSettings = () {
        try {
          final ModalRoute? modal = ModalRoute.of(context);
          if (modal != null) {
            return modal.settings;
          }
        } catch (e) {}
        return RouteSettings(name: element.key);
      }();
      return _build(
        child: element.value(
          context,
          RouteDataGeneralLibFlutter(
            routeName: routeSettings.name ?? element.key,
            arguments: routeSettings.arguments,
            context: context,
          ),
        ),
      );
    };
  }
  result.addAll(otherRoutes ?? {});
  return result;
}