Skip to content

Commit

Permalink
fix username update
Browse files Browse the repository at this point in the history
fix username update
  • Loading branch information
Ida631 committed Nov 17, 2024
1 parent 50df25f commit 2e78862
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/presentation/settings/views/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ class SettingsPage extends StatefulWidget {

class _SettingsPageState extends State<SettingsPage> {
@override
void didChangeDependencies() {
Future<void> didChangeDependencies() async {
super.didChangeDependencies();
// Fetch the latest auth session when dependencies change
final viewModel = Provider.of<SettingsViewModel>(context, listen: false);
viewModel.fetchAuthSessionNew();
await viewModel.fetchAuthSessionNew();
}


@override
Widget build(BuildContext context) {
return Consumer<SettingsViewModel>( // listen to changes in SettingsViewModel
Expand Down Expand Up @@ -53,6 +55,7 @@ class _SettingsPageState extends State<SettingsPage> {
),
if (viewModel.isLoggedIn)
ListTile(
key: ValueKey(viewModel.user?.name ?? ""),
leading: Icon(
Icons.account_circle,
size: 45,
Expand All @@ -70,9 +73,7 @@ class _SettingsPageState extends State<SettingsPage> {
MaterialPageRoute(
builder: (context) => UserProfilePage()),
).then((value) {
if (value == 'refresh') {
viewModel.fetchAuthSessionNew();
}
});
},
),
Expand Down

0 comments on commit 2e78862

Please sign in to comment.