title: How do I access my inherited widget in a dart file that doesn't build a widget in the tree?
body: <p>I'm following <a href="https://flutterbyexample.com/lesson/inherited-widgets" rel="nofollow noreferrer">this example</a> to add my very first <code>InheritedWidget</code> into my app. I've created my <code>_state_container.dart</code> file and now want to use it.</p>
  <p>To start, I'd like to use it in the widget where I display the chats in a group chat. This widget is in the file <code>receivedChats.dart</code> (chat header). I see in the example that all I would need to do is instantiate the <code>container</code> in the target's widget build function, but the problem is that this widget is calling another file called <code>message_dao.dart</code> to handle all data from Firebase. This file doesn't have a widget build function, so how would I use the container here?</p>
  <p><strong>File Structure:</strong></p>
  <pre><code>main.dart
  |
  wrapper.dart
  |
  home.dart //or authenticate.dart if user is not logged in
  |
  chatScreen.dart
  |               |
  msgInput.dart   receivedChats.dart - message_dao.dart
  </code></pre>
  <p>This is what I've already tried, but it gives 2 errors:</p>
  <pre><code>class MessageDao {
  
    final container = StateContainer.of(context); //ERROR: Undefined name 'context'. 
    final chatState = container.chatState; //ERROR: The instance member 'container' can't be accessed in an initializer. 
  
    //...rest of code...//
  </code></pre>