Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 129 additions & 0 deletions Assignment no 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Plant Store UI',
theme: ThemeData(
primarySwatch: Colors.green,
),
home: PlantStoreHome(),
);
}
}

class PlantStoreHome extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: IconButton(
icon: Icon(Icons.menu),
onPressed: () {},
),
actions: [
IconButton(
icon: Icon(Icons.shopping_cart),
onPressed: () {},
),
],
),
body: Column(
children: [
Padding(
padding: const EdgeInsets.all(16.0),
child: Text(
'Hello Mia',
style: TextStyle(fontSize: 24),
),
),
Padding(
padding: const EdgeInsets.all(16.0),
child: TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: 'Search',
prefixIcon: Icon(Icons.search),
),
),
),
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: [
CategoryButton(label: 'Popular'),
CategoryButton(label: 'Outdoor'),
CategoryButton(label: 'Indoor'),
CategoryButton(label: 'Top Picks'),
],
),
),
Expanded(
child: ListView.builder(
itemCount: 10,
itemBuilder: (context, index) {
return PlantCard(
name: 'Peace Lily',
image: 'peace_lily.jpg',
price: 25,
);
},
),
),
],
),
);
}
}

class CategoryButton extends StatelessWidget {
final String label;

CategoryButton({required this.label});

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
onPressed: () {},
child: Text(label),
),
);
}
}

class PlantCard extends StatelessWidget {
final String name;
final String image;
final int price;

PlantCard({required this.name, required this.image, required this.price});

@override
Widget build(BuildContext context) {
return Card(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
children: [
Image.asset(image),
SizedBox(width: 16),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(name),
Text('\$$price'),
],
),
],
),
),
);
}
}