Example output
import 'package:flutter/material.dart';
void main() {
runApp(MyEcommerceApp());
}
class MyEcommerceApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Ecommerce Store',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: EcommerceHomePage(),
);
}
}
class EcommerceHomePage extends StatefulWidget {
@override
_EcommerceHomePageState createState() => _EcommerceHomePageState();
}
class _EcommerceHomePageState extends State<EcommerceHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('My Ecommerce App'),
),
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Featured Products Section
Container(
padding: EdgeInsets.all(16.0),
child: Text(
'Featured Products',
style: TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold),
),
),
// Featured Product List
Container(
height: 200.0,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: 5,
itemBuilder: (context, index) {
// You can replace this with your actual product widget
return Container(
width: 150.0,
margin: EdgeInsets.all(8.0),
color: Colors.grey,
child: Center(
child: Text('Product $index'),
),
);
},
),
),
// Categories Section
Container(
padding: EdgeInsets.all(16.0),
child: Text(
'Categories',
style: TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold),
),
),
// Category List
Container(
height: 100.0,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: 8,
itemBuilder: (context, index) {
// You can replace this with your actual category widget
return Container(
width: 100.0,
margin: EdgeInsets.all(8.0),
color: Colors.blue,
child: Center(
child: Text('Category $index'),
),
);
},
),
),
],
),
),
);
}
}