Skip to content

Instantly share code, notes, and snippets.

@imaNNeo
Created June 18, 2021 15:30
Show Gist options
  • Save imaNNeo/ac18a4c8816be384a4adfe3f8c56c135 to your computer and use it in GitHub Desktop.
Save imaNNeo/ac18a4c8816be384a4adfe3f8c56c135 to your computer and use it in GitHub Desktop.
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),
);
}
}
@imaNNeo
Copy link
Author

imaNNeo commented Jun 18, 2021

1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment