title: Is there a way to dynamically state which flavor route files to import to deal with boilerplate code when making new flavors?
body: <p>One of our apps has quite a few Flutter flavors, where a router needs to be set up for each flavor in order to navigate around the app, as the individual router file will contain the correct imports to the views.</p>
  <p>For example, we might have MenuView that exists in</p>
  <p><code>views/flavor1/menu_view.dart</code></p>
  <p>and</p>
  <p><code>views/flavor2/menu_view.dart</code></p>
  <p>and <code>flavor_2_router.dart</code> would navigate to the <code>MenuView</code> as defined by the <code>import ../flavor2/_views.dart</code> statement.</p>
  <p>The problem is, when adding a new flavor, or a new view, it’s getting slightly cumbersome to copy and paste routes which are shared across all flavors.
  I’m essentially wondering if there’s a way to dynamically state which files to import (and thus get the classes from) or another type of design pattern that would help deal with this growing boilerplate code?</p>
  <p>Fragment of the router code:</p>
  <pre><code>// Flavor Specific Imports
  import 'package:mycompany/ui/flavors/flavor_1/views/_views.dart';
  
  Route&lt;dynamic&gt; generateRoute(RouteSettings settings) {
  
    switch (settings.name) {
      case AppUpgradeRoute:
        return _getPageRoute(
          routeName: settings.name,
          viewToShow: AppUpgradeView(),
        );
      case LoginRoute:
        return _getPageRoute(
          routeName: settings.name,
          viewToShow: LoginView(),
        );
      case StartUpRoute:
        var startupSettings = settings.arguments as StartupSettings;
        return _getPageRoute(
          routeName: settings.name,
          viewToShow: StartUpView(startupSettings: startupSettings),
        );  
      ...
  </code></pre>
  <p>Any suggestions?</p>