user9819204
user9819204

Reputation:

I can't pass the other page with Flutter onPress

I want to go to the other page when I clicked with the code on the press, but it doesn't work.

 DialogButton(
      onPressed: () => FirstTab(),
      color: Color(0xff78328a),
      child: Text(
        "DAÜ'ye / To EMU",
        style: TextStyle(
            color: Colors.white, fontSize: 20, fontWeight: FontWeight.bold),
      ),
    ),

Upvotes: 0

Views: 65

Answers (2)

Mazin Ibrahim
Mazin Ibrahim

Reputation: 7889

You should modify your onPressed method into this :

  onPressed: () => Navigator.of(context).push(MaterialPageRoute(builder: (context) => FirstTab()));

Upvotes: 1

Harsha pulikollu
Harsha pulikollu

Reputation: 2436

You have use Navigator.push in order to move to next page like this in your onPressed

Navigator.push(context, new MaterialPageRoute(
                        builder: (BuildContext context) {
                          return new PageName();
                        }));

Upvotes: 0

Related Questions