creating ui of online store in flutter
import 'package:flutter/material.dart';
void main() {
runApp(OnlineStoreApp());
}
class OnlineStoreApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Online Store',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: OnlineStoreScreen(),
);
}
}
class OnlineStoreScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Online Store'),
),
body: ListView(
children: [
SizedBox(height: 16),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16),
child: Text(
'Featured Products',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
),
SizedBox(height: 16),
Container(
height: 200,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: 5,
itemBuilder: (context, index) {
return Container(
width: 150,
margin: EdgeInsets.only(left: 16),
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: BorderRadius.circular(8),
),
child: Center(
child: Text('Product ${index + 1}'),
),
);
},
),
),
SizedBox(height: 16),
Divider(height: 1, color: Colors.grey),
SizedBox(height: 16),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16),
child: Text(
'Categories',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
),
SizedBox(height: 16),
Container(
height: 100,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: 5,
itemBuilder: (context, index) {
return Container(
width: 100,
margin: EdgeInsets.only(left: 16),
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: BorderRadius.circular(8),
),
child: Center(
child: Text('Category ${index + 1}'),
),
);
},
),
),
SizedBox(height: 16),
Divider(height: 1, color: Colors.grey),
SizedBox(height: 16),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16),
child: Text(
'Popular Products',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
),
SizedBox(height: 16),
GridView.count(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
crossAxisCount: 2,
children: List.generate(6, (index) {
return Container(
margin: EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: BorderRadius.circular(8),
),
child: Center(
child: Text('Product ${index + 1}'),
),
);
}),
),
],
),
);
}
}
Comments
Post a Comment