rajath_pai

ninja14 Expand & flex

Jul 30th, 2021
984
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import 'package:flutter/material.dart';
  2.  
  3. void main() => runApp(MaterialApp(
  4.       home: Home(),
  5.     ));
  6.  
  7. class Home extends StatelessWidget {
  8.   @override
  9.   Widget build(BuildContext context) {
  10.     return Scaffold(
  11.       appBar: AppBar(
  12.         title: Text(
  13.           'App bar',
  14.           style: TextStyle(color: Colors.white),
  15.         ),
  16.         centerTitle: true,
  17.         backgroundColor: Colors.red,
  18.       ),
  19.       body: Row(
  20. //         mainAxisAlignment : MainAxisAlignment.end,
  21. //         crossAxisAlignment : CrossAxisAlignment.start,
  22.         children :  <Widget>[
  23.           //Expanded use case => used to display within given boundary
  24.           Expanded(
  25.             child : Image.network('https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT5fekdY7QzAbN4Dvy_xIJHUbiyBNXn3qvUIw&usqp=CAU'),
  26.             flex : 3
  27.           ),
  28.           Expanded(   //use to expand so that there is no space left in between Widgets
  29.             flex : 3, //proportion that's needede to be flexed
  30.             child : Container(
  31.               padding : EdgeInsets.all(30.0),
  32.               color : Colors.blue,
  33.               child : Text('1'),
  34.               ),
  35.           ),
  36.           Expanded(   //use to expand so that there is no space left in between Widgets
  37.             flex : 2, //proportion that's needede to be flexed
  38.             child : Container(
  39.               padding : EdgeInsets.all(30.0),
  40.               color : Colors.green,
  41.               child : Text('2'),
  42.               ),
  43.           ),
  44.           Expanded(   //use to expand so that there is no space left in between Widgets
  45.             flex : 1, //proportion that's needede to be flexed
  46.             child : Container(
  47.               padding : EdgeInsets.all(30.0),
  48.               color : Colors.orange,
  49.               child : Text('3'),
  50.               ),
  51.           ),
  52.         ],
  53.       ),
  54.       floatingActionButton: FloatingActionButton(
  55.         child: Text('click me'),
  56.         onPressed: null,
  57.         backgroundColor: Colors.red,
  58.       ),
  59.     );
  60.   }
  61. }
  62.  
RAW Paste Data