Main Runapp: 'Package:Flutter/Material - Dart'
Main Runapp: 'Package:Flutter/Material - Dart'
dart';
void main() {
runApp(MaterialApp(
home: MyApp(),
));
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Student Form'),
),
body: ListView(
padding: EdgeInsets.all(16.0),
children: <Widget>[
_buildTextField(
controller: nameController,
label: 'Name',
hint: 'Enter your name',
),
SizedBox(height: 10),
_buildTextField(
controller: addressController,
label: 'Address',
hint: 'Enter your address',
),
SizedBox(height: 10),
_buildTextField(
controller: numberController,
label: 'Number',
hint: 'Enter your phone number',
),
SizedBox(height: 10),
_buildTextField(
controller: ageController,
label: 'Age',
hint: 'Enter your age',
),
SizedBox(height: 10),
_buildTextField(
controller: yearController,
label: 'Year',
hint: 'Enter your academic year',
),
SizedBox(height: 20),
ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => OutputPage(
name: nameController.text,
address: addressController.text,
number: numberController.text,
age: ageController.text,
year: yearController.text,
),
),
);
},
style: ElevatedButton.styleFrom(
primary: Colors.blue,
onPrimary: Colors.white,
),
child: Text('Submit'),
),
],
),
);
}
Widget _buildTextField({
required TextEditingController controller,
required String label,
required String hint,
}) {
return TextFormField(
controller: controller,
decoration: InputDecoration(
labelText: label,
hintText: hint,
border: OutlineInputBorder(),
),
);
}
}
OutputPage({
required this.name,
required this.address,
required this.number,
required this.age,
required this.year,
});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Output Page'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Name: $name',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
SizedBox(height: 10),
Text(
'Address: $address',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
SizedBox(height: 10),
Text(
'Number: $number',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
SizedBox(height: 10),
Text(
'Age: $age',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
SizedBox(height: 10),
Text(
'Year: $year',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
],
),
),
);
}
}