Is it possible to use Getx State Management in one part but not to use in other part of a Flutter App?

Viewed 82

So,I and my friend are making an app.My friend does the main page and I do the profile page. In main page my friend didn't use any state management method but I used 'Getx' in profile page.So how can we go to profile page by clicking some button in the main page?Or is it possible?

1 Answers

It is possible but not recommended.

As your problem: you can navigate from your main page to the profile page:

ElevatedButton(
 ....
 onPressed:(){
        Navigator.push(
        context,
        MaterialPageRoute(builder: (context) => ProfilePage()),
      );
 }

And you need to do the following on your profile page:

class ProfilePage extends StatelessWidget {
      ProfilePage({Key? key}) : super(key: key) {
       controller = Get.put(ProfileController());
      }

    late final ProfileController controller;

 .......
}
Related