How To Use Limited Box Widget Using Flutter Android App

admin_img Posted By Bajarangi soft , Posted On 02-11-2020

A box that limits its size only when it's unconstrained.If this widget's maximum width is unconstrained then its child's width is limited to maxWidth. Similarly, if this widget's maximum height is unconstrained then its child's height is limited to maxHeight.This has the effect of giving the child a natural dimension in unbounded environments. For example, by providing a maxHeight to a widget that normally tries to be as big as possible, the widget will normally size itself to fit its parent, but when placed in a vertical list, it will take on the given height.

How To Use Limited Box Widget Using Flutter Android App

Limited Box Widget
Complete Code For LimitedBox Widget In Flutter
main.dart

import 'package:flutter/material.dart';

void main(){
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.red[700],
          title: Text("LimitedBox Widget"
          )),
      body: Center(
        child: LimitedBox(
          child: Container(
            color: Colors.red[800],
          ),
        ),
      ),
    );
  }
}

Related Post