MADexp 3 Code&Output
MADexp 3 Code&Output
dart';
void main() {
runApp(StudentFormApp());
@override
return MaterialApp(
debugShowCheckedModeBanner: false,
home: StudentForm(),
);
@override
'Computer Engineering',
'Information Technology',
'Mechanical Engineering',
'Civil Engineering',
];
void _submitForm() {
if (_formKey.currentState!.validate()) {
_formKey.currentState!.save();
ScaffoldMessenger.of(context).showSnackBar(
);
@override
return Scaffold(
appBar: AppBar(
body: Padding(
padding: EdgeInsets.all(16.0),
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15),
),
elevation: 5,
child: Padding(
padding: EdgeInsets.all(16.0),
child: Form(
key: _formKey,
child: SingleChildScrollView(
child: Column(
children: [
Text(
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
color: Colors.blue,
),
),
SizedBox(height: 20),
TextFormField(
decoration: InputDecoration(
labelText: 'Name',
border: OutlineInputBorder(),
),
),
SizedBox(height: 10),
TextFormField(
decoration: InputDecoration(
labelText: 'Email',
border: OutlineInputBorder(),
),
keyboardType: TextInputType.emailAddress,
),
SizedBox(height: 10),
TextFormField(
decoration: InputDecoration(
border: OutlineInputBorder(),
),
),
SizedBox(height: 10),
TextFormField(
decoration: InputDecoration(
border: OutlineInputBorder(),
),
keyboardType: TextInputType.phone,
),
SizedBox(height: 10),
TextFormField(
decoration: InputDecoration(
labelText: 'Address',
border: OutlineInputBorder(),
),
maxLines: 3,
),
SizedBox(height: 10),
DropdownButtonFormField(
decoration: InputDecoration(
labelText: 'Department',
border: OutlineInputBorder(),
),
value: _department,
items: departments.map((dept) {
return DropdownMenuItem(
value: dept,
child: Text(dept),
);
}).toList(),
onChanged: (value) {
setState(() {
_department = value!;
});
},
),
SizedBox(height: 10),
Row(
children: [
Text('Gender: '),
Expanded(
child: RadioListTile(
title: Text('Male'),
value: 'Male',
groupValue: _gender,
onChanged: (value) {
setState(() {
_gender = value!;
});
},
),
),
Expanded(
child: RadioListTile(
title: Text('Female'),
value: 'Female',
groupValue: _gender,
onChanged: (value) {
setState(() {
_gender = value!;
});
},
),
),
],
),
SizedBox(height: 20),
ElevatedButton(
onPressed: _submitForm,
child: Text('Submit'),
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
padding: EdgeInsets.symmetric(
horizontal: 40,
vertical: 15,
),
),
),
],
),
),
),
),
),
),
);
name: testing_app
publish_to: 'none'
version: 1.0.0+1
environment:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^1.0.0
flutter:
uses-material-design: true
assets: