本篇內(nèi)容主要講解“怎么實現(xiàn)PageView滑動視圖Flutter”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“怎么實現(xiàn)PageView滑動視圖Flutter”吧!
創(chuàng)新互聯(lián)專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于做網(wǎng)站、網(wǎng)站建設(shè)、望都網(wǎng)絡(luò)推廣、小程序開發(fā)、望都網(wǎng)絡(luò)營銷、望都企業(yè)策劃、望都品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務(wù),您的肯定,是我們最大的嘉獎;創(chuàng)新互聯(lián)為所有大學生創(chuàng)業(yè)者提供望都建站搭建服務(wù),24小時服務(wù)熱線:18980820575,官方網(wǎng)址:sd-ha.com
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; void main()=>runApp(MaterialApp( home: MyApp(), )); //創(chuàng)建一個PageController,方便使用底部導航欄改變PageView的內(nèi)容 PageController _pageController = new PageController(); int _curIndex = 0;//當前索引 //純色頁面,用Page類構(gòu)造函數(shù)批量生成 var pages = <Widget>[ Page(Colors.orange), Page(Colors.purple), Page(Colors.green) ]; class Page extends StatelessWidget { Color c; Page(this.c); @override Widget build(BuildContext context) { return Scaffold( body: Container(color: c,), ); } } class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State<MyApp> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("滑動"), ), //PageView滑動界面 [https://www.jianshu.com/p/036c3b865820] body: PageView.builder( controller: _pageController, itemBuilder: (context,index) => pages[index], itemCount: pages.length, //當滑動的時候改變當前索引,并刷新界面 onPageChanged: (index){ setState(() { _curIndex = index; }); }, ), //創(chuàng)建底部導航欄 bottomNavigationBar: BottomNavigationBar( items: [ BottomNavigationBarItem( title: Text("Orange"), icon:Icon(Icons.star) ), BottomNavigationBarItem( title: Text("Purple"), icon:Icon(Icons.star) ), BottomNavigationBarItem( title: Text("Green"), icon:Icon(Icons.star) ) ], currentIndex: _curIndex, //在導航欄中利用Controller改變PageView onTap: (index){ _pageController.jumpToPage(index); } ), ); } }
到此,相信大家對“怎么實現(xiàn)PageView滑動視圖Flutter”有了更深的了解,不妨來實際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進入相關(guān)頻道進行查詢,關(guān)注我們,繼續(xù)學習!
網(wǎng)頁名稱:怎么實現(xiàn)PageView滑動視圖Flutter
文章出自:http://sd-ha.com/article10/popigo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站制作、自適應(yīng)網(wǎng)站、軟件開發(fā)、網(wǎng)站設(shè)計公司、用戶體驗、網(wǎng)站改版
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)