Showcaseview 包突出显示 CupertinoTabScaffold(用作 BottomNavBar)[Flutter]

问题描述 投票:0回答:2

我正在使用 showCaseView 包,当我突出显示小部件时,cupertinoTabScaffold 也会突出显示。 ShowCaseWidget 包装了 MaterialApp 小部件,因此 TabScaffold 和所有其他小部件都由 ShowCase 包包装。有谁遇到过这种情况,如何解决这个问题?

flutter dart flutter-dependencies showcaseview
2个回答
0
投票

我根据“showCaseView”现在是否处于活动状态更改了 CupertinoTabScaffold 的颜色:

  tabBar: CustomCupertinoTabBar(
      backgroundColor:
          Provider.of<NotifyShowcaseState>(context).isShowcaseActive //I've created ChangeNotifier class for updating state
              ? const Color(0x99BDBDBD) //dimmed grey if showCase is active
              : null,  //default white color, if showCase is inActive
            ....
        ),

0
投票

您可以存储一个值来控制您的

BottomNavBar

的可见性

首先在你的

ShowCaseWidget

ShowCaseWidget(
      onStart: (index, __) => showCaseVisible = true,
      onFinish: () => showCaseVisible = false,
      builder: (context) {
        return child;
      },

然后您可以根据变量的值简单地在导航栏上方显示一个叠加层:

Stack(
children: [
  MyNavBar(),
  if (showCaseVisible) Positioned.fill(
      child: GestureDetector(
        onTap: () => ShowCaseWidget.of(context).next(),
        child: ColoredBox(
          color: Colors.black.withOpacity(0.75),
        ),
      ),
    ),
],

© www.soinside.com 2019 - 2024. All rights reserved.