Created
June 8, 2018 23:00
-
-
Save manujbahl/209a275d6e81174be2e55ad2421b1fbf to your computer and use it in GitHub Desktop.
Flex layout issues.
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/material.dart'; | |
void main() { | |
runApp(new AnimatedListSample()); | |
} | |
class AnimatedListSample extends StatelessWidget{ | |
final GlobalKey<AnimatedListState> _listKey = | |
new GlobalKey<AnimatedListState>(); | |
// Used to build list items. | |
Widget _buildItem( | |
BuildContext context, int index, Animation<double> animation) { | |
var clr = Colors.blue; | |
if ( (index % 2) == 1 ) { | |
clr = Colors.red; | |
} | |
return new Container( | |
color: clr, | |
height: 100.0 | |
); | |
} | |
@override | |
Widget build(BuildContext context) { | |
var list = new AnimatedList( | |
key: _listKey, | |
initialItemCount: 3, | |
itemBuilder: _buildItem, | |
padding: new EdgeInsets.all(0.0), | |
); | |
var widget = new MaterialApp( | |
home: new Scaffold( | |
body: new Container( | |
color: Colors.white, | |
child: new Column( | |
children: <Widget>[ | |
new Container( | |
color: Colors.grey, | |
child: new Column( | |
children: <Widget>[ | |
new Expanded( child:list), | |
/* | |
My other widgets | |
*/ | |
], | |
) | |
), | |
/* | |
My other widgets | |
*/ | |
], | |
) | |
) | |
), | |
); | |
return widget; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment