Last active
June 3, 2021 04:28
-
-
Save dhruvilp/1c45e8e27ef571258b7146cf9508dca6 to your computer and use it in GitHub Desktop.
Flutter_PageView
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file | |
| // for details. All rights reserved. Use of this source code is governed by a | |
| // BSD-style license that can be found in the LICENSE file. | |
| import 'package:flutter/material.dart'; | |
| void main() => runApp(MyApp()); | |
| class MyApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| title: 'Flutter Demo', | |
| debugShowCheckedModeBanner: false, | |
| theme: ThemeData( | |
| primarySwatch: Colors.indigo, | |
| ), | |
| home: MyHomePage(title: 'App Header'), | |
| ); | |
| } | |
| } | |
| class MyHomePage extends StatefulWidget { | |
| final String title; | |
| MyHomePage({Key? key, required this.title}) : super(key: key); | |
| @override | |
| _MyHomePageState createState() => _MyHomePageState(); | |
| } | |
| class _MyHomePageState extends State<MyHomePage> { | |
| final PageController controller = PageController(initialPage: 0); | |
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| appBar: AppBar( | |
| title: Text(widget.title), | |
| ), | |
| body: PageView( | |
| scrollDirection: Axis.vertical, | |
| controller: controller, | |
| pageSnapping: false, | |
| children: <Widget>[ | |
| Container( | |
| child: Center(child: Text('First Page')), | |
| color: Colors.pink.shade200, | |
| ), | |
| Container( | |
| child: Center(child: Text('Second Page')), | |
| color: Colors.yellow, | |
| ), | |
| Column( | |
| mainAxisAlignment: MainAxisAlignment.spaceEvenly, | |
| children: [ | |
| Flexible( | |
| flex: 5, | |
| child: Container( | |
| child: Center(child: Text('Third Page')), | |
| color: Colors.greenAccent, | |
| ), | |
| ), | |
| Flexible( | |
| flex: 1, | |
| child: Container( | |
| child: Center(child: Text('App Footer')), | |
| color: Colors.grey.shade400, | |
| ), | |
| ), | |
| ], | |
| ), | |
| ], | |
| ), | |
| floatingActionButton: FloatingActionButton( | |
| onPressed: () {}, | |
| tooltip: 'Increment', | |
| child: Icon(Icons.add), | |
| ), | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment