Fix: Loading data
parent
13a1651af7
commit
bf20cbbd1f
|
@ -1,10 +1,10 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class MyButton extends StatelessWidget {
|
class MyButton extends StatelessWidget {
|
||||||
void Function()? onTap;
|
final void Function()? onTap;
|
||||||
final String text;
|
final String text;
|
||||||
|
|
||||||
MyButton({
|
const MyButton({
|
||||||
super.key,
|
super.key,
|
||||||
required this.text,
|
required this.text,
|
||||||
required this.onTap,
|
required this.onTap,
|
||||||
|
|
|
@ -59,14 +59,20 @@ class _UserDataPageState extends State<UserDataPage> {
|
||||||
.doc(currentUserId)
|
.doc(currentUserId)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
|
if (!userSnapshot.exists || userSnapshot.data() == null) {
|
||||||
|
return; // should not happen, user entry should exist
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> userFields =
|
||||||
|
userSnapshot.data() as Map<String, dynamic>;
|
||||||
|
|
||||||
// Extract gender and birth year
|
// Extract gender and birth year
|
||||||
_genderFromDb = userSnapshot[Constants.dbFieldUsersGender];
|
if (userFields.containsKey(Constants.dbFieldUsersGender)) {
|
||||||
_yearFromDb = userSnapshot
|
_genderFromDb = userSnapshot[Constants.dbFieldUsersGender];
|
||||||
.data()
|
}
|
||||||
.toString()
|
if (userFields.containsKey(Constants.dbFieldUsersYearBorn)) {
|
||||||
.contains(Constants.dbFieldUsersYearBorn)
|
_yearFromDb = userSnapshot[Constants.dbFieldUsersYearBorn];
|
||||||
? userSnapshot[Constants.dbFieldUsersYearBorn]
|
}
|
||||||
: null;
|
|
||||||
|
|
||||||
// Fetch locations
|
// Fetch locations
|
||||||
QuerySnapshot locationSnapshot = await _firestore
|
QuerySnapshot locationSnapshot = await _firestore
|
||||||
|
@ -391,6 +397,7 @@ class _UserDataPageState extends State<UserDataPage> {
|
||||||
: 'undefined'),
|
: 'undefined'),
|
||||||
const SizedBox(width: 20),
|
const SizedBox(width: 20),
|
||||||
DropdownMenu(
|
DropdownMenu(
|
||||||
|
initialSelection: _selectedYear,
|
||||||
onSelected: (int? newValue) {
|
onSelected: (int? newValue) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_selectedYear = newValue;
|
_selectedYear = newValue;
|
||||||
|
@ -403,7 +410,6 @@ class _UserDataPageState extends State<UserDataPage> {
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
label: const Text('birth year'),
|
label: const Text('birth year'),
|
||||||
initialSelection: _yearFromDb,
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue