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