Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- void main() => runApp(MyApp());
- class MyApp extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- title: 'Flutter Demo',
- theme: ThemeData(
- primarySwatch: Colors.blue,
- ),
- home: MyHomePage(title: 'Flutter Demo Home Page'),
- );
- }
- }
- class MyHomePage extends StatefulWidget {
- MyHomePage({Key key, this.title}) : super(key: key);
- final String title;
- @override
- _MyHomePageState createState() => _MyHomePageState();
- }
- class _MyHomePageState extends State<MyHomePage> {
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: Text(widget.title),
- ),
- body: ListView.builder(
- itemBuilder: (c, i) {
- return _buildItem(i);
- },
- itemCount: 7,
- ),
- );
- }
- Widget _buildItem(int i) {
- switch (i) {
- case 0:
- return AspectRatio(
- aspectRatio: 872 / 370,
- child: Text(
- i.toString(),
- textAlign: TextAlign.center,
- ),
- );
- break;
- case 1:
- return GridView.builder(
- gridDelegate:
- SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4, childAspectRatio: 1 / 1),
- itemBuilder: (c, i) {
- return Text(
- i.toString(),
- textAlign: TextAlign.center,
- );
- },
- itemCount: 4,
- shrinkWrap: true,
- physics: NeverScrollableScrollPhysics(),
- );
- break;
- default:
- return GridView.builder(
- gridDelegate:
- SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 6 / 5),
- itemBuilder: (c, i) {
- return Text(
- i.toString(),
- textAlign: TextAlign.center,
- );
- },
- itemCount: 4,
- shrinkWrap: true,
- physics: NeverScrollableScrollPhysics(),
- );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement