Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Team 37
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Om Akbari (nzc174)
Team 37
Commits
043ab5b2
Commit
043ab5b2
authored
3 years ago
by
Aayush
Browse files
Options
Downloads
Patches
Plain Diff
Changes Home Screen Firebase
parent
d5180020
No related branches found
Branches containing commit
No related tags found
1 merge request
!3
Main product
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/providers/product_provider.dart
+8
-7
8 additions, 7 deletions
lib/providers/product_provider.dart
lib/screens/home_screens/home_screen.dart
+63
-60
63 additions, 60 deletions
lib/screens/home_screens/home_screen.dart
with
71 additions
and
67 deletions
lib/providers/product_provider.dart
+
8
−
7
View file @
043ab5b2
...
...
@@ -4,14 +4,12 @@ import 'package:food_app/models/product_model.dart';
class
ProductProvider
with
ChangeNotifier
{
List
<
ProductModel
>
herbsProductList
=
[];
List
<
ProductModel
>
freshProductList
=
[];
List
<
ProductModel
>
rootProductList
=
[];
ProductModel
productModel
;
fetchHerbsProductData
()
async
{
List
<
ProductModel
>
newList
=
[];
QuerySnapshot
value
=
await
FirebaseFirestore
.
instance
.
collection
(
"HerbsProduct
"
)
.
get
();
await
FirebaseFirestore
.
instance
.
collection
(
"HerbsProduct"
)
.
get
();
value
.
docs
.
forEach
(
(
element
)
{
productModel
=
ProductModel
(
...
...
@@ -30,12 +28,13 @@ class ProductProvider with ChangeNotifier {
return
herbsProductList
;
}
List
<
ProductModel
>
freshProductList
=
[];
fetchFreshProductData
()
async
{
List
<
ProductModel
>
newList
=
[];
QuerySnapshot
value
=
await
FirebaseFirestore
.
instance
.
collection
(
"FreshFruitsProduct "
)
.
get
();
QuerySnapshot
value
=
await
FirebaseFirestore
.
instance
.
collection
(
"FreshFruitsProduct"
)
.
get
();
value
.
docs
.
forEach
(
(
element
)
{
...
...
@@ -55,11 +54,13 @@ class ProductProvider with ChangeNotifier {
return
freshProductList
;
}
List
<
ProductModel
>
rootProductList
=
[];
fetchRootProductData
()
async
{
List
<
ProductModel
>
newList
=
[];
QuerySnapshot
value
=
await
FirebaseFirestore
.
instance
.
collection
(
"RootVegetablesProduct
"
)
.
collection
(
"RootVegetablesProduct"
)
.
get
();
value
.
docs
.
forEach
(
...
...
This diff is collapsed.
Click to expand it.
lib/screens/home_screens/home_screen.dart
+
63
−
60
View file @
043ab5b2
...
...
@@ -37,27 +37,28 @@ class _HomeScreenState extends State<HomeScreen> {
SingleChildScrollView
(
scrollDirection:
Axis
.
horizontal
,
child:
Row
(
children:
productProvider
.
getHerbsProductDataList
.
map
((
herbsProductData
)
{
return
SingleProduct
(
onTap:
()
{
Navigator
.
of
(
context
)
.
push
(
MaterialPageRoute
(
builder:
(
context
)
=
>
ProductOverview
(
productPrice:
herbsProductData
.
productPrice
,
productName:
herbsProductData
.
productName
,
productImage:
herbsProductData
.
productImage
,
children:
productProvider
.
getHerbsProductDataList
.
map
(
(
herbsProductData
)
{
return
SingleProduct
(
onTap:
()
{
Navigator
.
of
(
context
)
.
push
(
MaterialPageRoute
(
builder:
(
context
)
=
>
ProductOverview
(
productImage:
herbsProductData
.
productImage
,
productName:
herbsProductData
.
productName
,
productPrice:
herbsProductData
.
productPrice
,
),
),
),
);
},
productPrice:
herbsProductData
.
productPrice
,
productImage:
herbsProductData
.
productImage
,
productName:
herbsProductData
.
productName
,
);
},
)
.
toList
(),
);
},
productImage:
herbsProductData
.
productImage
,
productName:
herbsProductData
.
productName
,
productPrice:
herbsProductData
.
productPrice
,
);
},
)
.
toList
(),
// children: [
// ],
...
...
@@ -87,27 +88,27 @@ class _HomeScreenState extends State<HomeScreen> {
SingleChildScrollView
(
scrollDirection:
Axis
.
horizontal
,
child:
Row
(
children:
productProvider
.
getFreshProductDataList
.
map
((
freshProductData
)
{
return
SingleProduct
(
onTap:
()
{
Navigator
.
of
(
context
)
.
push
(
MaterialPageRoute
(
builder:
(
context
)
=
>
ProductOverview
(
productPrice:
freshProductData
.
productPrice
,
productName:
freshProductData
.
productName
,
productImage:
freshProductData
.
productImage
,
children:
productProvider
.
getFreshProductDataList
.
map
(
(
freshProductData
)
{
return
SingleProduct
(
onTap:
()
{
Navigator
.
of
(
context
)
.
push
(
MaterialPageRoute
(
builder:
(
context
)
=
>
ProductOverview
(
productImage:
freshProductData
.
productImage
,
productName:
freshProductData
.
productName
,
productPrice:
freshProductData
.
productPrice
,
),
),
),
);
},
productPrice:
freshProductData
.
productPrice
,
productImage:
freshProductData
.
productImage
,
productName:
freshProductData
.
productName
,
);
},
)
.
toList
(),
);
},
productImage:
freshProductData
.
productImage
,
productName:
freshProductData
.
productName
,
productPrice:
freshProductData
.
productPrice
,
);
},
)
.
toList
(),
),
),
],
...
...
@@ -134,27 +135,27 @@ class _HomeScreenState extends State<HomeScreen> {
SingleChildScrollView
(
scrollDirection:
Axis
.
horizontal
,
child:
Row
(
children:
productProvider
.
getRootProductDataList
.
map
((
rootProductData
)
{
return
SingleProduct
(
onTap:
()
{
Navigator
.
of
(
context
)
.
push
(
MaterialPageRoute
(
builder:
(
context
)
=
>
ProductOverview
(
productPrice:
rootProductData
.
productPrice
,
productName:
rootProductData
.
productName
,
productImage:
rootProductData
.
productImage
,
children:
productProvider
.
getRootProductDataList
.
map
(
(
rootProductData
)
{
return
SingleProduct
(
onTap:
()
{
Navigator
.
of
(
context
)
.
push
(
MaterialPageRoute
(
builder:
(
context
)
=
>
ProductOverview
(
productImage:
rootProductData
.
productImage
,
productName:
rootProductData
.
productName
,
productPrice:
rootProductData
.
productPrice
,
),
),
),
);
},
productPrice:
rootProductData
.
productPrice
,
productImage:
rootProductData
.
productImage
,
productName:
rootProductData
.
productName
,
);
},
)
.
toList
(),
);
},
productImage:
rootProductData
.
productImage
,
productName:
rootProductData
.
productName
,
productPrice:
rootProductData
.
productPrice
,
);
},
)
.
toList
(),
),
),
],
...
...
@@ -165,6 +166,8 @@ class _HomeScreenState extends State<HomeScreen> {
void
initState
()
{
ProductProvider
productProvider
=
Provider
.
of
(
context
,
listen:
false
);
productProvider
.
fetchHerbsProductData
();
productProvider
.
fetchFreshProductData
();
productProvider
.
fetchRootProductData
();
super
.
initState
();
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment