StatefulWidget simple Example

 import "package:flutter/material.dart";


void main() {
runApp(
const MaterialApp(
debugShowCheckedModeBanner: false,
title: "Simple Form",
home: SimpleForm(),
),
);
}

class SimpleForm extends StatefulWidget {
const SimpleForm({super.key});
@override
State<StatefulWidget> createState() {
return SimpleFormState();
}
}

class SimpleFormState extends State<SimpleForm> {
String name = "";

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Simple Form"),
),
body: Container(
margin: const EdgeInsets.all(30.0),
child: Column(
children: <Widget>[
TextField(
onSubmitted: (String userName) {
setState(() {
name = userName;
});
},
),
const Padding(
padding: EdgeInsets.all(20.0),
),
Text(
"My Name is $name",
style: const TextStyle(
fontSize: 25.0,
),
),
],
),
),
);
}
}

Comments

Popular posts from this blog

Second GET API Calling with Bloc simple Example in Flutter

Stack Container Scrollable Card widget UI with Custom Widget

Pagination with Bloc Pattern in Flutter