Created
June 18, 2021 15:30
-
-
Save imaNNeo/ac18a4c8816be384a4adfe3f8c56c135 to your computer and use it in GitHub Desktop.
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'; | |
import 'package:flutter/widgets.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
// This widget is the root of your application. | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: MyHomePage(), | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
const MyHomePage({Key? key}) : super(key: key); | |
@override | |
_MyHomePageState createState() => _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: Center( | |
child: AspectRatio( | |
aspectRatio: 2.0, | |
child: PageView( | |
controller: PageController( | |
initialPage: 1, | |
viewportFraction: 0.6, | |
), | |
children: [ | |
ColoredBox(color: Colors.red), | |
ColoredBox(color: Colors.green), | |
ColoredBox(color: Colors.blue), | |
], | |
), | |
), | |
), | |
); | |
} | |
} | |
class ColoredBox extends StatelessWidget { | |
final Color color; | |
const ColoredBox({Key? key, required this.color}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
color: color, | |
margin: EdgeInsets.all(24), | |
); | |
} | |
} |
Author
imaNNeo
commented
Jun 18, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment