Skip to content

Instantly share code, notes, and snippets.

@manujbahl
Created June 8, 2018 23:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manujbahl/209a275d6e81174be2e55ad2421b1fbf to your computer and use it in GitHub Desktop.
Save manujbahl/209a275d6e81174be2e55ad2421b1fbf to your computer and use it in GitHub Desktop.
Flex layout issues.
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