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

  • 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…

  • Bottom Bar Packages

    convex_bottom_bar The ConvexAppBar is a Flutter package that creates and shows a convex tab in the bottom bar. Theming is supported. persistent_bottom_nav_bar For Flutter, a complete, highly configurable bottom navigation bar that is persistent/static and can be used for any application. It has up to 20 different styles. salomon_bottom_bar Another bottom navigation bar, but this…

  • Floating Action Button Packages

    simple_speed_dial A simple Flutter speed dial. You may add as many speed dial alternatives as you wish. Labels may be added beside the options. Every FAB’s color can be customized. draggable_fab The FAB wrapper widget may be dragged to any edge of the screen and is draggable. curved_nav_bar The left and right side of the…

  • Shared Preferences Packages

    shared_preferences The Flutter plugin for reading and writing simple key-value pairs wraps NSUserDefaults on iOS and SharedPreferences on Android. rx_shared_preferences Preference updates for the rxdart streaming service are communicated via Reactive Streams. The SharedPreference wrapper is reactive stream rxdart. A stream-based wrapper around shared preferences that allows for reactively stored key-value pairs. shared_preferences_dtx The shared…

  • Animation Packages

    flutter_animate Flutter Animate is a library that makes it simple to add almost any kind of animated effect in Flutter. The library comes with a variety of pre-built effects, like fade, scale, slide, blur, shake, shimmer, and color effects (saturation and tint), that can be easily added to your app. In addition, Flutter Animate simplifies…

  • Monetization Packages

    google_mobile_ads Google Mobile Ads may use the Flutter plugin, which supports banner, interstitial (full-screen), rewarded and native advertisements. unity_ads_plugin The Unity Ads plugin for Flutter Applications is a mobile game advertising platform. This plugin can show both Unity Banner Ads and Unity Video Ads. appodeal_flutter Appodeal is a Flutter plugin that displays advertisements on the…