Design Flutter UI For College ID Card
Design Flutter UI For College ID Card
import 'package:flutter/material.dart';
@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.')));
}
},
)),
],
)),
),
);
}
}
import 'package:flutter/material.dart';
@override
return MaterialApp(
theme: ThemeData(
primarySwatch: Colors.green,
),
);
@override
return Scaffold(
body: ListView(
children: <Widget>[
ProductBox(
name: "iPhone",
price: 55000,
image: "iphone.png"),
ProductBox(
name: "Android",
price: 10000,
image: "android.png"),
ProductBox(
name: "Tablet",
price: 25000,
image: "tablet.png"),
ProductBox(
name: "Laptop",
price: 35000,
image: "laptop.png"),
ProductBox(
name: "Desktop",
price: 10000,
image: "computer.png"),
],
));
}
}
ProductBox(
{Key? key,
required this.name,
required this.description,
required this.price,
required this.image})
: super(key: key);
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,
Text(this.description),
],
)))
])));
}
4. Design Gridview Layout in Flutter.
import 'package:flutter/material.dart';
@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]);
},
)),
),
);
}
}
Main.dart
import 'package:flutter/material.dart';
import 'mynavapp/detail.dart';
void main() {
runApp(MaterialApp(
home: MyNavigation(),
));
@override
State<StatefulWidget> createState() {
return _MyNavigation();
@override
return Scaffold(
appBar: AppBar(
),
body: Center(
child: RaisedButton(
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder:
(context) => MyPageDetail()));
},
),
),
);
Details.dart
import 'package:flutter/material.dart';
void main() {
runApp(const MaterialApp(
home: MyForm(),
));
}
@override
State<StatefulWidget> createState() {
return MyFormState();
}
}
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());
}
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",
),
));
}
}
void main() {
runApp(const MaterialApp(
home: MyForm(),
));
}
@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.')));
}
},
)),
],
)),
),
);
}
}