Stateful Widget in Flutter


Here is the simple program for printing the stateful widget in Flutter.


Source Code

import 'package:flutter/material.dart';
void main() {
  runApp(MyApp());
}
class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
  String value = 'Test';
  void clickMe() {
    setState(() {
      value = 'Tutor Joes';
    });
  }
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Column(
        children: <Widget>[
          Text("$value"),
          FloatingActionButton(
            child: Icon(Icons.add),
            onPressed: clickMe,
          )
        ],
      ),
    );
  }
}
To download raw file Click Here