title: Changing theme using GetX
body: <p>I want to change the theme to <code>redTheme</code> only when I'm on a specific route. For that purpose, I've used <code>routingCallback</code> like</p>
  <pre><code>class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return GetMaterialApp(
        title: 'App',
        theme: defaultTheme(context),
        initialRoute: AppPages.INITIAL,
        getPages: AppPages.routes,
        routingCallback: (routing) =&gt; _routingCallback(context, routing),
      );
    }
  
    _routingCallback(BuildContext context, Routing routing) {
      if (routing.current == Routes.PURSUE_MODE) {
        _changeThemeIfNeeded(redTheme(context));
      } else {
        _changeThemeIfNeeded(defaultTheme(context));
      }
    }
  
    void _changeThemeIfNeeded(ThemeData theme) {
      Get.changeTheme(theme);
    }
  }
  </code></pre>
  <p>Unfortunately, it's causing</p>
  <blockquote>
  <p>════════ Exception caught by widgets library
  ═══════════════════════════════════════════════════════ setState() or
  markNeedsBuild() called during build. The relevant error-causing
  widget was:    Directionality
  file:///Users/jakub/.pub-cache/hosted/pub.dartlang.org/get_navigation-3.12.0/lib/src/root/root_widget.dart:235:22
  ════════════════════════════════════════════════════════════════════════════════════════════════════</p>
  </blockquote>
  <p>Because of that, I've wrapped theme changing in try-catch block, so I'm not getting exception at the start</p>
  <pre><code>  void _changeThemeIfNeeded(ThemeData theme) {
      try {
        if (Get.theme != theme) {
          Get.changeTheme(theme);
        }
      } catch (e) {
        print('Not ready e = $e');
      }
    }
  </code></pre>
  <p>But I believe there is more elegant approach to this problem using <code>Get</code> framework?</p>