使用“基础内容”在页面顶部打开对话框时不显示go_router

Underlying Content is not shown when dialog is open on top of the page using go_router

提问人:Mehroze Zaidi 提问时间:10/21/2023 更新时间:10/21/2023 访问量:32

问:

enter image description here

正如您在屏幕截图中看到的那样,我遇到了这个问题,当使用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());
        },
      ),}

请注意:我使用了这种方法,因为我想在地址栏上显示网址,其他通用方式工作正常。

Flutter Routes Navigator Gorouter

评论

0赞 Munsif Ali 10/21/2023
减小对话框的大小
0赞 Mehroze Zaidi 10/23/2023
兄弟,白色背景就像整个白色屏幕,对话框在这个背景上。我希望背景是透明的,但不幸的是我做不到。
0赞 Munsif Ali 10/25/2023
你能附上对话框的屏幕截图吗

答: 暂无答案