I want to give back to the beginning of my code to load the code all over again or simply just connect it (showdialog) to the function that reload my widgets by clicking on a showdialog window?

void showWWWEndDialog() {
 showDialog(
  context: context,
  builder: (BuildContext context) {
    // return object of type Dialog
    return AlertDialog(
      title: new Text("Witcher Memory"),
      content: new Text("Brawo! Gra zakończona. Chcesz zacząć nową?"),
      actions: <Widget>[
        // usually buttons at the bottom of the dialog
        new FlatButton(
          child: new Text("Nie"),
          onPressed: () {
            Navigator.pop(context, "no");
          },
        ),
        new FlatButton(
          child: new Text("Tak"),
          onPressed: () {
            _restartGame = true;
            Navigator.pop(context, "yes");
            //
          },
        ),
      ],
    );
  },
);
}

void gameRestart() {
for(var i = 0; i < boardRowCount; i++)
  for(var j = 0; j < boardColumnCount; j++){
    boardState[i][j] = new PlayCard(i * boardColumnCount + j, getRandomAsset());
  }

}

1 Answers

0
CopsOnRoad On Best Solutions

If you are planning to go to the first Widget (page) of your app from any point in the app, you can try this. You also want to clear some reward if user does that before navigating to the HomePage.

Navigator.pushNamedAndRemoveUntil(context, "/homepage", (p) => false);