To create a Stateful widget:
1. Create a StatefulWidget
2. Create a State
class SGreeting extends StatefulWidget {
@override
SGreetingState createState() => SGreetingState()
}
class SGreetingState extends State { String greeting = "Hello State"; void _toggleState () {
var next = greeting == "Hello State" ? "Hello World" : "Hello State";
setState(() {
greeting = next;
});
} @override
Widget build(BuildContext context) {
// TODO: implement build
return GestureDetector(
onTap: this._toggleState,
child: Text(
this.greeting,
style: TextStyle(
fontSize:
)
)
);
} }