Commit d850d69c authored by Neevash Ramdial's avatar Neevash Ramdial Committed by Kate Lovett

Added tool sample for PageController (#34137)

* Added tool sample for PageController

* Fixed text directionality bug
parent 05e92c82
......@@ -36,6 +36,87 @@ import 'viewport.dart';
/// See also:
///
/// * [PageView], which is the widget this object controls.
///
/// {@tool sample}
///
/// This widget introduces a [MaterialApp], [Scaffold] and [PageView] with two pages
/// using the default constructor. Both pages contain a [RaisedButton] allowing you
/// to animate the [PageView] using a [PageController].
///
/// ```dart
/// class MyPageView extends StatefulWidget {
/// MyPageView({Key key}) : super(key: key);
///
/// _MyPageViewState createState() => _MyPageViewState();
/// }
///
/// class _MyPageViewState extends State<MyPageView> {
/// PageController _pageController;
///
/// @override
/// void initState() {
/// super.initState();
/// _pageController = PageController();
/// }
///
/// @override
/// void dispose() {
/// _pageController.dispose();
/// super.dispose();
/// }
///
/// @override
/// Widget build(BuildContext context) {
/// return MaterialApp(
/// home: Scaffold(
/// body: PageView(
/// controller: _pageController,
/// children: [
/// Container(
/// color: Colors.red,
/// child: Center(
/// child: RaisedButton(
/// color: Colors.white,
/// onPressed: () {
/// if (_pageController.hasClients) {
/// _pageController.animateToPage(
/// 1,
/// duration: const Duration(milliseconds: 400),
/// curve: Curves.easeInOut,
/// );
/// }
/// },
/// child: Text('Next'),
/// ),
/// ),
/// ),
/// Container(
/// color: Colors.blue,
/// child: Center(
/// child: RaisedButton(
/// color: Colors.white,
/// onPressed: () {
/// if (_pageController.hasClients) {
/// _pageController.animateToPage(
/// 0,
/// duration: const Duration(milliseconds: 400),
/// curve: Curves.easeInOut,
/// );
/// }
/// },
/// child: Text('Previous'),
/// ),
/// ),
/// ),
/// ],
/// ),
/// ),
/// );
/// }
/// }
///
/// ```
/// {@end-tool}
class PageController extends ScrollController {
/// Creates a page controller.
///
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment