提问人:Mehroze Zaidi 提问时间:10/21/2023 更新时间:10/21/2023 访问量:32
使用“基础内容”在页面顶部打开对话框时不显示go_router
Underlying Content is not shown when dialog is open on top of the page using go_router
问:
正如您在屏幕截图中看到的那样,我遇到了这个问题,当使用go_router在页面顶部打开对话框时,不会显示基础内容。我使用以下方法来显示使用包go_router覆盖层或对话框。
class DialogScreen<T> extends Page<T> {
final Offset? anchorPoint;
final Color? barrierColor;
final bool barrierDismissible;
final String? barrierLabel;
final bool useSafeArea;
final CapturedThemes? themes;
final WidgetBuilder builder;
const DialogScreen({
required this.builder,
this.anchorPoint,
this.barrierColor = Colors.black54,
this.barrierDismissible = true,
this.barrierLabel,
this.useSafeArea = true,
this.themes,
super.key,
super.name,
super.arguments,
super.restorationId,
});
@override
Route<T> createRoute(BuildContext context) => DialogRoute<T>(
context: context,
settings: this,
builder: (context) => Dialog(
backgroundColor: Colors.transparent,
child: builder(context),
),
anchorPoint: anchorPoint,
barrierColor: barrierColor,
barrierDismissible: barrierDismissible,
barrierLabel: barrierLabel,
useSafeArea: useSafeArea,
themes: themes,
);
}
这是我的 web_routes.dart 文件:
class WebRoutes {
static final GoRouter goRouter = GoRouter(
navigatorKey: NavigationService.navigatorKey,
initialLocation: kIsWeb ? '/' : "/login",
//'/login',
debugLogDiagnostics: true,
routes: [
GoRoute(
name: "testDialog",
path: '/testDialog',
pageBuilder:
(BuildContext context, GoRouterState state) {
return
DialogScreen(
barrierColor: Colors.transparent,
barrierDismissible: true,
builder: (context) =>
const TestScreen());
},
),}
请注意:我使用了这种方法,因为我想在地址栏上显示网址,其他通用方式工作正常。
答: 暂无答案
上一个:React 服务器组件和导航器
评论