-
-
Save dmasotti/d2bee9752d34be56cdb65bb446044e83 to your computer and use it in GitHub Desktop.
Column Builder for Flutter. Can be used instead of a ListView with shrinkWrap.
This file contains hidden or 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
class ColumnBuilder extends StatelessWidget { | |
final IndexedWidgetBuilder itemBuilder; | |
final MainAxisAlignment mainAxisAlignment; | |
final MainAxisSize mainAxisSize; | |
final CrossAxisAlignment crossAxisAlignment; | |
final TextDirection textDirection; | |
final VerticalDirection verticalDirection; | |
final int itemCount; | |
const ColumnBuilder({ | |
Key key, | |
@required this.itemBuilder, | |
@required this.itemCount, | |
this.mainAxisAlignment: MainAxisAlignment.start, | |
this.mainAxisSize: MainAxisSize.max, | |
this.crossAxisAlignment: CrossAxisAlignment.center, | |
this.textDirection, | |
this.verticalDirection: VerticalDirection.down, | |
}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return new Column( | |
children: new List.generate(this.itemCount, | |
(index) => this.itemBuilder(context, index)).toList(), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment