Created
April 28, 2021 09:29
-
-
Save Abhilash-Chandran/312bdcdc6a6e9c70e33f5dd57467d4cb to your computer and use it in GitHub Desktop.
pageview with scrollbar.
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
/// Flutter code sample for PageView | |
// Here is an example of [PageView]. It creates a centered [Text] in each of the three pages | |
// which scroll horizontally. | |
import 'package:flutter/material.dart'; | |
void main() => runApp(const MyApp()); | |
/// This is the main application widget. | |
class MyApp extends StatelessWidget { | |
const MyApp({Key? key}) : super(key: key); | |
static const String _title = 'Flutter Code Sample'; | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: _title, | |
home: Scaffold( | |
appBar: AppBar(title: const Text(_title)), | |
body: const MyStatelessWidget(), | |
), | |
); | |
} | |
} | |
/// This is the stateless widget that the main application instantiates. | |
class MyStatelessWidget extends StatelessWidget { | |
const MyStatelessWidget({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
final PageController pageController = PageController(initialPage: 0); | |
return Scrollbar( | |
controller: pageController, | |
isAlwaysShown: true, | |
thickness: 10, | |
showTrackOnHover: true, | |
hoverThickness: 15, | |
radius: Radius.circular(0), | |
child: PageView( | |
scrollDirection: Axis.vertical, | |
controller: pageController, | |
children: const <Widget>[ | |
Center( | |
child: Text('First Page'), | |
), | |
Center( | |
child: Text('Second Page'), | |
), | |
Center( | |
child: Text('Third Page'), | |
) | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment