Notes
Notes - notes.io |
import 'package:dino_run/components/my_button.dart';
import 'package:dino_run/models/food.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
class FoodPage extends StatefulWidget {
final Food food;
final Map<Addon, bool> selectedAddons = {};
FoodPage({
super.key,
required this.food,
}){
// initialize selected addons to be false
for (Addon addon in food.availableAddons) {
selectedAddons[addon] = false;
}
}
@override
State<FoodPage> createState() => _FoodPageState();
}
class _FoodPageState extends State<FoodPage> {
@override
Widget build(BuildContext context) {
return Stack(children: [
// scaffold UI
Scaffold(
body: SingleChildScrollView(
child: Column(
children: [
// food image
Image.asset(widget.food.imagePath),
Padding(
padding: const EdgeInsets.all(25.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// food name
Text(
widget.food.name,
style:const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20,
),
),
// food price
Text(
'$${widget.food.price}',
style: TextStyle(
fontSize: 16,
color: Theme.of(context).colorScheme.primary),
),
const SizedBox(height: 10),
// food description
Text(widget.food.description),
const SizedBox(height: 10),
Divider(color: Theme.of(context).colorScheme.secondary),
const SizedBox(height: 10),
//addons
Text(
"Add-ons",
style: TextStyle(
color: Theme.of(context).colorScheme.inversePrimary,
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 10),
Container(
decoration: BoxDecoration(
border: Border.all(
color: Theme.of(context).colorScheme.secondary),
borderRadius: BorderRadius.circular(8),
),
child: ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
padding: EdgeInsets.zero,
itemCount: widget.food.availableAddons.length,
itemBuilder: (context, index) {
//get individual addon
Addon addon = widget.food.availableAddons[index];
// return check box UI
return CheckboxListTile(
title: Text(addon.name),
subtitle: Text(
'$${addon.price}',
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
),
),
value: widget.selectedAddons[addon],
onChanged: (bool? value) {
setState(() {
widget.selectedAddons[addon] = value!;
});
},
);
},
),
)
],
),
),
// button -> add to cart
MyButton(
onTap: () {},
text: "Add to cart",
),
const SizedBox(height: 25),
],
),
),
),
// back button
SafeArea(
child: Opacity(
opacity: 0.6,
child: Container(
margin: const EdgeInsets.only(left: 25),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.secondary,
shape: BoxShape.circle,
),
child: IconButton(
icon: const Icon(Icons.arrow_back_ios_rounded),
onPressed: () => Navigator.pop(context),
),
),
),
),
],
);
}
}
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team