簡體   English   中英

Flutter:Tab 項上的漣漪效應

[英]Flutter: Ripple effect on Tab item

我創建了一個帶有標簽的 Flutter TabBar。 當用戶單擊選項卡按鈕時,有沒有辦法添加類似按鈕的漣漪效果?

  TabBar(
        isScrollable: true,
        controller: tabController,
        indicatorColor: Colors.transparent,
        tabs: <Widget>[
          Tab(child: Text("tab 1")),
          Tab(child: Text("tab 2")),
          Tab(child: Text("tab 3"))
        ],
      );

默認情況下,選項卡具有連鎖反應。

Scaffold(
  backgroundColor: Colors.red,
  body: SafeArea(
    child: Row(
      children: [
        TabBar(
          controller: tabController,
          isScrollable: true,
          indicatorColor: Colors.transparent,
          tabs: <Widget>[
            Tab(child: Text("tab 1")),
            Tab(child: Text("tab 2")),
            Tab(child: Text("tab 3"))
          ],
        ),
      ],
    ),
  ),
);

預習

編輯:

Material(
      color: Colors.transparent,
      child: InkWell(
        onTap: widget.onTap,
        child: Ink(
          child: Text("Tab1")
        )
      )
     )

如果您為 customTab 實現了 Inkwell,您可以向其中添加 Ink 和材料,它將顯示波紋效果。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM