0

According to this answer the build method gets called Route pop/push

My problem is that in my application there is a page that the build method gets called only once and thats when page is building for the first time but in my other pages every thing is fine and build method gets called several times e.g. when pop back from another page or push to a new page.

My code is like:

class ProjectDetailsPage extends StatefulWidget {
  final int Id;

  const ProjectDetailsPage({Key key, this.Id}) : super(key: key);

  @override
  _ProjectDetailsPageState createState() => _ProjectDetailsPageState();
}

class _ProjectDetailsPageState extends State<ProjectDetailsPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      Drawer: SlideDrawer(),
      appBar: LeadingAppBar(),
      body: FutureBuilder(
         future: _getProject(),
         builder: (context, snapshot) {
         ....
         }
      )
  );
}

So I want my page to rebuild whenever push/pop happens

Ali Izadyar
  • 140
  • 1
  • 2
  • 13

1 Answers1

0

Use the RouteAware mixin for your state and implement the didPush and didPopNext methods.

Pieter van Loon
  • 5,318
  • 1
  • 6
  • 15