Fireship · @fireship

Flutter Layouts for the CSS Developer

Uploaded February 1, 2019 · Length 10:24

Flutter Layouts for the CSS Developer

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.

  1. 0:00

    [Music]

  2. 0:06

    if you want to be productive with

  3. 0:08

    flutter one of the first things you

  4. 0:09

    should master is layouts in today's

  5. 0:11

    video I'll show you the core principles

  6. 0:12

    for aligning and positioning widgets and

  7. 0:14

    if your web developer I'll be making

  8. 0:16

    direct comparisons to CSS because the

  9. 0:18

    two share a lot more similarities than

  10. 0:19

    you might realize if you new here like

  11. 0:21

    and subscribe and you can grab the full

  12. 0:22

    source code from fire ship i/o and I'll

  13. 0:24

    be giving away another t-shirt with this

  14. 0:25

    video all you have to do is leave a

  15. 0:26

    comment below letting me know what you

  16. 0:28

    want to see next the first thing we'll

  17. 0:29

    look at is individual widget positioning

  18. 0:31

    which is the equivalent to a div and

  19. 0:33

    HTML with a CSS class applied to it from

  20. 0:35

    there we'll look at how to layout

  21. 0:36

    widgets and columns and rows which works

  22. 0:38

    in the same way that flexbox does in CSS

  23. 0:40

    and lastly we'll look at how to stack

  24. 0:42

    wood just on top of each other which is

  25. 0:43

    similar to absolute or fixed positioning

  26. 0:45

    in CSS let's go ahead and jump into the

  27. 0:48

    code and you'll see that I'm starting

  28. 0:49

    out here with a scaffold which basically

  29. 0:51

    gives us a point pallet to work with

  30. 0:52

    then as the body I'm defining a

  31. 0:54

    container that has a red border that'll

  32. 0:57

    make it easy to visualize how child

  33. 0:58

    elements fit within their parent

  34. 1:00

    container then I've created a widget

  35. 1:01

    called square which just has a fixed

  36. 1:03

    width and height and we can pass in an

  37. 1:05

    argument to adjust the size or the color

  38. 1:06

    of the square this just gives us

  39. 1:08

    something to work with as we start

  40. 1:10

    aligning multiple items and quick

  41. 1:12

    sidenote you'll notice I'm using font

  42. 1:13

    awesome icons highly recommended if you

  43. 1:15

    get bored with the default material

  44. 1:16

    icons and then lastly we have a widget

  45. 1:18

    called demo which we'll get to when we

  46. 1:20

    start doing things with flexbox and

  47. 1:22

    absolute positioning for now let's go

  48. 1:23

    back up to the root container that we

  49. 1:25

    define in the body you'll see that it's

  50. 1:26

    sitting in the top left corner of the

  51. 1:28

    view a container is a lot like a span or

  52. 1:30

    a div and HTML in the sense that it's

  53. 1:32

    just an empty piece of UI that you can

  54. 1:34

    apply styles and positioning to let's

  55. 1:36

    first add some spacing on the outside of

  56. 1:38

    this element by setting a margin with

  57. 1:40

    edge in sets to all sides of 24 and we

  58. 1:43

    can increase that a bit to make it a

  59. 1:44

    little more clear but basically it's

  60. 1:45

    like putting an invisible border around

  61. 1:47

    the entire container and up with the

  62. 1:49

    equivalent CSS in the top right corner

  63. 1:50

    here you can also set padding which will

  64. 1:53

    put that invisible spacing on the inside

  65. 1:55

    of the element so you'll notice that the

  66. 1:56

    border gets pushed out and now the green

  67. 1:58

    background on the container element is

  68. 1:59

    visible you can apply spacing to