Skip to content

Instantly share code, notes, and snippets.

@ananevam
Created December 17, 2019 18:11
Show Gist options
  • Save ananevam/2f8ef151e4ed7e1a376f6476165b503d to your computer and use it in GitHub Desktop.
Save ananevam/2f8ef151e4ed7e1a376f6476165b503d to your computer and use it in GitHub Desktop.
import 'package:flutter/cupertino.dart';
main() => runApp(new CupertinoApp(
home: HomeScreen()
)
);
class HomeScreen extends StatelessWidget {
Widget get _list {
return GridView.count(
scrollDirection: Axis.horizontal,
physics: AlwaysScrollableScrollPhysics(),
shrinkWrap: true,
crossAxisCount: 2,
children: List<String>.generate(100, (i) => "Item $i")
.map((item) => Column(children: [
Container(
width: 100,
height: 100,
color: CupertinoColors.destructiveRed),
Text(item),
]))
.toList(),
);
}
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
//navigationBar: CupertinoNavigationBar(middle: Text("Welcome")),
child: _list);
}
}
@PlugFox
Copy link

PlugFox commented Dec 17, 2019

import 'package:flutter/cupertino.dart';

main() => runApp(new CupertinoApp(home: HomeScreen()));

class HomeScreen extends StatelessWidget {
  Widget get _list {
    return SingleChildScrollView(
      scrollDirection: Axis.horizontal,
      physics: AlwaysScrollableScrollPhysics(),
      child: Row(
        children: List<Map<int, String>>.generate(
                50,
                (int _i) => <int, String>{
                      1: "Item ${_i * 2}",
                      2: "Item ${_i * 2 + 1}",
                    })
            .map<Widget>(
              (Map<int, String> _map) => Column(
                children: [
                  Container(
                      width: 100,
                      height: 100,
                      color: CupertinoColors.destructiveRed),
                  Text(_map[1]),
                  Container(
                      width: 100,
                      height: 100,
                      color: CupertinoColors.destructiveRed),
                  Text(_map[2]),
                ],
              ),
            )
            .toList(),
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
        backgroundColor: Color(0xFF0000FF),
        child: _list);
  }
}

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