Set Min Width and Min Height of a Container

In some cases, you may need to set a minimum width and height for a Container. These examples will show you how to do this using the minWidth and minHeight properties of the Container widget to limit the padding within a Container.

BoxConstraints is the class which defines min and max size for box layout.

Container(
          color: Colors.orange,
          constraints: BoxConstraints(
              minHeight: 200, minWidth: double.infinity),
          child: ListView(
            shrinkWrap: true,
            children: [
              ...List.generate(
                100,  
                (index) => Text(
                  'Text: ${index}'
                ),
              ),
            ],
          ),
        )
@override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.fromLTRB(0, 8.0, 0, 8.0),
      child: Container(
        padding: const EdgeInsets.all(8.0),
        decoration: BoxDecoration(
            color: MyTheme.cardColor,
            border: Border.all(
              color: MyTheme.cardColor,
            ),
            borderRadius: MyTheme.radius),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Expanded(
              flex: 9,
              child: Column(
                mainAxisAlignment: MainAxisAlignment.start,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  RowField(
                      left: LabelValue(
                          label: "Qty",
                          value: _showQty(stockQuant!.purchase_qty,
                              stockQuant!.purchase_uom[1])),
                      right: LabelValue(
                          label: "Loose Qty",
                          value: _showQty(stockQuant!.loose_qty,
                              stockQuant!.product_uom[1])),
                      flexes: [5, 5]),
                  RowField(
                      left: LabelValue(
                          label: "Location", value: stockQuant!.location_id[1]),
                      right: LabelValue(
                          label: "Lot", value: stockQuant!.lot_id[1]),
                      flexes: [5, 5]),
                ],
              ),
            ),
            Expanded(child: IconButton(onPressed: () {
              Navigator.push(
                context,
                MaterialPageRoute(builder: (context) => ProductMovePage(product: product, stockQuant: stockQuant)),
              );
            }, icon: Icon(Icons.add_task , color: MyTheme.highlightColor)), flex: 1)
          ],
        ),
      ),
    );
  }

Similar Posts

  • Flutter Projects for Beginners

    If you’re just getting started with Flutter, you might be feeling a little overwhelmed. There are so many different things to learn, and it can be hard to know where to start. That’s why we’ve put together this list of 8 Flutter projects for beginners. These projects will help you get comfortable with the basics…

  • Rich Text Editors

    flutter_markdown This package is a Markdown editor for Flutter. From plain text data formatted with simple Markdown tags, you may produce rich text output including text styles, tables, links, and more. markdown markdown is a Dart library that can convert Markdown to HTML. zefyr Flutter’s clean, minimalistic, and collaboration-ready rich text editor. zefyrka This editor…

  • Date and Calendar Packages

    date_format The date_format is an easy-to use API that provides several constants for building your own Date format string. Use the `formatDate` method to create customised dates, and be sure they look good on any device! It provides various constants that you can use when building your Date string with the formatDate method, so it’s…

  • Text Packages

    One of the benefits of using Flutter is its rich graphical system, which makes it easy for developers to make their app look great with very little effort. To help you get started, we’ve put together this roundup of some of our favorite packages and libraries for creating beautiful text layouts with Flutter! flutter_typeahead A…

  • Packages to Scan Barcode and QR

    flutter_barcode_scanner A plugin for Android and iOS that enables barcode scanning. Barcodes, QR codes, and other types of coding are all supported. qr_flutter A Widget or custom painter may be used to display QR codes for Flutter. qr_code_scanner The zxing library is a QR code scanner that can be integrated into flutter. It makes use…