Certainly! Below is a simple example of a Flutter code for a food delivery app's home screen UI. This example includes a top navigation bar, a search bar, category buttons, and a list of popular dishes.
dart Copy code
import 'package:flutter/material.dart';
void main() {
runApp(FoodDeliveryApp());
}
class FoodDeliveryApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Food Delivery',
theme: ThemeData(
primarySwatch: Colors.orange,
),
home: HomeScreen(),
);
}
}
class HomeScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Food Delivery'),
actions: [
IconButton(
icon: Icon(Icons.notifications),
onPressed: () {},
),
],
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: ListView(
children: [
// Search Bar
TextField(
decoration: InputDecoration(
hintText: 'Search for restaurants or dishes',
prefixIcon: Icon(Icons.search),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
),
),
),
SizedBox(height: 20),
// Categories
Text(
'Categories',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
SizedBox(height: 10),
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: [
CategoryButton('Pizza'),
CategoryButton('Burgers'),
CategoryButton('Salads'),
CategoryButton('Desserts'),
],
),
),
SizedBox(height: 20),
// Popular Dishes
Text(
'Popular Dishes',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
SizedBox(height: 10),
PopularDishesList(),
],
),
),
);
}
}
class CategoryButton extends StatelessWidget {
final String category;
CategoryButton(this.category);
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(right: 10),
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
decoration: BoxDecoration(
color: Colors.orange.shade100,
borderRadius: BorderRadius.circular(20),
),
child: Text(
category,
style: TextStyle(fontSize: 18, color: Colors.orange.shade800),
),
);
}
}
class PopularDishesList extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
children: [
PopularDish(
name: 'Margherita Pizza',
image: 'assets/pizza.jpg',
price: 12.99,
),
PopularDish(
name: 'Cheeseburger',
image: 'assets/burger.jpg',
price: 8.99,
),
PopularDish(
name: 'Caesar Salad',
image: 'assets/salad.jpg',
price: 6.99,
),
],
);
}
}
class PopularDish extends StatelessWidget {
final String name;
final String image;
final double price;
PopularDish({required this.name, required this.image, required this.price});
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.symmetric(vertical: 10),
child: Row(
children: [
Image.asset(
image,
width: 100,
height: 100,
fit: BoxFit.cover,
),
SizedBox(width: 20),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
name,
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
Text(
'\$${price.toStringAsFixed(2)}',
style: TextStyle(fontSize: 16, color: Colors.orange),
),
],
),
],
),
);
}
}
This code provides a basic structure for a food delivery app's home screen. You can further enhance it by adding more features like user authentication, detailed dish pages, cart functionality, etc.