what is flex in flexible flutter code example

Example 1: flutter flex

Row(
  children:[
    Expanded(
      flex: 9,
      child: Container(
              color: Colors.red,
              child: Text(
            'Flex 9'
          ),), //Replace with your child widget
          ),
    Expanded(
      flex: 3,
      child:  Container(
              color: Colors.red,
        child: Text(
            'Flex 3'
          ),
      ), //Replace with your child widget
      ),
  ],
)

Example 2: flexible widget flutter

Row(children:[
  Flexible(
  flex:5
    child: Container(color: Colors.red, child: Text('This is a very long text that won’t fit the line.'))),
  Flexible(
  flex:5
    child: Container(color: Colors.green, child: Text(‘Goodbye!))),
  ]
)

Tags:

Dart Example