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

  • Dialog Packages

    A Dialog is a class that is intended to be subclassed by other classes. It’s often used to display messages on the page, or make choices available to the user. Flutter has a few built-in dialogs, but there are times when you need to build your own or use an existing package. adaptive_dialog Adaptively display…

  • Clipboard Packages

    A clipboard is one of the most important tools for a mobile phone user. A clipboard is a place where you can store information that you need quick access to or from. You can use those items to copy and paste them into a word processor, mail, chat program, or other function. clipboard This is…

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

  • Router and Navigation Packages

    fluro Fluro is a Flutter routing library that provides custom routing capabilities such as wildcards, named parameters, and clear route definitions. beamer The Router and Navigator’s Pages API, aka “Navigator 2.0,” enables you to traverse guarded page stacks and URLs via the Router and Navigator. shelf_router Supports URL parameters, nested routers, and router constructions generated…

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

  • Chart and Graph Packages

    We will go over some of the best Flutter packages that create charts and graphs so that you don’t have to waste time searching them out. graphic Graphic is the perfect Flutter library for anyone looking to visualize data in a clear, concise way. With its easy-to-use charting library, you’ll be able to create stunning…