Fireship · @fireship
Flutter Layouts for the CSS Developer
Uploaded February 1, 2019 · Length 10:24
Summary
Flutter layouts explained for web developers familiar with CSS, covering alignment, positioning, and flexible positioning.
- flutter layouts
- css developer
- flutter for web developers
- flutter alignment
- flutter positioning
- flutter flexible positioning
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
[Music]
- 0:06
if you want to be productive with
- 0:08
flutter one of the first things you
- 0:09
should master is layouts in today's
- 0:11
video I'll show you the core principles
- 0:12
for aligning and positioning widgets and
- 0:14
if your web developer I'll be making
- 0:16
direct comparisons to CSS because the
- 0:18
two share a lot more similarities than
- 0:19
you might realize if you new here like
- 0:21
and subscribe and you can grab the full
- 0:22
source code from fire ship i/o and I'll
- 0:24
be giving away another t-shirt with this
- 0:25
video all you have to do is leave a
- 0:26
comment below letting me know what you
- 0:28
want to see next the first thing we'll
- 0:29
look at is individual widget positioning
- 0:31
which is the equivalent to a div and
- 0:33
HTML with a CSS class applied to it from
- 0:35
there we'll look at how to layout
- 0:36
widgets and columns and rows which works
- 0:38
in the same way that flexbox does in CSS
- 0:40
and lastly we'll look at how to stack
- 0:42
wood just on top of each other which is
- 0:43
similar to absolute or fixed positioning
- 0:45
in CSS let's go ahead and jump into the
- 0:48
code and you'll see that I'm starting
- 0:49
out here with a scaffold which basically
- 0:51
gives us a point pallet to work with
- 0:52
then as the body I'm defining a
- 0:54
container that has a red border that'll
- 0:57
make it easy to visualize how child
- 0:58
elements fit within their parent
- 1:00
container then I've created a widget
- 1:01
called square which just has a fixed
- 1:03
width and height and we can pass in an
- 1:05
argument to adjust the size or the color
- 1:06
of the square this just gives us
- 1:08
something to work with as we start
- 1:10
aligning multiple items and quick
- 1:12
sidenote you'll notice I'm using font
- 1:13
awesome icons highly recommended if you
- 1:15
get bored with the default material
- 1:16
icons and then lastly we have a widget
- 1:18
called demo which we'll get to when we
- 1:20
start doing things with flexbox and
- 1:22
absolute positioning for now let's go
- 1:23
back up to the root container that we
- 1:25
define in the body you'll see that it's
- 1:26
sitting in the top left corner of the
- 1:28
view a container is a lot like a span or
- 1:30
a div and HTML in the sense that it's
- 1:32
just an empty piece of UI that you can
- 1:34
apply styles and positioning to let's
- 1:36
first add some spacing on the outside of
- 1:38
this element by setting a margin with
- 1:40
edge in sets to all sides of 24 and we
- 1:43
can increase that a bit to make it a
- 1:44
little more clear but basically it's
- 1:45
like putting an invisible border around
- 1:47
the entire container and up with the
- 1:49
equivalent CSS in the top right corner
- 1:50
here you can also set padding which will
- 1:53
put that invisible spacing on the inside
- 1:55
of the element so you'll notice that the
- 1:56
border gets pushed out and now the green
- 1:58
background on the container element is
- 1:59
visible you can apply spacing to


