Skip to content

Commit

Permalink
fix: Workaround for flutter cannot wait on navigator push
Browse files Browse the repository at this point in the history
  • Loading branch information
krille-chan committed Dec 7, 2023
1 parent 76ab8c6 commit 73038ad
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/pages/user_bottom_sheet/user_bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:go_router/go_router.dart';
import 'package:matrix/matrix.dart';

import 'package:fluffychat/config/themes.dart';
import 'package:fluffychat/widgets/permission_slider_dialog.dart';
import '../../widgets/matrix.dart';
import 'user_bottom_sheet_view.dart';
Expand Down Expand Up @@ -225,19 +226,24 @@ class UserBottomSheetController extends State<UserBottomSheet> {
}
break;
case UserBottomSheetAction.message:
Navigator.of(context).pop();
// Workaround for https://github.com/flutter/flutter/issues/27495
await Future.delayed(FluffyThemes.animationDuration);

final roomIdResult = await showFutureLoadingDialog(
context: context,
context: widget.outerContext,
future: () => Matrix.of(widget.outerContext)
.client
.startDirectChat(user?.id ?? widget.profile!.userId),
);
final roomId = roomIdResult.result;
if (roomId == null) return;
Navigator.of(context).pop();
widget.outerContext.go('/rooms/$roomId');
break;
case UserBottomSheetAction.ignore:
Navigator.of(context).pop();
// Workaround for https://github.com/flutter/flutter/issues/27495
await Future.delayed(FluffyThemes.animationDuration);
final userId = user?.id ?? widget.profile?.userId;
widget.outerContext
.go('/rooms/settings/security/ignorelist', extra: userId);
Expand Down

0 comments on commit 73038ad

Please sign in to comment.