title: Widget cannot be marked as needing to build because the framework is already in the process of building widgets
body: <p>I'm trying to implement Provider and it seems it works fine but I get this message:</p>
  
  <blockquote>
    <p>This _DefaultInheritedProviderScope widget cannot be
    marked as needing to build because the framework is already in the
    process of building widgets.  A widget can be marked as needing to be
    built during the build phase only if one of its ancestors is currently
    building. This exception is allowed because the framework builds
    parent widgets before children, which means a dirty descendant will
    always be built. Otherwise, the framework might not visit this widget
    during this build phase. The widget on which setState() or
    markNeedsBuild() was called was:
    _DefaultInheritedProviderScope   value: Instance of 'UserProfile'   listening to value The widget which was currently
    being built when the offending call was made was: FutureBuilder 
    dirty   state: _FutureBuilderState#bf6ec When the exception was
    thrown, this was the stack: </p>
    
    <h1>0      Element.markNeedsBuild. (package:flutter/src/widgets/framework.dart:3896:11)</h1>
    
    <h1>1      Element.markNeedsBuild (package:flutter/src/widgets/framework.dart:3911:6)</h1>
    
    <h1>2      _InheritedProviderScopeMixin.markNeedsNotifyDependents (package:provider/src/inherited_provider.dart:268:5)</h1>
    
    <h1>3      ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:206:21)</h1>
    
    <h1>4      UserProfile.user= (package:mdd/core/services/user_info.dart:13:5) ... The UserProfile</h1>
    
    <p>sending notification was: Instance of 'UserProfile'</p>
  </blockquote>
  
  <p>My code is the following:</p>
  
  <pre><code>class HomePage extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      final authService = Provider.of&lt;AuthService&gt;(context);
      final userProfile =    Provider.of&lt;UserProfile&gt;(context);
  
      return StatefulWrapper(
        onInit: () {
          FirebaseNotifications().setUpFirebase();
        },
        child: FutureBuilder&lt;User&gt;(
          future: authService.getUser(),
          builder: (context, AsyncSnapshot&lt;User&gt; snapshot) {
            if (snapshot.connectionState == ConnectionState.done) {
              if (snapshot.error != null) {
                return Text(snapshot.error.toString());
              }
              userProfile.user = snapshot.data;
             // FirebaseUser user = snapshot.data;
  
              return snapshot.hasData ? ListScreen() : LoginScreen();
            } else {
              return Scaffold(
                appBar: AppBar(),
                body: Container(),
              );
            }
          },
        )
      );
    }
  }
  </code></pre>
  
  <p>And this is the UserProfile class:</p>
  
  <pre><code>class UserProfile with ChangeNotifier {
    User _user = User();
  
    get user {
      return _user;
    }
  
    set user(User user) {
      this._user = user;
      notifyListeners();
    }
  }
  </code></pre>
  
  <p>and the part of the AuthService used to fetch the profile:</p>
  
  <pre><code>Future&lt;User&gt; getUser() async {
    print('GETTING THE USER');
    final fbaseUser = await _auth.currentUser();
    final snapshot = await _db.collection('users')
        .document(fbaseUser.uid)
        .get();
    if (snapshot.data != null) {
      Map&lt;dynamic, dynamic&gt; jsres = snapshot.data;
      _user = User.fromJson(jsres);
      return _user;
    }
  }
  </code></pre>
  
  <p>Why am I getting this error? What am I doing wrong? Can anyone help me with this, please?</p>