0% found this document useful (0 votes)
7 views10 pages

MADexp 3 Code&Output

The document contains a Flutter application code for a student form, allowing users to input their personal details such as name, email, roll number, phone number, address, department, and gender. It includes form validation and a submit button that displays a success message upon submission. Additionally, it specifies project metadata, dependencies, and assets for the Flutter project.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views10 pages

MADexp 3 Code&Output

The document contains a Flutter application code for a student form, allowing users to input their personal details such as name, email, roll number, phone number, address, department, and gender. It includes form validation and a submit button that displays a success message upon submission. Additionally, it specifies project metadata, dependencies, and assets for the Flutter project.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

import 'package:flutter/material.

dart';

void main() {

runApp(StudentFormApp());

class StudentFormApp extends StatelessWidget {

@override

Widget build(BuildContext context) {

return MaterialApp(

debugShowCheckedModeBanner: false,

theme: ThemeData(primarySwatch: Colors.blue),

home: StudentForm(),

);

class StudentForm extends StatefulWidget {

@override

_StudentFormState createState() => _StudentFormState();

class _StudentFormState extends State<StudentForm> {

final _formKey = GlobalKey<FormState>();

String _name = '';

String _email = '';

String _rollNumber = '';

String _phone = '';


String _address = '';

String _department = 'Information Technology';

String _gender = 'Male';

final List<String> departments = [

'Computer Engineering',

'Information Technology',

'Electronics & Telecommunication',

'Mechanical Engineering',

'Civil Engineering',

];

void _submitForm() {

if (_formKey.currentState!.validate()) {

_formKey.currentState!.save();

ScaffoldMessenger.of(context).showSnackBar(

SnackBar(content: Text('Form Submitted Successfully')),

);

@override

Widget build(BuildContext context) {

return Scaffold(

appBar: AppBar(

title: Text('Bharati Vidyapeeth College of Engineering Form'),


),

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(

'Student Details Form',

style: TextStyle(

fontSize: 22,

fontWeight: FontWeight.bold,

color: Colors.blue,

),

),

SizedBox(height: 20),

TextFormField(

decoration: InputDecoration(
labelText: 'Name',

border: OutlineInputBorder(),

),

validator: (value) =>

value!.isEmpty ? 'Please enter your name' : null,

onSaved: (value) => _name = value!,

),

SizedBox(height: 10),

TextFormField(

decoration: InputDecoration(

labelText: 'Email',

border: OutlineInputBorder(),

),

keyboardType: TextInputType.emailAddress,

validator: (value) =>

value!.contains('@') ? null : 'Enter a valid email',

onSaved: (value) => _email = value!,

),

SizedBox(height: 10),

TextFormField(

decoration: InputDecoration(

labelText: 'Roll Number',

border: OutlineInputBorder(),

),

validator: (value) =>

value!.isEmpty ? 'Please enter your roll number' : null,


onSaved: (value) => _rollNumber = value!,

),

SizedBox(height: 10),

TextFormField(

decoration: InputDecoration(

labelText: 'Phone Number',

border: OutlineInputBorder(),

),

keyboardType: TextInputType.phone,

validator: (value) =>

value!.length == 10 ? null : 'Enter a valid phone number',

onSaved: (value) => _phone = value!,

),

SizedBox(height: 10),

TextFormField(

decoration: InputDecoration(

labelText: 'Address',

border: OutlineInputBorder(),

),

maxLines: 3,

validator: (value) =>

value!.isEmpty ? 'Please enter your address' : null,

onSaved: (value) => _address = value!,

),

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

description: A new Flutter project.

publish_to: 'none'

version: 1.0.0+1

environment:

sdk: ">=2.16.2 <3.0.0"


dependencies:

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:

- assets/images/background.jpg # Make sure it matches your image extension

You might also like