Created
July 30, 2018 06:56
-
-
Save rohan20/908612270ac6fd872560fabec0961c96 to your computer and use it in GitHub Desktop.
ProductListPage (static)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:products_tutorial/widgets/products_list_item.dart'; | |
class ProductsListPage extends StatelessWidget { | |
BuildContext context; | |
@override | |
Widget build(BuildContext context) { | |
this.context = context; | |
return Scaffold( | |
appBar: AppBar( | |
centerTitle: true, | |
backgroundColor: Colors.white, | |
title: Text( | |
"PRODUCT LIST", | |
style: TextStyle( | |
color: Colors.black, | |
), | |
), | |
), | |
body: _buildProductsListPage(), | |
); | |
} | |
_buildProductsListPage() { | |
Size screenSize = MediaQuery.of(context).size; | |
return Container( | |
color: Colors.grey[100], | |
child: ListView.builder( | |
itemCount: 5, | |
itemBuilder: (context, index) { | |
if (index == 0) { | |
return _buildFilterWidgets(screenSize); | |
} else if (index == 4) { | |
return SizedBox( | |
height: 12.0, | |
); | |
} else { | |
return _dummyProductsList(screenSize)[index]; | |
} | |
}, | |
), | |
); | |
} | |
_buildFilterWidgets(Size screenSize) { | |
return Container( | |
margin: const EdgeInsets.all(12.0), | |
width: screenSize.width, | |
child: Card( | |
elevation: 4.0, | |
child: Container( | |
padding: const EdgeInsets.symmetric(vertical: 12.0), | |
child: Row( | |
mainAxisSize: MainAxisSize.min, | |
mainAxisAlignment: MainAxisAlignment.spaceEvenly, | |
children: <Widget>[ | |
_buildFilterButton("SORT"), | |
Container( | |
color: Colors.black, | |
width: 2.0, | |
height: 24.0, | |
), | |
_buildFilterButton("REFINE"), | |
], | |
), | |
), | |
), | |
); | |
} | |
_buildFilterButton(String title) { | |
return InkWell( | |
onTap: () { | |
print(title); | |
}, | |
child: Row( | |
children: <Widget>[ | |
Icon( | |
Icons.arrow_drop_down, | |
color: Colors.black, | |
), | |
SizedBox( | |
width: 2.0, | |
), | |
Text(title), | |
], | |
), | |
); | |
} | |
_dummyProductsList(Size screenSize) { | |
return [ | |
ProductsListItem( | |
name: "Michael Kora", | |
currentPrice: 524, | |
originalPrice: 699, | |
discount: 25, | |
imageUrl: | |
"https://n1.sdlcdn.com/imgs/c/9/8/Lambency-Brown-Solid-Casual-Blazers-SDL781227769-1-1b660.jpg", | |
), | |
ProductsListItem( | |
name: "Michael Kora", | |
currentPrice: 524, | |
originalPrice: 699, | |
discount: 25, | |
imageUrl: | |
"https://n1.sdlcdn.com/imgs/c/9/8/Lambency-Brown-Solid-Casual-Blazers-SDL781227769-1-1b660.jpg", | |
), | |
ProductsListItem( | |
name: "David Klin", | |
currentPrice: 249, | |
originalPrice: 499, | |
discount: 50, | |
imageUrl: | |
"https://images-na.ssl-images-amazon.com/images/I/71O0zS0DT0L._UX342_.jpg", | |
), | |
ProductsListItem( | |
name: "Nakkana", | |
currentPrice: 899, | |
originalPrice: 1299, | |
discount: 23, | |
imageUrl: | |
"https://assets.myntassets.com/h_240,q_90,w_180/v1/assets/images/1304671/2016/4/14/11460624898615-Hancock-Men-Shirts-8481460624898035-1_mini.jpg", | |
), | |
ProductsListItem( | |
name: "David Klin", | |
currentPrice: 249, | |
originalPrice: 499, | |
discount: 20, | |
imageUrl: | |
"https://images-na.ssl-images-amazon.com/images/I/71O0zS0DT0L._UX342_.jpg", | |
), | |
ProductsListItem( | |
name: "Nakkana", | |
currentPrice: 899, | |
originalPrice: 1299, | |
discount: 23, | |
imageUrl: | |
"https://assets.myntassets.com/h_240,q_90,w_180/v1/assets/images/1304671/2016/4/14/11460624898615-Hancock-Men-Shirts-8481460624898035-1_mini.jpg", | |
), | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment