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

  • Image Libraries

    octo_image The octo_image is a Flutter image widget that may perform various tasks. Placeholders, error indicators, and image transformers with fading are all supported. A placeholder, a progress indicator, an ImageBuilder, or an error widget is required for the OctoImage widget to display the picture. A placeholder or a progress indication may be used, as…

  • State Manager

    If you are new to Flutter and state management, I suggest using riverpod package. Provider and Riverpod are both good. provider InheritedWidget are snippets of code that allow you to reuse and easily add functionality to widgets. This package adds a wrapper around it so they’re easier to use and more reusable. Too often when…

  • Picture-in-Picture Packages

    A Picture-in-Picture (PIP) is a small, frame that floats out of the main video and stays on top of it. It can be used to display anything like: Knowing the different purposes behind PIP will help you understand which package suits your needs best. flutter_android_pip With the SDK 24 or above, you may integrate Picture-in-Picture…

  • Best Flutter Tools

    If you want to get the most out of your experience with this incredible platform then I recommend checking out these awesome tools! Flutter Editors Android Studio Android Studio is an IDE (Integrated Development Environment) for developing a mobile application using Dart/Flutter, Java/Kotlin or C/C++ language on Linux, macOS and Windows operating systems. Visual Studio…

  • Font and Emoji Packages

    font_awesome_flutter The Font Awesome Icon pack is available as Flutter Icons. It adds 1500 additional icons to your app, in addition to the default set of 500. flutter_font_icons As the name suggests, this is a collection of font icons built with Flutter. It includes all fonts from react-native-vector-icons and WeatherIcons. icon_font_generator Convert all icons in…