我試圖給 ToggleButtons pageController,但它不起作用。
uj5u.com熱心網友回復:
pageView您可以像這樣滾動Switch切換:
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Center(
child: ToggleButtons(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'1',
style: TextStyle(fontSize: 16),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'2',
style: TextStyle(fontSize: 16),
),
),
],
onPressed: (int index) {
setState(() {
if (index == 1) {
controller.nextPage(
duration: Duration(milliseconds: 300),
curve: Curves.easeInOut);
} else {
controller.previousPage(
duration: Duration(milliseconds: 300),
curve: Curves.easeInOut);
}
for (int i = 0; i < isSelected.length; i ) {
isSelected[i] = i == index;
}
});
},
isSelected: isSelected,
),
),
Expanded(
child: PageView(
controller: controller,
children: [
Container(
color: Colors.red,
),
Container(
color: Colors.yellow,
),
],
),
),
],
)

轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/516794.html
標籤:扑镖颤振布局
上一篇:使用.contains()會產生多少讀取?-顫振/火力基地
下一篇:如何將整個串列傳遞到新頁面
