Created
December 15, 2019 15:33
-
-
Save ananevam/a6839358291d1fa45d2d6eb658dd5a2d to your computer and use it in GitHub Desktop.
This file contains 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/cupertino.dart'; | |
main() => runApp(new CupertinoApp( | |
home: App() | |
) | |
); | |
class App extends StatefulWidget { | |
@override | |
State<StatefulWidget> createState() { | |
return _AppState(); | |
} | |
} | |
class _AppState extends State<App> { | |
@override | |
Widget build(BuildContext context) { | |
return CupertinoTabScaffold( | |
tabBar: CupertinoTabBar(items: [ | |
BottomNavigationBarItem( | |
icon: Icon(CupertinoIcons.home), title: Text("Home")), | |
BottomNavigationBarItem( | |
icon: Icon(CupertinoIcons.home), title: Text("Explore")), | |
]), | |
tabBuilder: (context, index) { | |
switch (index) { | |
case 0: | |
return HomeScreen(); | |
break; | |
case 1: | |
return HomeScreen(); | |
break; | |
default: | |
return HomeScreen(); | |
break; | |
} | |
}, | |
); | |
} | |
} | |
class HomeScreen extends StatefulWidget { | |
@override | |
createState() => _HomeScreen(); | |
} | |
class _HomeScreen extends State<HomeScreen> { | |
Widget get _scrollView { | |
return LayoutBuilder( | |
builder: (BuildContext context, BoxConstraints viewportConstraints) { | |
return SingleChildScrollView( | |
physics: AlwaysScrollableScrollPhysics(), | |
child: ConstrainedBox( | |
constraints: BoxConstraints( | |
minHeight: viewportConstraints.maxHeight, | |
), | |
child: SafeArea( | |
child: Column(children: [ | |
Text("foo"), | |
GridView.count( | |
scrollDirection: Axis.horizontal, | |
physics: AlwaysScrollableScrollPhysics(), | |
shrinkWrap: true, | |
crossAxisCount: 2, | |
//padding: EdgeInsets.all(4.0), | |
childAspectRatio: 8.0 / 9.0, | |
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: _scrollView); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment