Expanded widget inside Column not expanded instead it’s got invisible. Actually quite the opposite, if you’re planning to use this as an item in a listViewyou can’t let infinite size on the same axis your listView is scrolling. Let me explain: Currently you’re not defining any height on your cell() widget, which is fine if you’re using it alone.
Here is an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | import 'package:flutter/material.dart'; void main() { runApp(MaterialApp( title: 'layout test', home: Layout_test_class(), )); } class Layout_test_class extends StatelessWidget { Widget cell() { return Container( color: Colors.yellow, //height: 250, after un commenting this will work. but i want to make it without this child: Row( crossAxisAlignment: CrossAxisAlignment.end, mainAxisSize: MainAxisSize.max, children: <Widget>[ Expanded( child: Column( mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ Expanded( child: Container( color: Colors.green, child: Text('apple z'), ), ), Container( color: Colors.red, child: Text('apple 2'), ) ], ), ), Column( children: <Widget>[ Container( color: Colors.black, width: 200, height: 200, ), ], ), ], ), ); } @override Widget build(BuildContext context) { // TODO: implement build return Scaffold( appBar: AppBar( title: Text('title'), ), body: cell(), ); } } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.