flutterdartflutter-layoutflutter-widget

Flutter: Expanded vs Flexible


I've used both Expanded and Flexible widgets and they both seem to work the same.

What is the difference between Expanded and Flexible?


Solution

  • Scaffold(
      appBar: AppBar(),
      body: Column(
        children: <Widget>[
          Row(
            children: <Widget>[
              buildExpanded(),
              buildFlexible(),
            ],
          ),
          Row(
            children: <Widget>[
              buildExpanded(),
              buildExpanded(),
            ],
          ),
          Row(
            children: <Widget>[
              buildFlexible(),
              buildFlexible(),
            ],
          ),
        ],
      ),
    );
    

    enter image description here