0% found this document useful (0 votes)
276 views

Design Flutter UI For College ID Card

The document contains 3 sections describing how to design a Flutter UI for a college ID card, a student registration form, and a listview layout. The first section details how to create a Flutter app with a Scaffold containing an AppBar, CircleAvatar, text fields and rows to display student information such as name, hometown, academic year, and email on an ID card. The second section explains how to build a student registration form with a GlobalKey, Form, TextFormFields for name, email, mobile number, roll number and password with validation, and a submit button. The third section demonstrates creating a listview layout with a Scaffold, AppBar, ListView, and ProductBox

Uploaded by

Tanay jain
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
276 views

Design Flutter UI For College ID Card

The document contains 3 sections describing how to design a Flutter UI for a college ID card, a student registration form, and a listview layout. The first section details how to create a Flutter app with a Scaffold containing an AppBar, CircleAvatar, text fields and rows to display student information such as name, hometown, academic year, and email on an ID card. The second section explains how to build a student registration form with a GlobalKey, Form, TextFormFields for name, email, mobile number, roll number and password with validation, and a submit button. The third section demonstrates creating a listview layout with a Scaffold, AppBar, ListView, and ProductBox

Uploaded by

Tanay jain
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 23

1.

Design Flutter UI for college ID Card:-

import 'package:flutter/material.dart';

void main() => runApp(MaterialApp(


home: IdCard(),
));

class IdCard extends StatelessWidget {


@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey[900],
appBar: AppBar(
title: Text('TE-IT ID Card'),
centerTitle: true,
backgroundColor: Colors.grey[850],
elevation: 0.0,
),
body: Padding(
padding: const EdgeInsets.fromLTRB(30.0, 40.0, 30.0,
0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Center(
child: CircleAvatar(
radius: 40.0,
backgroundImage: AssetImage('thumb.jpg'),
),
),
Divider(
color: Colors.grey[800],
height: 60.0,
),
Text(
'NAME',
style: TextStyle(
color: Colors.grey,
letterSpacing: 2.0,
),
),
SizedBox(height: 10.0),
Text(
'Shrihan',
style: TextStyle(
color: Colors.amberAccent[200],
fontWeight: FontWeight.bold,
fontSize: 28.0,
letterSpacing: 2.0,
),
),
SizedBox(height: 30.0),
Text(
'HOMETOWN',
style: TextStyle(
color: Colors.grey,
letterSpacing: 2.0,
),
),
SizedBox(height: 10.0),
Text(
'Thane- India',
style: TextStyle(
color: Colors.amberAccent[200],
fontWeight: FontWeight.bold,
fontSize: 28.0,
letterSpacing: 2.0,
),
),
SizedBox(height: 30.0),
Text(
'Current Academic Year',
style: TextStyle(
color: Colors.grey,
letterSpacing: 2.0,
),
),
SizedBox(height: 10.0),
Text(
'2021-2022',
style: TextStyle(
color: Colors.amberAccent[200],
fontWeight: FontWeight.bold,
fontSize: 28.0,
letterSpacing: 2.0,
),
),
SizedBox(height: 30.0),
Row(
children: <Widget>[
Icon(
Icons.email,
color: Colors.grey[400],
),
SizedBox(width: 10.0),
Text(
'[email protected]',
style: TextStyle(
color: Colors.grey[400],
fontSize: 18.0,
letterSpacing: 1.0,
),
)
],
),
],
),
),
);
}
}
2. Design Student Registration Form in Flutter.
import 'package:flutter/material.dart';
void main() {
runApp(const MaterialApp(
home: MyForm(),
));
}
class MyForm extends StatefulWidget {
const MyForm({Key? key}) : super(key: key);

@override
State<StatefulWidget> createState() {
return MyFormState();
}
}
class MyFormState extends State<MyForm> {
final _myFormKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Student Registration Form"),
),
body: Container(
padding: const EdgeInsets.symmetric(vertical: 25.0,
horizontal: 25.0),
child: Form(
key: _myFormKey,
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(10.0),
child: TextFormField(
validator: (msg) {
if (msg!.isEmpty) {
return "Please enter name";
}
return null;
},
decoration: InputDecoration(labelText:
"Name", hintText: "Enter Your Name", border:
OutlineInputBorder(borderRadius:
BorderRadius.circular(10.0))),
),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: TextFormField(
validator: (msg) {
if (msg!.isEmpty) {
return "Please enter email";
}
return null;
},
decoration: InputDecoration(labelText:
"Email", hintText: "Enter Your Email", border:
OutlineInputBorder(borderRadius:
BorderRadius.circular(10.0))),
),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: TextFormField(
keyboardType: TextInputType.phone,
validator: (msg) {
if (msg!.isEmpty) {
return "Please enter Mobile Number";
}
if (msg!.length != 10) {
return "Please Enter Correct Digits";
}
return null;
},
decoration: InputDecoration(labelText:
"Mobile", hintText: "Enter Your Mobile No.", border:
OutlineInputBorder(borderRadius:
BorderRadius.circular(10.0))),
),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: TextFormField(
keyboardType: TextInputType.phone,
validator: (msg) {
if (msg!.isEmpty) {
return "Please enter Roll Number";
}
return null;
},
decoration: InputDecoration(labelText:
"Roll No.", hintText: "Enter Your Roll No.", border:
OutlineInputBorder(borderRadius:
BorderRadius.circular(10.0))),
),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: TextFormField(
validator: (msg) {
if (msg!.isEmpty) {
return "Please enter Password";
}
if (msg!.length < 8) {
return "Please Enter Correct
Password";
}
return null;
},
obscureText: true,
decoration: InputDecoration(labelText:
"Password", hintText: "Enter Your Password.", border:
OutlineInputBorder(borderRadius:
BorderRadius.circular(10.0))),
),
),
Container(
padding: const EdgeInsets.only(left:
150.0, top: 40.0),
child: ElevatedButton(
child: const Text('Submit'),
onPressed: () {
// It returns true if the form is
valid, otherwise returns false
if
(_myFormKey.currentState!.validate()) {
// If the form is valid, display a
Snackbar.
Scaffold.of(context)
.showSnackBar(const
SnackBar(content: Text('Data is in processing.')));
}
},
)),
],
)),
),

);
}
}

3. Design Listview Layout in Flutter.

import 'package:flutter/material.dart';

void main() => runApp(MyApp());


class MyApp extends StatelessWidget {

// It is the root widget of your application.

@override

Widget build(BuildContext context) {

return MaterialApp(

title: 'Flutter Demo Application',

theme: ThemeData(

primarySwatch: Colors.green,

),

home: MyHomePage(title: 'Complex layout example'),

);

class MyHomePage extends StatelessWidget {

MyHomePage({Key? key, required this.title}) : super(key: key);

final String title;

@override

Widget build(BuildContext context) {

return Scaffold(

appBar: AppBar(title: Text("Product List")),

body: ListView(

padding: const EdgeInsets.fromLTRB(3.0, 12.0, 3.0, 12.0),

children: <Widget>[

ProductBox(
name: "iPhone",

description: "iPhone is the top branded phone ever",

price: 55000,

image: "iphone.png"),

ProductBox(

name: "Android",

description: "Android is a very stylish phone",

price: 10000,

image: "android.png"),

ProductBox(

name: "Tablet",

description: "Tablet is a popular device for official meetings",

price: 25000,

image: "tablet.png"),

ProductBox(

name: "Laptop",

description: "Laptop is most famous electronic device",

price: 35000,

image: "laptop.png"),

ProductBox(

name: "Desktop",

description: "Desktop is most popular for regular use",

price: 10000,

image: "computer.png"),

],

));

}
}

class ProductBox extends StatelessWidget {

ProductBox(

{Key? key,

required this.name,

required this.description,

required this.price,

required this.image})

: super(key: key);

final String name;

final String description;

final int price;

final String image;

Widget build(BuildContext context) {

return Container(

padding: EdgeInsets.all(2),

height: 110,

child: Card(

child: Row(

mainAxisAlignment: MainAxisAlignment.spaceEvenly,

children: <Widget>[

Image.asset("assets/" + image),

Expanded(

child: Container(

padding: EdgeInsets.all(5),
child: Column(

mainAxisAlignment: MainAxisAlignment.spaceEvenly,

children: <Widget>[

Text(this.name,

style: TextStyle(fontWeight: FontWeight.bold)),

Text(this.description),

Text("Price: " + this.price.toString()),

],

)))

])));

}
4. Design Gridview Layout in Flutter.
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {


List<String> images = [
"https://picsum.photos/200/300.jpg",
"https://picsum.photos/200/300.jpg",
"https://picsum.photos/200/300.jpg",
"https://picsum.photos/200/300.jpg"
];

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text("Flutter GridView Demo"),
backgroundColor: Colors.red,
),
body: Container(
padding: EdgeInsets.all(12.0),
child: GridView.builder(
itemCount: images.length,
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2,
crossAxisSpacing: 4.0, mainAxisSpacing: 4.0),
itemBuilder: (BuildContext context, int index) {
return Image.network(images[index]);
},
)),
),
);
}
}

5. Design Flutter Ul to navigate between two screens.

Main.dart

import 'package:flutter/material.dart';

import 'mynavapp/detail.dart';

void main() {

runApp(MaterialApp(

home: MyNavigation(),

));

class MyNavigation extends StatefulWidget {


const MyNavigation({Key? key}) : super(key: key);

@override

State<StatefulWidget> createState() {

return _MyNavigation();

class _MyNavigation extends State<MyNavigation> {

@override

Widget build(BuildContext context) {

return Scaffold(

appBar: AppBar(

title: Text("Navigation Tutorail"),

),

body: Center(

child: RaisedButton(

child: Text("Click Here"),

onPressed: () {

Navigator.push(context, MaterialPageRoute(builder:
(context) => MyPageDetail()));

},

),

),
);

Details.dart

import 'package:flutter/material.dart';

class MyPageDetail extends StatelessWidget {


const MyPageDetail({Key? key}): super(key:key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Navigation Result"),
),
body: Center(
child: Column(
children: <Widget>[
Text("Navigation Page")
],
),
),
);
}
}

6. Design Product Description Layout. ( same as list view )


7. Design Employee Registration Form in Flutter.
import 'package:flutter/material.dart';

void main() {
runApp(const MaterialApp(
home: MyForm(),
));
}

class MyForm extends StatefulWidget {


const MyForm({Key? key}) : super(key: key);

@override
State<StatefulWidget> createState() {
return MyFormState();
}
}

class MyFormState extends State<MyForm> {


final _myFormKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Employee Registration Form"),
),
body: Container(
padding: const EdgeInsets.symmetric(vertical: 25.0,
horizontal: 25.0),
child: Form(
key: _myFormKey,
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(10.0),
child: TextFormField(
validator: (msg) {
if (msg!.isEmpty) {
return "Please enter name";
}
return null;
},
decoration: InputDecoration(labelText:
"Name", hintText: "Enter Your Name", border:
OutlineInputBorder(borderRadius:
BorderRadius.circular(10.0))),
),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: TextFormField(
validator: (msg) {
if (msg!.isEmpty) {
return "Please enter email";
}
return null;
},
decoration: InputDecoration(labelText:
"Email", hintText: "Enter Your Email", border:
OutlineInputBorder(borderRadius:
BorderRadius.circular(10.0))),
),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: TextFormField(
keyboardType: TextInputType.phone,
validator: (msg) {
if (msg!.isEmpty) {
return "Please enter Mobile Number";
}
if (msg!.length != 10) {
return "Please Enter Correct Digits";
}
return null;
},
decoration: InputDecoration(labelText:
"Mobile", hintText: "Enter Your Mobile No.", border:
OutlineInputBorder(borderRadius:
BorderRadius.circular(10.0))),
),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: TextFormField(
validator: (msg) {
if (msg!.isEmpty) {
return "Please enter Password";
}
if (msg!.length < 8) {
return "Please Enter Correct
Password";
}
return null;
},
obscureText: true,
decoration: InputDecoration(labelText:
"Password", hintText: "Enter Your Password.", border:
OutlineInputBorder(borderRadius:
BorderRadius.circular(10.0))),
),
),
Container(
padding: const EdgeInsets.only(left:
150.0, top: 40.0),
child: ElevatedButton(
child: const Text('Submit'),
onPressed: () {
// It returns true if the form is
valid, otherwise returns false
if
(_myFormKey.currentState!.validate()) {
// If the form is valid, display a
Snackbar.
Scaffold.of(context).showSnackBar(const SnackBar(content:
Text('Data is in processing.')));
}
},
)),
],
)),
),
);
}
}

8. Create flutter layout using any 7-8 widgets of flutter ( same as ID card )
9. Create Calculator using flutter.
10. a. Create Stateless Widget.
import 'package:flutter/material.dart';

void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {


@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text("Stateless Widget"),
),
body: Center(
child: Column(
children: [
TextButton(
onPressed: () {},
child: Text("Login"),
),
TextButton(
onPressed: () {},
child: Text("Register"),
)
],
),
),
),
);
}
}

b. Create Stateful Widget.


import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {


@override
_MyState createState() => _MyState();
}

class _MyState extends State<MyApp> {


Color _containerColor = Colors.yellow;

void changeColor() {
setState(() {
if (_containerColor == Colors.yellow) {
_containerColor = Colors.red;
return;
}
_containerColor = Colors.yellow;
});
}

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
appBar: AppBar(title: Text("A Simple App
Stateful Widget")),
body: Container(decoration:
BoxDecoration(color: _containerColor)),
floatingActionButton: FloatingActionButton(
onPressed: changeColor,
child: Icon(Icons.add),
tooltip: "Book Here",
),
));
}
}

11. Design Product Registration Form in Flutter.


import 'package:flutter/material.dart';

void main() {
runApp(const MaterialApp(
home: MyForm(),
));
}

class MyForm extends StatefulWidget {


const MyForm({Key? key}) : super(key: key);

@override
State<StatefulWidget> createState() {
return MyFormState();
}
}
class MyFormState extends State<MyForm> {
final _myFormKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Product Registration Form"),
),
body: Container(
padding: const EdgeInsets.symmetric(vertical: 25.0,
horizontal: 25.0),
child: Form(
key: _myFormKey,
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(10.0),
child: TextFormField(
validator: (msg) {
if (msg!.isEmpty) {
return "Please enter name";
}
return null;
},
decoration: InputDecoration(labelText:
"Product Name", hintText: "Enter Product Name", border:
OutlineInputBorder(borderRadius:
BorderRadius.circular(10.0))),
),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: TextFormField(
validator: (msg) {
if (msg!.isEmpty) {
return "Please enter Price";
}
return null;
},
decoration: InputDecoration(labelText:
"Price", hintText: "Enter Product Price", border:
OutlineInputBorder(borderRadius:
BorderRadius.circular(10.0))),
),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: TextFormField(
validator: (msg) {
if (msg!.isEmpty) {
return "Please enter Description";
}
return null;
},
decoration: InputDecoration(labelText:
"Description", hintText: "Enter Product Price", border:
OutlineInputBorder(borderRadius:
BorderRadius.circular(10.0))),
),
),
Container(
padding: const EdgeInsets.only(left:
150.0, top: 40.0),
child: ElevatedButton(
child: const Text('Submit'),
onPressed: () {
// It returns true if the form is
valid, otherwise returns false
if
(_myFormKey.currentState!.validate()) {
// If the form is valid, display a
Snackbar.
Scaffold.of(context).showSnackBar(const SnackBar(content:
Text('Data is in processing.')));
}
},
)),
],
)),
),
);
}
}

You might also like