Skip to content

Commit

Permalink
mandi page done
Browse files Browse the repository at this point in the history
  • Loading branch information
SonicWarrior1 committed Sep 3, 2022
1 parent c0b76ff commit c78dc2b
Show file tree
Hide file tree
Showing 4 changed files with 531 additions and 139 deletions.
31 changes: 31 additions & 0 deletions agriculture/lib/controllers/priceController.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:get/get.dart';

class PriceController extends GetxController {
Stream<QuerySnapshot<Map<String, dynamic>>>? snapshot;
getPrices(String cropName) async {
snapshot = await FirebaseFirestore.instance
.collection('crops')
.doc(cropName)
.collection('prices')
.snapshots();
}

List<PriceData> chartData = [
// PriceData(DateTime(2016), 25),
// PriceData(DateTime(2017), 35),
PriceData(DateTime(2015), 25),
PriceData(DateTime(2016), 15),
PriceData(DateTime(2017), 115),
PriceData(DateTime(2018), 65),
PriceData(DateTime(2019), 65),
PriceData(DateTime(2020), 65),
PriceData(DateTime(2021), 65),
];
}

class PriceData {
PriceData(this.year, this.price);
final DateTime year;
final int price;
}
73 changes: 40 additions & 33 deletions agriculture/lib/crops.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,47 @@ class _CropsState extends State<Crops> {
child: StreamBuilder<QuerySnapshot<Map<String, dynamic>>>(
stream: FirebaseFirestore.instance.collection('crops').snapshots(),
builder: (context, snapshot) {
return ListView.builder(
itemCount: snapshot.data!.docs.length,
itemBuilder: (context, index) {
String name = snapshot.data!.docs[index]['name'];
String image = snapshot.data!.docs[index]['imageUrl'];
String season = snapshot.data!.docs[index]['season'];
String water = snapshot.data!.docs[index]['water'];
String temp = snapshot.data!.docs[index]['temp'];
String soil = snapshot.data!.docs[index]['soil'];
String plantation = snapshot.data!.docs[index]['plantation'];
String method = snapshot.data!.docs[index]['method'];
String disease = snapshot.data!.docs[index]['diseases'];
String solutions = snapshot.data!.docs[index]['solution'];
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(
child: CircularProgressIndicator(),
);
} else {
return ListView.builder(
itemCount: snapshot.data!.docs.length,
itemBuilder: (context, index) {
String name = snapshot.data!.docs[index]['name'];
String image = snapshot.data!.docs[index]['imageUrl'];
String season = snapshot.data!.docs[index]['season'];
String water = snapshot.data!.docs[index]['water'];
String temp = snapshot.data!.docs[index]['temp'];
String soil = snapshot.data!.docs[index]['soil'];
String plantation =
snapshot.data!.docs[index]['plantation'];
String method = snapshot.data!.docs[index]['method'];
String disease = snapshot.data!.docs[index]['diseases'];
String solutions = snapshot.data!.docs[index]['solution'];

return recommended(image, name, season, temp, soil, water,
plantation, method, disease, solutions, context);
},
//scrollDirection: Axis.vertical,
primary: false,
// children: <Widget>[
// recommended("assets/rice.jpg", "Rice", "Kharif",
// "22-32 degree Celsius", "Deep clayey and loamy soil"),
// recommended("assets/wheat.jpg", "Wheat", "Rabi",
// " 10-15 degree Celsius ", "Well-drained fertile loamy"),
// recommended("assets/sugarcane.jpg", "Sugarcane", "Kharif",
// " 21-27 degree Celsius ", " Deep rich loamy soil"),
// recommended("assets/tea.jpg", "Tea", "Kharif",
// "20-30 degree Celsius ", "deep friable loamy soil"),
// recommended("assets/coffee.jpg", "Coffee", "Kharif",
// "15-28 degree Celsius ", "deep friable loamy soil"),
// recommended("assets/cotton.jpg", "Cotton", "Kharif",
// "21-30 degree Celsius ", "Black soil of Deccan Plateau"),
// ],
);
return recommended(image, name, season, temp, soil, water,
plantation, method, disease, solutions, context);
},
//scrollDirection: Axis.vertical,
primary: false,
// children: <Widget>[
// recommended("assets/rice.jpg", "Rice", "Kharif",
// "22-32 degree Celsius", "Deep clayey and loamy soil"),
// recommended("assets/wheat.jpg", "Wheat", "Rabi",
// " 10-15 degree Celsius ", "Well-drained fertile loamy"),
// recommended("assets/sugarcane.jpg", "Sugarcane", "Kharif",
// " 21-27 degree Celsius ", " Deep rich loamy soil"),
// recommended("assets/tea.jpg", "Tea", "Kharif",
// "20-30 degree Celsius ", "deep friable loamy soil"),
// recommended("assets/coffee.jpg", "Coffee", "Kharif",
// "15-28 degree Celsius ", "deep friable loamy soil"),
// recommended("assets/cotton.jpg", "Cotton", "Kharif",
// "21-30 degree Celsius ", "Black soil of Deccan Plateau"),
// ],
);
}
}),
),
);
Expand Down
Loading

0 comments on commit c78dc2b

Please sign in to comment.