title: Flutter code, To add or display the widget on press button or set state on press method
body: <p>I am new to flutter and want to display the text widget after pressing the button.</p>
  
  <pre><code>   import 'package:flutter/material.dart';
  
      class dellecturer extends StatefulWidget {
        @override
        _dellecturerState createState() =&gt; _dellecturerState();
      }
  
      class _dellecturerState extends State&lt;dellecturer&gt; {
        @override
        Widget build(BuildContext context) {
          return Card(
            color: Colors.grey.shade300,
            margin: EdgeInsets.all(10.0),
          child: Container(
            margin: EdgeInsets.all(20),
            child: ListView(
              children: &lt;Widget&gt;[
               new Container(
                 margin: EdgeInsets.only(top:13,bottom: 25),
                 alignment: Alignment.topCenter,
                   child:Text("DELETE BY LECTURER ID",style: TextStyle(color: Colors.redAccent,fontWeight: FontWeight.bold,fontSize: 20.0),),
               ),
               new TextField(
                  decoration:InputDecoration(border: OutlineInputBorder(borderSide: BorderSide(style: BorderStyle.solid),),labelText: "LECTURER ID",hintText: "Enter lecturer ID",prefixIcon: Icon(Icons.person)),
                ),
                Padding(padding: EdgeInsets.only(top:20),),
               new RaisedButton(child: Text("OK",style: TextStyle(fontWeight: FontWeight.bold,color: Colors.white,fontSize: 15),),color: Colors.red,onPressed: (){Form(child: Search());},),//onclick search
              ],
            ),
  
  
          ),
          ); 
  
        }
      Widget Search(){  //should display
        setState(() {
        return Scaffold(
          body: Container(
          child: ListView(
            children: &lt;Widget&gt;[
              new Text("ID :1234",style: TextStyle(color: Colors.redAccent),),
               new Text("ID :1234",style: TextStyle(color: Colors.redAccent),),
                new Text("ID :1234",style: TextStyle(color: Colors.redAccent),),
            ],
          ),
          )
        );
        });
  
      }
      }
  </code></pre>