Skip to content

Instantly share code, notes, and snippets.

@Abhilash-Chandran
Created April 28, 2021 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Abhilash-Chandran/312bdcdc6a6e9c70e33f5dd57467d4cb to your computer and use it in GitHub Desktop.
Save Abhilash-Chandran/312bdcdc6a6e9c70e33f5dd57467d4cb to your computer and use it in GitHub Desktop.
pageview with scrollbar.
/// 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