你好,我在Flutter中有一个标签栏,我想禁用标签之间的滑动
// Set the bottom navigation bar
bottomNavigationBar: new Material(
// set the color of the bottom navigation bar
color: const Color(0xFFF7F7F7),
// set the tab bar as the child of bottom navigation bar
child: new TabBar(
tabs: <Tab>[
new Tab(
// set icon to the tab
icon: new Icon(Icons.home,color: Colors.black),
),
new Tab(
icon: new Icon(Icons.favorite,color: Colors.black),
),
new Tab(
icon: new Icon(Icons.search,color: Colors.black),
),
new Tab(
icon: new Icon(Icons.settings,color: Colors.black),
),
],
// setup the controller
controller: controller,
),
),
);
}
}
我在点击每个标签栏按钮时正在移动标签,并且我想禁用滑动谢谢
答案 0 :(得分:26)
您可以通过使用physics
属性来更改页面视图响应用户输入的方式来实现。为此,我们有一个NeverScrollableScrollPhysics
,因此只需将physics
更改为这样:
TabBarView(
physics: NeverScrollableScrollPhysics(),
controller: tabcontroler,
children: <Widget>[
Container(color: Colors.red),
Container(color: Colors.green),
Container(color: Colors.blue),
],
),
答案 1 :(得分:0)
1。。您可以从 TabBarView()
<div class="container pt-4">
<!-- Outer Row -->
<div class="row justify-content-center pt-5">
<div class="col-xl-8 col-lg-10 col-md-7 mt-5">
<div class="card o-hidden border-0 shadow-lg my-5">
<div class="card-body p-5">
<!-- Nested Row within Card Body -->
<div class="row">
<div class="col-lg-6 d-none d-lg-block logo"><img data-tilt class="img-fluid px-5 mt-3 " src="img/netsol.png"> </div>
<div class="col-lg-6">
<div class="p-3 py-5 col-md-12 pr-5">
<div class="text-center">
<h1 class="h6 text-gray-900 mb-3 font-weight-bold">Welcome to Feedback System!</h1>
</div>
<form class="user" action="" method="post" name="login">
<div class="form-group">
<input type="text" class="form-control form-control-user" name="username" placeholder="Username" required />
</div>
<div class="form-group">
<input type="password" class="form-control form-control-user" name="password" placeholder="Password" required />
</div>
<div class="text-danger text-center mb-2">
<?php
if (isset($_SESSION["username"])) {
$noaccess = $_SESSION["username"];
echo "<span>$noaccess</span>";
unset($_SESSION["username"]);
}
else if (isset($_SESSION["error"])) {
$error = $_SESSION["error"];
echo "<span>$error</span>";
unset($_SESSION["error"]);
}
?>
</div>
<input name="submit" class="btn btn-primary btn-user btn-block" type="submit" value="Login" />
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
2。。您可以禁用 ListView(), PageView()
TabBarView(
physics: NeverScrollableScrollPhysics(),
controller: tabcontroler,
children: <Widget>[]
)
物理学接受这些值:
1. BouncingScrollPhysics():在列表的结束/开始时反弹滚动
2. NeverScrollableScrollPhysics():停止更改标签或停止列表滚动或停止页面浏览的页面更改
3. ClampingScrollPhysics():正常行为