The problem

Android is developed with a mix of Flutter. When Android enters the same Flutter page for the second time, the page is not refreshed as it was the first time.

plan

For appeal issues, it is recommended that the Flutter page entered use the StatefulWidget component and rewrite the didUpdateWidget ().

class FlutterPage extends StatefulWidget {
  const FlutterPage({Key? key}) : super(key: key);

  @override
  _FlutterPageState createState(a) => _FlutterPageState();
}

class _FlutterPageState extends State<FlutterPage> {
  
  
  @override
  void didUpdateWidget(covariant FlutterPage oldWidget) {
    super.didUpdateWidget(oldWidget);
    // TODO:Perform a refresh, such as setState (), request data, and initialize the layout
  }
  
  @override
  Widget build(BuildContext context) {
    returnContainer(); }}Copy the code

Simple implementation as written in the appeal code, perform refresh operation in didUpdateWidget, setState(() {}), request API, initialize view, etc. You can also rewrite the didUpdateWidget () if page refreshes do not work during development. This is not limited to hybrid development, but also to pure Flutter development.