Removed refrences to name and vote from db
This commit is contained in:
parent
9d1967a9f0
commit
f50380306b
42
flutter_app/android/app/google-services.json
Normal file
42
flutter_app/android/app/google-services.json
Normal file
@ -0,0 +1,42 @@
|
||||
{
|
||||
"project_info": {
|
||||
"project_number": "541811372013",
|
||||
"firebase_url": "https://hackku.firebaseio.com",
|
||||
"project_id": "hackku",
|
||||
"storage_bucket": "hackku.appspot.com"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:541811372013:android:63dc196b5890f0e2",
|
||||
"android_client_info": {
|
||||
"package_name": "com.glmdev.waitnomore.flutterapp"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "541811372013-k0nheic39d5v6bbgokl0ajg06otf8rus.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyBoOxFcUyUsi2PW3QXw86FnQZ__1TCEI2s"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"analytics_service": {
|
||||
"status": 1
|
||||
},
|
||||
"appinvite_service": {
|
||||
"status": 1,
|
||||
"other_platform_oauth_client": []
|
||||
},
|
||||
"ads_service": {
|
||||
"status": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
@ -51,7 +51,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
final record = Record.fromSnapshot(data);
|
||||
|
||||
return Padding(
|
||||
key: ValueKey(record.name),
|
||||
key: ValueKey(record.stall),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
@ -59,15 +59,15 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
borderRadius: BorderRadius.circular(5.0),
|
||||
),
|
||||
child: ListTile(
|
||||
title: Text(record.name),
|
||||
trailing: Text(record.votes.toString()),
|
||||
onTap: () => Firestore.instance.runTransaction((transaction) async {
|
||||
final freshSnapshot = await transaction.get(record.reference);
|
||||
final fresh = Record.fromSnapshot(freshSnapshot);
|
||||
|
||||
await transaction
|
||||
.update(record.reference, {'votes': fresh.votes + 1});
|
||||
}),
|
||||
title: Text(record.stall.toString()),
|
||||
trailing: Text(record.handicap.toString()),
|
||||
// onTap: () => Firestore.instance.runTransaction((transaction) async {
|
||||
//// final freshSnapshot = await transaction.get(record.reference);
|
||||
//// final fresh = Record.fromSnapshot(freshSnapshot);
|
||||
////
|
||||
//// await transaction
|
||||
//// .update(record.reference, {'votes': fresh.votes + 1});
|
||||
//// }),
|
||||
),
|
||||
),
|
||||
);
|
||||
@ -75,19 +75,21 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
}
|
||||
|
||||
class Record {
|
||||
final String name;
|
||||
final int votes;
|
||||
final int stall;
|
||||
final bool handicap;
|
||||
final DocumentReference reference;
|
||||
|
||||
Record.fromMap(Map<String, dynamic> map, {this.reference})
|
||||
: assert(map['name'] != null),
|
||||
assert(map['votes'] != null),
|
||||
name = map['name'],
|
||||
votes = map['votes'];
|
||||
: assert(map['handicap'] != null),
|
||||
assert(map['Stall'] != null),
|
||||
stall = map['Stall'],
|
||||
handicap = map['handicap'];
|
||||
|
||||
|
||||
|
||||
Record.fromSnapshot(DocumentSnapshot snapshot)
|
||||
: this.fromMap(snapshot.data, reference: snapshot.reference);
|
||||
|
||||
@override
|
||||
String toString() => "Record<$name:$votes>";
|
||||
String toString() => "Record<$stall>";
|
||||
}
|
Loading…
Reference in New Issue
Block a user