gpt4 book ai didi

flutter - Flutter PageView删除页面指示器

转载 作者:行者123 更新时间:2023-12-03 04:26:39 25 4
gpt4 key购买 nike

有谁知道在我更改页面后的几秒钟内是否可以删除显示的PageView指示器?

enter image description here

    return Scaffold(
bottomNavigationBar: CubertoBottomBar(
tabStyle: CubertoTabStyle.STYLE_FADED_BACKGROUND,
selectedTab: _selectedIndex,
tabs: [
TabData(
iconData: Icons.assignment,
title: "Logbuch",
tabColor: Colors.deepPurple,
),
....
],
onTabChangedListener: (position, title, color) {
setState(() {
_selectedIndex = position;
});
},
),
body: PageView(
controller: _pageController,
pageSnapping: true,
onPageChanged: (index) {
setState(() {
_selectedIndex = index;
});
},
// physics: NeverScrollableScrollPhysics(),
children: <Widget>[
LogBookView(),
...
],
),
);

在PageView小部件和BottomNav小部件的文档中找不到任何有关它的信息。

最佳答案

我认为您需要为代码提供一些上下文,因为有很多实现PageView和indicator的方法。我认为您使用TabBarView作为PageView的父级,因为默认情况下,PageView本身不具有指示器,而TabBarView具有。

假设我是对的,除非您想使用不同的选项卡,并且每个选项卡具有不同的PageView或其他小部件,否则您实际上不需要使用TabBarView。判断您的UI我认为带 Controller 的PageView可以满足您的UI需求。

Class XYZ extends StatefullWidget{
.......
}
Class _XYZ extends State<XYZ>
with SingleTickerProviderStateMixin{

PageController _pageController;
int pageNumber = 0;

void initState() {
super.initState();

_pageController = PageController();
}
..................
//inside build PageView
PageView(
controller: _pageController,
onPageChanged: (pageIndex) {
setState(() {
pageNumber = pageIndex;
});
},
children: <Widget>[
Notes(), // scaffold or widget or other class
Wochenplan(), scaffold or widget or other class
ETC(), // scaffold or widget or other class
],
),
..................
//inside build bottom nav icons
Row(
children: <Widget>[
buildTabButton(int currentIndex, int pageNumber, String image),
buildTabButton2....,
buildTabButton3...,
],
)
.......

buildTabButton1........

buildTabButton2(int currentIndex, int pageNumber, String image) {
return AnimatedContainer(
height: _height,
width: currentIndex == pageNumber ? 100 : 30,
padding: EdgeInsets.all(10),
duration: Duration(milliseconds: 300),
decoration: BoxDecoration(),// use currentIndex == pageNumber to decorate current widget and others
child: ../*ClickableWidget*/, //onClckWochenplan() // and so on
);
}

buildTabButton3........


........................
//onPressed or onTap functions which you can implement inside widgets as well..
void ABC() {
_pageController.animateToPage(0,
duration: Duration(milliseconds: 500), curve: Curves.decelerate);
}

void onClckWochenplan() {
_pageController.animateToPage(1,
duration: Duration(milliseconds: 500), curve: Curves.decelerate);
}

void DEF() {
_pageController.animateToPage(2,
duration: Duration(milliseconds: 500), curve: Curves.decelerate);
}


希望对您有所帮助。.否则请提供一些代码以从社区中获取帮助。

关于flutter - Flutter PageView删除页面指示器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59395316/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com