minwidth for expanded flutter code example

Example 1: flutter set widget width to 50% o parent


  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("MediaQuery"),
      ),
      body: Container(
        width: MediaQuery.of(context).size.width * 0.5,
        height: MediaQuery.of(context).size.height * 0.5,
      ),
    );
  }

Example 2: flutter column min height screen sixe

import 'dart:math'; // for max function

// Add the following around your column
LayoutBuilder(
  builder: (BuildContext context, BoxConstraints constraints) {
    return SingleChildScrollView(
      child: ConstrainedBox(
        constraints: BoxConstraints.tightFor(height: max(500, constraints.maxHeight)),
        child: Column(), // your column
      ),
    );
  },
);

Tags:

Dart Example