From 49e50762c0443c4b086535dc86c5325f011fd107 Mon Sep 17 00:00:00 2001 From: Mitesh Singh Date: Sat, 12 Dec 2020 03:18:48 +0530 Subject: [PATCH] AdoptAWidget: PageView (#71174) --- .../flutter/lib/src/widgets/page_view.dart | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/packages/flutter/lib/src/widgets/page_view.dart b/packages/flutter/lib/src/widgets/page_view.dart index 4361975ee2..df661392cb 100644 --- a/packages/flutter/lib/src/widgets/page_view.dart +++ b/packages/flutter/lib/src/widgets/page_view.dart @@ -575,6 +575,35 @@ const PageScrollPhysics _kPagePhysics = PageScrollPhysics(); /// /// {@youtube 560 315 https://www.youtube.com/watch?v=J1gE9xvph-A} /// +/// {@tool dartpad --template=stateless_widget_scaffold} +/// +/// Here is an example of [PageView]. It creates a centered [Text] in each of the three pages +/// which scroll horizontally. +/// +/// ```dart +/// Widget build(BuildContext context) { +/// final controller = PageController(initialPage: 0); +/// return PageView( +/// /// [PageView.scrollDirection] defaults to [Axis.horizontal]. +/// /// Use [Axis.vertical] to scroll vertically. +/// scrollDirection: Axis.horizontal, +/// controller: controller, +/// children: [ +/// Center( +/// child: Text("First Page"), +/// ), +/// Center( +/// child: Text("Second Page"), +/// ), +/// Center( +/// child: Text("Third Page"), +/// ) +/// ], +/// ); +/// } +/// ``` +/// {@end-tool} +/// /// See also: /// /// * [PageController], which controls which page is visible in the view.