向上滑動面板中的頁腳隱藏內容

我正在使用sliding_up_panel小部件和頁腳屬性在底部顯示一些底部。問題是面板的內容隱藏在頁腳內容后面。我試著按照文檔中的建議添加填充,但這似乎并沒有得到理想的結果。

以下是小部件文檔的摘要。

頁腳:浮動在面板上方并附著到面板底部的可選持久控件。面板底部的內容將被此小部件覆蓋。在面板底部添加襯墊以避免覆蓋。

SlidingUpPanel(
  backdropEnabled: true,
  color: Colors.transparent,
  minHeight: 140,
  maxHeight: 300,
  parallaxEnabled: true,
  footer: SizedBox(
    width: MediaQuery.of(context).size.width,
    child: Padding(
      padding: const EdgeInsets.all(10.0),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          SizedBox(
            width: double.infinity,
            child: ElevatedButton(
              onPressed: () {},
              child: Text("Subscribe"),
            ),
          ),
          Row(
            children: [
              Expanded(
                child: ElevatedButton(
                  onPressed: () {},
                  child: Text("Chat"),
                ),
              ),
              SizedBox(width: 10),
              Expanded(
                  child: ElevatedButton(
                onPressed: () {},
                child: Text("Learn More"),
              ))
            ],
          ),
        ],
      ),
    ),
  ),
  panel: Padding(
    padding: const EdgeInsets.only(bottom: 90.0),
    child: Container(
      decoration: const BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.only(
          topLeft: Radius.circular(30),
          topRight: Radius.circular(30),
        ),
      ),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          Padding(
            padding: const EdgeInsets.all(20),
            child: Container(
              width: 40,
              height: 3,
              decoration: const BoxDecoration(
                color: Colors.black,
                borderRadius: BorderRadius.all(
                  Radius.circular(10),
                ),
              ),
            ),
          ),
          Align(
            alignment: Alignment.topLeft,
            child: Padding(
              padding: const EdgeInsets.only(
                left: 20,
                right: 20,
              ),
              child: Column(
                crossAxisAlignment:
                    CrossAxisAlignment.start,
                children: [
                  Text("Main Heading"),
                  Text("Sub Heading"),
                  Text(
                      "Text area 1 Text area 1 Text area 1 Text area 1 Text area 1 Text area 1 Text area 1 Text area 1 Text area 1 Text area 1 Text area 1 Text area 1 Text area 1"),
                  Text("Text area 2"),
                  Text("Text area 3"),
                ],
              ),
            ),
          ),
        ],
      ),
    ),
  ),
)

輸出如下圖所示:

Panel Closed

您可以注意到文本隱藏在按鈕后面。

Panel Open

我嘗試在面板上添加底部填充。當面板打開時,在面板底部增加了灰色區域。

請幫助防止將此文本隱藏在按鈕后面。

? 最佳回答:

我認為底部填充物只能在面板打開時幫助使內容可見。當它關閉時,你需要一個頂部填充物——你可以添加它,但在這種情況下,當你打開面板時,填充物也會在那里。

因此,您可以嘗試保持面板的打開/關閉狀態,并根據該狀態調整內容。

在state類中創建成員變量:

double _panelPosition = 0;

SlidingUpPanel添加回調函數以跟蹤狀態:

SlidingUpPanel(
   onPanelSlide: (position) => setState(() => _panelPosition = position),
  ...
)

現在,您可以根據面板位置顯示/隱藏內容,將包含“主標題、子標題”等的Column包裝到Visibility小部件中:

child: Visibility(
  visible: _panelPosition > 0,
  child: Column(
    crossAxisAlignment: CrossAxisAlignment.start,
    children: [<your text widgets>],
  ),
),

或者您可以使用AnimatedOpacity來使其更平滑:

child: AnimatedOpacity(
  opacity: _panelPosition,
  duration: const Duration(milliseconds: 200),
  child: Column(
    crossAxisAlignment: CrossAxisAlignment.start,
    children: [<your text widgets>],
  ),
),

或者使用動態變化的頂部填充,如果面板打開,該填充將達到0(使用ExpandedSingleChildScrollView以避免溢出):

Expanded(
  child: SingleChildScrollView(
    child: Align(
      alignment: Alignment.topLeft,
      child: Padding(
        padding: const EdgeInsets.only(
          left: 20,
          right: 20,
        ),
        child: Padding(
          padding: EdgeInsets.only(
              top: 100 - _panelPosition * 100),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [<your text widgets>],
          ),
        ),
      ),
    ),
  ),
),

您可以微調上述版本以控制何時開始顯示內容等。

注意:在打開面板期間,上述代碼將導致多次重建。如果要避免這種情況,可以使用bool變量而不是double,并且只跟蹤完全關閉(position == 0)和完全打開({%27})狀態。當然,在這種情況下不能使用AnimatedOpacity

主站蜘蛛池模板: 久久免费视频一区| 波多野结衣中文字幕一区| 亚洲AV综合色一区二区三区| 中文字幕一区二区区免| 亚洲一区二区三区无码中文字幕| 国产一区二区三区乱码| 精品一区二区视频在线观看| 成人无码精品一区二区三区| 午夜视频久久久久一区| 中文字幕无码一区二区免费| 亚洲一区在线免费观看| 一区二区三区在线播放视频| 国产日韩一区二区三免费高清| 中文字幕日韩一区| 一区免费在线观看| 亚洲AV综合色一区二区三区 | 免费高清在线影片一区| 日本精品一区二区三区在线视频| 亚洲熟妇av一区二区三区漫画| 日本一区二区视频| a级午夜毛片免费一区二区| 99热门精品一区二区三区无码| 国产免费av一区二区三区| 久久久精品人妻一区亚美研究所| 国产精品第一区揄拍无码| 无码国产伦一区二区三区视频| 国产伦一区二区三区免费| 亚洲国产老鸭窝一区二区三区| 麻豆一区二区三区蜜桃免费| 亚洲av无码一区二区三区不卡 | 色偷偷一区二区无码视频| 国产伦理一区二区三区| 亚洲AV香蕉一区区二区三区| 国产成人无码AV一区二区在线观看| 久久蜜桃精品一区二区三区| 日本伊人精品一区二区三区| 精品无码综合一区| 日本一区二区三区在线网| 亚无码乱人伦一区二区| 91福利一区二区| 另类免费视频一区二区在线观看|