Repository navigation
Layout, Screen
ArtemMikhaylov edited this page Jan 30, 2020
·
13 revisions
-
https://stackoverflow.com/a/56575657/3165400
For android just add this to
MainActivityinManifest
android:screenOrientation="portrait"And for ios, set portrait orientation in XCode
- See
LayoutBuilderhttps://www.youtube.com/watch?v=IYDVcriKjsw - See
MediaQueryhttps://www.youtube.com/watch?v=A3WrA4zAaPw
-
ContainerorScaffoldas screen root widget will match parent. -
RowandColumn(and any others which have nobackgroundColorattribute) as root widgets: I don't see any way to reliably check how they draw themselves as screen root widgets since they have nobackgroundColorattribute. - Containers inside Align center inside Raw(as root screen layout) and without any size and children - wraps content, e.g. not visible as dot.
-
Column- is aka LinearLayout with vertical orientation, wrap_content by default, -
Expanded- it's like we set weight for the child of the LinearLayout, 1 by default. -
Container- with
width: MediaQuery.of(context).size.widthwe use to make both body Column and its child to match_parent by width.Columndoesn't have awithattribute. Only the first child matches the parent. All others still wrap_content by default, and gravity center horizontal by default. - And to set a background color (
Columndoesn't have such an attribute). - To set margin, neither
columnnorImagedoesn't have themarginattribute. In a more general case, you should wrap widget withPaddingwidget to set paddings.Containerhowever has both, margin and padding attributes. Probably padding attribute just wraps child widget withPaddingwidget. See more https://stackoverflow.com/a/53679108/3165400
- with
body: Column(
children: <Widget>[
Expanded(
child: Container(
child: Column(
children: <Widget>[
Image(
image: AssetImage('images/logo.png'),
),
],
),
margin: const EdgeInsets.only(top: 64),
width: MediaQuery.of(context).size.width,
color: Colors.amber.shade500,
)
),
Column(