Class to Class Access Data


I have a problem with classes. I keep the user data in user_info_screen with Google auth. How can I pull this user data in a class that has this data on another page?

 class UserInfoScreen extends StatefulWidget {
   UserInfoScreen({Key key, User user})
      : _user = user,
        super(key: key);

  final User _user;

  _UserInfoScreenState createState() => _UserInfoScreenState();

class _UserInfoScreenState extends State<UserInfoScreen> {

  User _user;

The page I want to use (user) by pulling this data

class HomeView extends StatefulWidget {
  _HomeViewState createState() => _HomeViewState();

class _HomeViewState extends State<HomeView> {


Thank you.


A good way to handle it, espacially if you will use the user data on other pages, is to implement a store concept :


GetStorage box = GetStorage();
box.write('userData', _user);


GetStorage box = GetStorage();
User _user ='userData');

Or pass it as an argument

UserInfoScreen.dart => HomeView(), arguments: [
    {"userData": _user}


  dynamic argumentData = Get.arguments;

  void onInit() {

Answered By – BabC

Answer Checked By – Candace Johnson (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *