Created
December 28, 2022 11:20
-
-
Save RyouMon/27c540ea528585a3274c83a7f57f8bf8 to your computer and use it in GitHub Desktop.
Flutter Demo: PageView Example
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
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(const MyApp()); | |
} | |
class NumberPageView extends StatefulWidget { | |
const NumberPageView({super.key}); | |
@override | |
State<NumberPageView> createState() => _NumberPageViewState(); | |
} | |
class _NumberPageViewState extends State<NumberPageView> { | |
@override | |
Widget build(BuildContext context) { | |
return PageView( | |
children: const [ | |
Center(child: Text("1", textScaleFactor: 10)), | |
Center(child: Text("2", textScaleFactor: 10)), | |
Center(child: Text("3", textScaleFactor: 10)), | |
], | |
); | |
} | |
} | |
class HomePage extends StatelessWidget { | |
const HomePage({super.key, required this.title}); | |
final String title; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(title: Text(title)), | |
body: const NumberPageView(), | |
); | |
} | |
} | |
class MyApp extends StatelessWidget { | |
const MyApp({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: const HomePage(title: 'PageView Example'), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment