Skip to content

Instantly share code, notes, and snippets.

@dhafinrayhan
Created January 31, 2024 16:45
Show Gist options
  • Save dhafinrayhan/a63f94e0bb09ed7a2334c09c79012f14 to your computer and use it in GitHub Desktop.
Save dhafinrayhan/a63f94e0bb09ed7a2334c09c79012f14 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
/// Flutter code sample for [PageView].
void main() => runApp(const PageViewExampleApp());
class PageViewExampleApp extends StatelessWidget {
const PageViewExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('PageView Sample')),
body: const PageViewExample(),
),
);
}
}
class PageViewExample extends StatelessWidget {
const PageViewExample({super.key});
@override
Widget build(BuildContext context) {
final PageController controller = PageController();
return PageView(
/// [PageView.scrollDirection] defaults to [Axis.horizontal].
/// Use [Axis.vertical] to scroll vertically.
controller: controller,
children: const <Widget>[
Column(
children: [
Text('First Page'),
TextField(),
],
),
Column(
children: [
Text('Second Page'),
TextField(),
],
),
Column(
children: [
Text('Third Page'),
TextField(),
],
),
],
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment