Skip to content

Instantly share code, notes, and snippets.

@vijayinyoutube
Created May 1, 2020 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vijayinyoutube/02e61bb62465d27c07a6e01c90117f35 to your computer and use it in GitHub Desktop.
Save vijayinyoutube/02e61bb62465d27c07a6e01c90117f35 to your computer and use it in GitHub Desktop.
Restaurant App Part-2
import 'package:flutter/material.dart';
int quantity = 1;
double total = 30.25;
class InfoPage extends StatefulWidget {
@override
_InforPageState createState() => _InforPageState();
}
class _InforPageState extends State<InfoPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
child: Column(
children: <Widget>[
Stack(
children: <Widget>[
ClipPath(
clipper: MyClipper(),
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10),
height: 300,
width: double.infinity,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment(0.8, 0.0),
colors: [
Colors.lightBlue[500],
Colors.lightBlueAccent[100],
],
tileMode: TileMode.repeated,
),
),
child: Column(
children: <Widget>[
Padding(
padding: EdgeInsets.only(top: 30),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"Italian Choco Cake",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 20),
),
Icon(
Icons.menu,
color: Colors.white,
),
],
),
),
itemCake(),
],
),
),
),
Padding(
padding: EdgeInsets.only(
left: ((MediaQuery.of(context).size.width - 175) / 2),
top: (MediaQuery.of(context).size.height+175) / 5),
child: Hero(
tag: "cakeitem",
child: ClipOval(
child: Container(
child: new Image.asset(
"assets/cake.jpg",
fit: BoxFit.cover,
width: 175,
height: 175,
),
),
),
),
),
],
),
SizedBox(
height: 25,
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 10),
child: Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"Quantity",
style: TextStyle(
fontWeight: FontWeight.normal, fontSize: 25),
),
Container(
decoration: new BoxDecoration(
color: Colors.blue[200],
borderRadius: new BorderRadius.circular(250),
),
width: 100,
height: 35,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
decoration: new BoxDecoration(
color: Colors.white,
borderRadius: new BorderRadius.circular(250),
),
child: GestureDetector(
onTap: remove,
child: Icon(
Icons.remove,
color: Colors.red,
),
),
),
Text(
"$quantity",
style: TextStyle(
//color: Colors.black,
fontWeight: FontWeight.normal,
fontSize: 18),
),
Container(
decoration: new BoxDecoration(
color: Colors.white,
borderRadius: new BorderRadius.circular(250),
),
child: GestureDetector(
onTap: add,
child: Icon(
Icons.add,
color: Colors.green,
),
),
),
],
),
),
)
],
),
SizedBox(
height: 10,
),
Text("Total amount"),
SizedBox(
height: 10,
),
Text("\$$total"),
SizedBox(
height: 20,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Container(
height: 40,
width: MediaQuery.of(context).size.width * 0.5,
child: RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)),
color: Colors.blue[400],
child: Text("Place Order",
style:
TextStyle(color: Colors.white, fontSize: 22)),
onPressed: () {},
),
),
],
)
],
),
),
],
),
),
);
}
void add() {
setState(() {
quantity = quantity + 1;
total = 30.25 * quantity;
});
}
void remove() {
setState(() {
if (quantity > 1) {
quantity = quantity - 1;
total = 30.25 * quantity;
}
});
}
}
class MyClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
var path = Path();
path.lineTo(0, size.height / 1.3);
path.quadraticBezierTo(
size.width / 2, size.height, size.width, size.height /1.3);
path.lineTo(size.width, 0);
path.close();
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) {
return false;
}
}
Widget itemCake() {
return Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(
height: 15,
),
Text(
"Dark Belgium chocolate",
style: TextStyle(
fontWeight: FontWeight.normal, fontSize: 15, color: Colors.white),
),
SizedBox(
height: 15,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
children: <Widget>[
SizedBox(
width: 5,
),
Container(
width: 50,
decoration: BoxDecoration(
color: Colors.lightBlue[100],
borderRadius: BorderRadius.circular(10),
),
alignment: Alignment.center,
child: Text(
"Cold",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15),
),
),
SizedBox(
width: 5,
),
Container(
width: 50,
decoration: BoxDecoration(
color: Colors.red[100],
borderRadius: BorderRadius.circular(10),
),
alignment: Alignment.center,
child: Text(
"Fresh",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15),
),
),
],
),
Column(
children: <Widget>[
Text(
"\$30.25",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 30,
color: Colors.black54),
),
Text(
"per Quantity",
style: TextStyle(
fontWeight: FontWeight.normal,
fontSize: 10,
color: Colors.black),
)
],
)
],
),
SizedBox(
height: 15,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
SizedBox(
width: 5,
),
Icon(Icons.star, size: 15, color: Colors.orangeAccent),
Icon(Icons.star, size: 15, color: Colors.orangeAccent),
Icon(Icons.star, size: 15, color: Colors.orangeAccent),
Icon(Icons.star, size: 15, color: Colors.orangeAccent),
Icon(Icons.star, size: 15, color: Colors.orangeAccent),
],
),
],
),
);
}
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'info.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]);
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData.light(),
home: MyPage(),
);
}
}
class MyPage extends StatefulWidget {
@override
_MyPageState createState() => _MyPageState();
}
class _MyPageState extends State<MyPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Restaurant"),
),
body: Padding(
padding: EdgeInsets.all(5),
child: ListView(
scrollDirection: Axis.vertical,
children: <Widget>[
Hero(
tag: "cakeitem",
child: FittedBox(
child: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => InfoPage()),
);
},
child: Card(
// color: Colors.red,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
elevation: 5,
child: Row(
children: <Widget>[
itemcake(),
Container(
width: 90,
height: 100,
child: ClipRRect(
borderRadius: BorderRadius.circular(15.0),
child: Image(
fit: BoxFit.cover,
alignment: Alignment.topRight,
image: AssetImage('assets/cake.jpg'),
),
),
),
],
),
),
),
),
),
FittedBox(
child: Card(
// color: Colors.red,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
elevation: 5,
child: Row(
children: <Widget>[
juiceitem(),
Container(
width: 90,
height: 100,
child: ClipRRect(
borderRadius: BorderRadius.circular(15.0),
child: Image(
fit: BoxFit.cover,
alignment: Alignment.topRight,
image: AssetImage('assets/juice.jpg'),
),
),
),
],
),
),
),
FittedBox(
child: Card(
// color: Colors.red,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
elevation: 5,
child: Row(
children: <Widget>[
pizzaitem(),
Container(
width: 90,
height: 100,
child: ClipRRect(
borderRadius: BorderRadius.circular(15.0),
child: Image(
fit: BoxFit.cover,
alignment: Alignment.topRight,
image: AssetImage('assets/pizza.jpg'),
),
),
),
],
),
),
),
FittedBox(
child: Card(
// color: Colors.red,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
elevation: 5,
child: Row(
children: <Widget>[
eliteitem(),
Container(
width: 90,
height: 100,
child: ClipRRect(
borderRadius: BorderRadius.circular(15.0),
child: Image(
fit: BoxFit.cover,
alignment: Alignment.topRight,
image: AssetImage('assets/elite.jpg'),
),
),
),
],
),
),
),
],
),
),
);
}
Widget itemcake() {
return Container(
//width: 150,
child: Column(
//mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Padding(
padding: EdgeInsets.symmetric(horizontal: 5),
child: Text(
"Italian Choco Cake",
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 15, color: Colors.red),
),
),
SizedBox(
height: 5,
),
Text(
"Dark belgium chocolate",
style: TextStyle(
fontWeight: FontWeight.normal,
fontSize: 9.5,
color: Colors.grey),
),
SizedBox(
height: 5,
),
Row(
children: <Widget>[
Icon(
Icons.shopping_cart,
size: 15,
),
SizedBox(
width: 5,
),
Container(
width: 35,
decoration: BoxDecoration(
color: Colors.lightBlue[100],
//color: Theme.of(context).accentColor,
borderRadius: BorderRadius.circular(10),
),
alignment: Alignment.center,
child: Text(
"Cold",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 9.5),
),
),
SizedBox(
width: 5,
),
Container(
width: 35,
decoration: BoxDecoration(
color: Colors.red[100],
//color: Theme.of(context).accentColor,
borderRadius: BorderRadius.circular(10),
),
alignment: Alignment.center,
child: Text(
"Fresh",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 9.5),
),
),
],
),
SizedBox(
height: 5,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Text(
"Ratings",
style: TextStyle(
fontWeight: FontWeight.normal,
fontSize: 7,
color: Colors.grey),
),
SizedBox(
width: 10,
),
Icon(
Icons.star,
size: 10,
color: Colors.orangeAccent,
),
Icon(
Icons.star,
size: 10,
color: Colors.orangeAccent,
),
Icon(
Icons.star,
size: 10,
color: Colors.orangeAccent,
),
Icon(
Icons.star,
size: 10,
color: Colors.orangeAccent,
),
],
),
],
),
);
}
Widget juiceitem() {
return Container(
//width: 150,
child: Column(
//mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Padding(
padding: EdgeInsets.symmetric(horizontal: 5),
child: Text(
"Fresh Mango Juice",
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 15, color: Colors.red),
),
),
SizedBox(
height: 5,
),
Text(
"Dark belgium chocolate",
style: TextStyle(
fontWeight: FontWeight.normal,
fontSize: 9.5,
color: Colors.grey),
),
SizedBox(
height: 5,
),
Row(
children: <Widget>[
Icon(
Icons.shopping_cart,
size: 15,
),
SizedBox(
width: 5,
),
Container(
width: 35,
decoration: BoxDecoration(
color: Colors.lightBlue[100],
//color: Theme.of(context).accentColor,
borderRadius: BorderRadius.circular(10),
),
alignment: Alignment.center,
child: Text(
"Cold",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 9.5),
),
),
SizedBox(
width: 5,
),
Container(
width: 35,
decoration: BoxDecoration(
color: Colors.red[100],
//color: Theme.of(context).accentColor,
borderRadius: BorderRadius.circular(10),
),
alignment: Alignment.center,
child: Text(
"Fresh",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 9.5),
),
),
SizedBox(
width: 5,
),
Container(
width: 35,
decoration: BoxDecoration(
color: Colors.yellow[400],
//color: Theme.of(context).accentColor,
borderRadius: BorderRadius.circular(10),
),
alignment: Alignment.center,
child: Text(
"New",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 9.5),
),
),
],
),
SizedBox(
height: 5,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Text(
"Ratings",
style: TextStyle(
fontWeight: FontWeight.normal,
fontSize: 7,
color: Colors.grey),
),
SizedBox(
width: 10,
),
Icon(
Icons.star,
size: 10,
color: Colors.orangeAccent,
),
Icon(
Icons.star,
size: 10,
color: Colors.orangeAccent,
),
Icon(
Icons.star,
size: 10,
color: Colors.orangeAccent,
),
Icon(
Icons.star,
size: 10,
color: Colors.orangeAccent,
),
Icon(
Icons.star,
size: 10,
color: Colors.orangeAccent,
),
],
),
],
),
);
}
Widget pizzaitem() {
return Container(
//width: 150,
child: Column(
//mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Padding(
padding: EdgeInsets.symmetric(horizontal: 5),
child: Text(
"Cheese Pizza Italy ",
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 15, color: Colors.red),
),
),
SizedBox(
height: 5,
),
Text(
"Double cheese New York Style",
style: TextStyle(
fontWeight: FontWeight.normal,
fontSize: 9.5,
color: Colors.grey),
),
SizedBox(
height: 5,
),
Row(
children: <Widget>[
Icon(
Icons.shopping_cart,
size: 15,
),
SizedBox(
width: 5,
),
Container(
width: 35,
decoration: BoxDecoration(
color: Colors.deepOrange[300],
//color: Theme.of(context).accentColor,
borderRadius: BorderRadius.circular(10),
),
alignment: Alignment.center,
child: Text(
"Spicy",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 9.5),
),
),
SizedBox(
width: 5,
),
Container(
width: 35,
decoration: BoxDecoration(
color: Colors.yellow[400],
//color: Theme.of(context).accentColor,
borderRadius: BorderRadius.circular(10),
),
alignment: Alignment.center,
child: Text(
"New",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 9.5),
),
),
],
),
SizedBox(
height: 5,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Text(
"Ratings",
style: TextStyle(
fontWeight: FontWeight.normal,
fontSize: 7,
color: Colors.grey),
),
SizedBox(
width: 10,
),
Icon(
Icons.star,
size: 10,
color: Colors.orangeAccent,
),
Icon(
Icons.star,
size: 10,
color: Colors.orangeAccent,
),
Icon(
Icons.star,
size: 10,
color: Colors.orangeAccent,
),
Icon(
Icons.star,
size: 10,
color: Colors.orangeAccent,
),
Icon(
Icons.star,
size: 10,
color: Colors.orangeAccent,
),
],
),
],
),
);
}
Widget eliteitem() {
return Container(
//width: 150,
child: Column(
//mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Padding(
padding: EdgeInsets.symmetric(horizontal: 5),
child: Text(
"Alinea Chicago",
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 15, color: Colors.red),
),
),
SizedBox(
height: 5,
),
Text(
"Classical French cooking",
style: TextStyle(
fontWeight: FontWeight.normal,
fontSize: 9.5,
color: Colors.grey),
),
SizedBox(
height: 5,
),
Row(
children: <Widget>[
Icon(
Icons.shopping_cart,
size: 15,
),
SizedBox(
width: 5,
),
Container(
width: 35,
decoration: BoxDecoration(
color: Colors.deepOrange[300],
//color: Theme.of(context).accentColor,
borderRadius: BorderRadius.circular(10),
),
alignment: Alignment.center,
child: Text(
"Spicy",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 9.5),
),
),
SizedBox(
width: 5,
),
Container(
width: 35,
decoration: BoxDecoration(
color: Colors.red,
//color: Theme.of(context).accentColor,
borderRadius: BorderRadius.circular(10),
),
alignment: Alignment.center,
child: Text(
"Hot",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 9.5,
color: Colors.white),
),
),
SizedBox(
width: 5,
),
Container(
width: 35,
decoration: BoxDecoration(
color: Colors.yellow[400],
//color: Theme.of(context).accentColor,
borderRadius: BorderRadius.circular(10),
),
alignment: Alignment.center,
child: Text(
"New",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 9.5,
),
),
),
],
),
SizedBox(
height: 5,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Text(
"Ratings",
style: TextStyle(
fontWeight: FontWeight.normal,
fontSize: 7,
color: Colors.grey),
),
SizedBox(
width: 10,
),
Icon(
Icons.star,
size: 10,
color: Colors.orangeAccent,
),
Icon(
Icons.star,
size: 10,
color: Colors.orangeAccent,
),
Icon(
Icons.star,
size: 10,
color: Colors.orangeAccent,
),
],
),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment