I just started flutter, this is a basic question but I am not able to solve. I created a stateful widget and I need to call the setState() method on click of a button. The button is not part of this stateful widget. The button is present in the footer of application.
complete application code:
import 'package:flutter/material.dart'; void main() => runApp(new MyApp()); class MyApp extends StatelessWidget { @override build(BuildContext context) { return new MaterialApp( title: "My app title", home: new Scaffold( appBar: new AppBar( title: new Text("My App"), backgroundColor: Colors.amber, ), body: new Container( child: new Center( child: new MyStateFullWidget(), ), ), persistentFooterButtons: <Widget>[ new FlatButton( onPressed: () { // I need to call the update() of MyStateFullWidget/MyStateFullWidgetState class }, child: new Text("Click Here"), color: Colors.amber, textColor: Colors.white, ), ], )); } } class MyStateFullWidget extends StatefulWidget { @override State<StatefulWidget> createState() { return new MyStateFullWidgetState(); } } class MyStateFullWidgetState extends State<MyStateFullWidget> { int count = 0; @override Widget build(BuildContext context) { return new Text("Count: $count"); } update() { setState() { count++; } } }