Flutter Set State onPressed on RaisedButton
you can implement using setState method.
i implement something like that just go through that.
import 'package:flutter/material.dart'; void main() { runApp(MaterialApp( title: 'Demo', initialRoute: '/', routes: { '/': (context) => FirstScreen(), '/second': (context) => SecondScreen(), }, )); } class FirstScreen extends StatefulWidget { @override _FirstScreenState createState() => _FirstScreenState(); } class _FirstScreenState extends State<FirstScreen> { int submit = 0; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Demo"), ), body: new Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Row( children: <Widget>[ new RaisedButton( padding: const EdgeInsets.all(10.0), child: const Text('Next Question'), color: submit == 0 ? Color(0xFFE9E9E9) : Colors.grey, elevation: 0.0, onPressed: () { submit == 0 ? null : Navigator.push( context, MaterialPageRoute(builder: (context) => SecondScreen()), ); } ), new RaisedButton( padding: const EdgeInsets.all(10.0), child: const Text('Submit Answer'), color: Color(0xFFE08284), elevation: 0.0, onPressed: () { setState(() { submit = 1; }); }, ), ], ), submit == 1 ? new Container( child: new Text("hello World"), ) : new Container() ], ) ); } } class SecondScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Second Screen"), ), body: Center( child: RaisedButton( onPressed: () { Navigator.pop(context); }, child: Text('Go back!'), ), ), ); } }