title: Flutter : sending data across multiple screens
body: <p>I have 3 Widget <code>MyApp Widget</code> ,<code>Home Widget</code>, and <code>Sliver Appbar Widget</code>, It's connected to each other. Example <strong>MyApp Widget</strong> -> <strong>Home Widget</strong> -> <strong>SliverAppbar Widget</strong>.
  <p> My question is , how to Passing data from <strong>My App Widget</strong> directly to <strong>SliverAppBar Widget</strong> ? </p>
  
  <p><a href="https://i.stack.imgur.com/3VZh6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3VZh6.png" alt="enter image description here"></a></p>
  
  <p><p> I found what i think it's can solve my case that is <a href="https://api.flutter.dev/flutter/widgets/InheritedWidget-class.html" rel="nofollow noreferrer">Inherited Widget</a>. But i confused to understading to use this widget.</p>
  
  <p>I already try using Inherited Widget as documentation like this : </p>
  
  <h2>MyApp Widget</h2>
  
  <pre><code>class SettingsApp extends InheritedWidget {
    SettingsApp({Key key, this.isDarkMode = false, Widget child})
        : super(key: key, child: child);
  
    final bool isDarkMode;
  
    static SettingsApp of(BuildContext context) {
      return (context.dependOnInheritedWidgetOfExactType&lt;SettingsApp&gt;());
    }
  
    @override
    bool updateShouldNotify(SettingsApp oldWidget) {
      return true;
    }
  }
  
  </code></pre>
  
  <h2>SliverAppBar Widget</h2>
  
  <pre><code>class SliverAppBarCustom extends StatelessWidget {
    final Box detbBox = Hive.box("debt_box");
    final UserModelHive userModelHive = Hive.box("user_box").get("userSession");
    @override
    Widget build(BuildContext context) {
      final isDarkMode =
          context.dependOnInheritedWidgetOfExactType&lt;SettingsApp&gt;().isDarkMode;
      print(isDarkMode.toString());
      var mediaQuery = MediaQuery.of(context);
      var textTheme = Theme.of(context).textTheme;
       return Text(isDarkMode.toString());
    }
  }
  
  </code></pre>
  
  <p>But i get this error : </p>
  
  <h2>Log</h2>
  
  <pre><code>The following NoSuchMethodError was thrown building SliverAppBarCustom(dirty):
  The getter 'isDarkMode' was called on null.
  Receiver: null
  Tried calling: isDarkMode
  
  </code></pre>