Fireship · @fireship

Top 12 Flutter Tips & Tricks

Uploaded June 3, 2019 · Length 9:32

Top 12 Flutter Tips & Tricks

Summary

Learn 12 Flutter tips and tricks for building efficient and maintainable apps, including code auto-completion, refactor tool, animations, and performance optimization.

  • flutter development
  • flutter tips and tricks
  • flutter animations
  • flutter performance optimization
  • dart programming
  • flutter widgets
  • flutter ui design

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    you may have heard the flutter is almost

  2. 0:01

    like magic when it comes to building

  3. 0:03

    native apps so you decided to jump on

  4. 0:05

    the flutter train but now you find

  5. 0:06

    yourself

  6. 0:06

    refactoring this giant nested nightmare

  7. 0:08

    of widgets luckily flutter has a whole

  8. 0:10

    bunch of tricks up its sleeve so you

  9. 0:12

    should never have to battle with code

  10. 0:13

    like this in today's video we'll look at

  11. 0:15

    12 different strategies for building

  12. 0:16

    efficient and maintainable flutter apps

  13. 0:18

    if you're new here like and subscribe

  14. 0:20

    and leave a comment below for a chance

  15. 0:21

    to win this t-shirt or my first trick

  16. 0:23

    I'll show you how to write code

  17. 0:25

    automatically using nothing but the tab

  18. 0:27

    key in the mouse I talked about this in

  19. 0:29

    detail in my full flutter course which

  20. 0:30

    you can access as a pro member but there

  21. 0:32

    are a few things that you absolutely

  22. 0:33

    must know if we take a look at this code

  23. 0:35

    snippet you can see a lot of closing

  24. 0:37

    tags on a single line making it very

  25. 0:39

    hard to understand but you can easily

  26. 0:40

    fix this by adding trailing commas to

  27. 0:42

    your arguments and lists and the end

  28. 0:44

    result is an easy to read tree structure

  29. 0:46

    when we format the file but doing this

  30. 0:48

    manually all the time would get really

  31. 0:49

    annoying that's why you should get

  32. 0:50

    really good at using the tab key because

  33. 0:52

    the tooling is so good in dart and

  34. 0:54

    flutter that almost everything can be

  35. 0:55

    auto-completed with intellisense just

  36. 0:57

    hover over the thing you want hit tab

  37. 0:58

    and the trailing column will be added

  38. 1:00

    for you

  39. 1:01

    [Music]

  40. 1:07

    but the most powerful tool you have at

  41. 1:09

    your disposal is the refactor tool it

  42. 1:11

    allows us to insert new widgets into the

  43. 1:13

    widget tree especially commonly used

  44. 1:15

    ones like container and center and we

  45. 1:16

    can also use it to remove widgets

  46. 1:17

    without having to think about where the

  47. 1:19

    opening and closing characters are and

  48. 1:21

    if the widget tree starts to become too

  49. 1:22

    deeply nested that usually means we need

  50. 1:24

    to refactor out into our own state list

  51. 1:26

    or stateful widget and the refactor tool

  52. 1:28

    can easily handle that while also

  53. 1:29

    setting up a constructor with the

  54. 1:31

    necessary input properties so you should

  55. 1:33

    really never have to write a custom

  56. 1:34

    widget from scratch now tip number two I

  57. 1:37

    learned from Robert Brune heggs YouTube

  58. 1:38

    channel which you should definitely be

  59. 1:39

    subscribed to if you're using flutter

  60. 1:41

    you won't be able to use the vs code

  61. 1:43

    refactor tool in every situation but

  62. 1:44

    there's still a few things you can do to

  63. 1:46

    make your life easier first install the

  64. 1:47

    awesome flutter snippets from gnash rom

  65. 1:49

    dial that will give you shortcuts to

  66. 1:51

    generate things like stateful and

  67. 1:53

    stateless widgets then when you run into

  68. 1:55

    issues with your code you can hit

  69. 1:56

    control period to run a quick fix a

  70. 1:58

    common example is when you're adding