title: flutter - change a variable from another class
body: <p>I would like when I press on the RawMaterialButton, the textField () class changes to the container () class and appears on the screen,
  with the code I have now when I press nothing happens ...</p>
  <p>can anyone fix it? Thank you.</p>
  <pre><code>
  void main() =&gt; runApp(mainApp());
  
  class mainApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        home: chat(),
      );
    }
  }
  
  class chat extends StatefulWidget {
    const chat({Key? key}) : super(key: key);
  
    @override
    _chatState createState() =&gt; _chatState();
  }
  
  class _chatState extends State&lt;chat&gt; {
    bool changeClass = false;
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        body: changeClass ? container() : textField(changeClass: changeClass),
      );
    }
  }
  
  class textField extends StatefulWidget {
    textField({Key? key, required this.changeClass}) : super(key: key);
  
    bool changeClass = false;
  
    @override
    _textFieldState createState() =&gt; _textFieldState();
  }
  
  class _textFieldState extends State&lt;textField&gt; {
    @override
    Widget build(BuildContext context) {
      return Center(
        child: Row(
          children: [
            Container(
              width: 300.0,
              height: 60.0,
              color: Colors.red,
            ),
            RawMaterialButton(
              onPressed: () {
                setState(() {
                  widget.changeClass = true;
                });
              },
              child: Icon(Icons.send),
            )
          ],
        ),
      );
    }
  }
  
  class container extends StatefulWidget {
    const container({Key? key}) : super(key: key);
  
    @override
    _containerState createState() =&gt; _containerState();
  }
  
  class _containerState extends State&lt;container&gt; {
    @override
    Widget build(BuildContext context) {
      return Center(
        child: Container(
          width: double.infinity,
          height: 60.0,
          color: Colors.grey,
        ),
      );
    }
  }
  
  </code></pre>
  <p>hope someone can help me.
  Thank you :)
  I write this piece because otherwise it won't let me upload itI write this piece because otherwise it won't let me upload itI write this piece because otherwise it won't let me upload it</p>