LimitedBox (Flutter Widget of the Week)

Поделиться
HTML-код
  • Опубликовано: 24 июн 2019
  • Ever had a widget that misbehaved when given unlimited size to grow? The LimitedBox widget provides size constraints to widgets in cases where their dimensions are unbounded.
    Learn more about LimitedBox → goo.gle/2wXZTM8
    This video is also subtitled in Chinese, Indonesian, Italian, Japanese, Korean, Portuguese, and Spanish.
    Learn everything about Flutter at → goo.gle/2WAhEN1
    Get more tips! → goo.gle/307BX6t
    Subscribe! → goo.gle/Flutter

Комментарии • 88

  • @yasharora4623
    @yasharora4623 5 лет назад +214

    Google : how many widgets you want ?
    Developers : Yes

  • @victoremeka
    @victoremeka Год назад +6

    After a day of spiralling into a flutter layout rabbit hole, this video is an absolute gem.

  • @mahmud-ahsan
    @mahmud-ahsan 5 лет назад +12

    I liked this widget. It really helps to set something in default size when parent's size is unknown.

  • @Huy-ed2re
    @Huy-ed2re 5 лет назад +36

    I recognize the voice behind this clip was Emily. Thank you for making these! You guys are awesome!

  • @christianeichmueller8637
    @christianeichmueller8637 5 лет назад +134

    I'm a simple man. I see a flutter video and I click like!

    • @praharshbhatt2934
      @praharshbhatt2934 5 лет назад +2

      Then like my flutter video

    • @breh2716
      @breh2716 2 года назад +3

      @@praharshbhatt2934 i'm a simple man, i see a flutter video and i click like! Unless it is made by Praharsh Bhatt.

    • @breh2716
      @breh2716 Год назад +1

      Bruh i was a menace 💀

    • @notpowder5831
      @notpowder5831 3 месяца назад

      ​@@breh2716 bro starts someone's villain arc 💀

  • @sopheaktraphim9146
    @sopheaktraphim9146 5 лет назад +1

    Love these short videos. I don't even use flutter that much, but I remember like all the widget they have shown.

  • @asquove7863
    @asquove7863 4 года назад +19

    Compare to CSS:
    SizedBox: display: inline-block;
    LimitedBox: display: block;
    Really a useful widget, thanks!

    • @antongrekov7710
      @antongrekov7710 2 года назад

      Counter Strike Source?

    • @splex7
      @splex7 2 года назад

      @@antongrekov7710 Nice ~

  • @AbdallaElmedny
    @AbdallaElmedny 2 года назад +6

    I had a hard time understanding constraints coming from CSS. But the moment you said container set their height to 0 when unconstrained. It all clicked! Thanks

  • @tyshanthedev1985
    @tyshanthedev1985 5 лет назад +3

    I love everything you guys have done. Thanks.

  • @danvilela
    @danvilela 5 лет назад +9

    Never heard of it. Will start using it! Thx☺️

  • @dkq986
    @dkq986 5 лет назад

    This will surely simplify design patterns.

  • @zx112344567789
    @zx112344567789 Год назад +6

    I think the example is not good enough to explain the widget. If it come to "unbounded constraint" from parent, the Sizedbox, ConstraintedBox can also do the same thing for the child.
    It is about "if the parent with no constraint, Limitedbox give the child maxSize".
    On the other hand, "if the parent with constraint, Limitedbox pass parent's constraint and ignore it own's".
    Try the exampe below:
    ListView(
    children: [
    LimitedBox(
    maxHeight: 200,
    child: Container(color: Colors.green),
    ),
    ConstrainedBox(
    constraints: const BoxConstraints(maxHeight: 300),
    child: LimitedBox(
    maxHeight: 200,
    child: Container(color: Colors.blue),
    ),
    ),
    ConstrainedBox(
    constraints: const BoxConstraints(maxHeight: 300),
    child: SizedBox(
    height: 200,
    child: Container(color: Colors.red),
    ),
    ),
    ],
    );

  • @sashankvisweshwaran8386
    @sashankvisweshwaran8386 2 года назад +1

    This is beautiful💖! I was searching for something like this for an hour now

  • @rajkumarmigsingh
    @rajkumarmigsingh 2 года назад +1

    This is what i want thank you Flutter!😊✌🏻

  • @jimmyfmedina
    @jimmyfmedina 5 лет назад +1

    Very good, very useful.

  • @KL13923j
    @KL13923j 5 лет назад +1

    Awesome one!

  • @RodyDavis
    @RodyDavis 5 лет назад +7

    You can use this on flutter_web since height is unbounded!

  • @hydernotes
    @hydernotes 3 года назад

    very useful widget!

  • @HemangJoshi
    @HemangJoshi 5 лет назад

    Awesome video...

  • @shashidharreddy1624
    @shashidharreddy1624 5 лет назад

    For AR android app development in flutter, is vscode editor is enough? . I am on windows 10 G2020 processor and 8gb ddr3 ram

  • @muhammedanaspk2972
    @muhammedanaspk2972 3 года назад

    This widget solves the problem when a unbounded horizontal listview is used?

  • @colectorcell1871
    @colectorcell1871 5 лет назад

    Oke very useful this channel

  • @SandeepGurram810
    @SandeepGurram810 5 лет назад +1

    This should ease many design problems.

  • @trieuvantunet
    @trieuvantunet 5 лет назад

    i love flutter

  • @viharcontractor1679
    @viharcontractor1679 5 лет назад

    Do you guys plan on making some good FlutterFire tutorials?

  • @sosyallog8772
    @sosyallog8772 4 года назад

    I love flutter

  • @temirbek
    @temirbek 3 года назад +1

    What if you use ConstrainedBox instead? Seems like has same effect

  • @joehsiao6224
    @joehsiao6224 4 года назад +12

    Why not just set a container's height?

    • @xerotolerant
      @xerotolerant 3 года назад +2

      If you don’t know at build time if a component is going to be in an unbounded parent or now you can wrap it in this. Think dynamic user interfaces.

  • @prafulgupta7004
    @prafulgupta7004 5 лет назад +39

    Please make video on How to write efficient code?

    • @ZiggyCrane
      @ZiggyCrane 5 лет назад +7

      Nobody but yourself will help you with that.

    • @eshansingh1
      @eshansingh1 5 лет назад +1

      Could you be more specific? Efficient in what sense?

    • @jimjaylee7553
      @jimjaylee7553 5 лет назад

      @@eshansingh1 in format

    • @appboy-io
      @appboy-io 5 лет назад

      Check out the boring flutter podcast. It's a great resource.

    • @ChrisHornberger
      @ChrisHornberger 4 года назад

      (sigh) Seriously?

  • @aytunch
    @aytunch 5 лет назад +14

    how is this different than SizedBox? can someone explain?

    • @moseskarunia
      @moseskarunia 5 лет назад +8

      LimitedBox will get ignored once the parent already have size.

    • @alpertokcan9899
      @alpertokcan9899 5 лет назад +7

      Sizedbox always constraints its children but this constrains it only if parent doesnt. This could be usefull to have in child component. Put this on your child components as topmost widget and you have a widget that constrains itself when its parent doesnt! Like in a column or list. But somewhere else if parent constrains it, it respects the parents constrains.

  • @renanzumas4422
    @renanzumas4422 5 лет назад

    Simple e amazing

  • @DavidHust
    @DavidHust 4 года назад

    What program did they use to make these animations? Powerpoint?

  • @SreekanthKrishnan
    @SreekanthKrishnan 5 лет назад +3

    Is there a solution for a login screen to distribute the children equally in portrait also scroll in landscape or when there's not enough space?

    • @srijankumarsamanta5579
      @srijankumarsamanta5579 5 лет назад +1

      there are a number of ways to do it :
      for equally distribution of screen height and width - crossAxisAllignment.spaceAround or mainAxisAllignment.spaceAround
      for perfect screen to fields ratio while in portrait or landscape mode - use MEDIA QUERY
      for custom space arrangement - use EXPANDED with FLEX
      COMBINE EVERYTHING TO GET THE BEST RESULT

    • @sreekanthkrishnan8886
      @sreekanthkrishnan8886 5 лет назад

      @LP Square That's what I ended up doing. But I'm having to put an arbitrary value for checking the height. It works for the purpose. But I was thinking if there's some better way so that instead of a hard coded height value how can we set the break point depending on the actual measured height of all widgets.

  • @rozael1855
    @rozael1855 2 года назад

    thank for sharing

    • @flutterdev
      @flutterdev  2 года назад

      Thanks for watching! Be sure to subscribe to stay up to date with the latest from Flutter: goo.gle/Flutter

  • @JandN
    @JandN 4 года назад +1

    Just give height to the container?

  • @ChrisHornberger
    @ChrisHornberger 4 года назад +5

    The more I use Flutter, the more I like it, but the less forethought I think went into a lot of it. A lot of the specialty widgets could simply be optional parameters on (most?) every other widget of similar type. For instance, Expanded, LimitedBox, AnimatedContainer, (maybe a few more), and Container should all just be.... Container with a comprehensive set of properties. And a container with both a color and a box decoration shouldn't toss and exception. Container->Decoration->Color should simply supercede Container->Color because, ya know, Decoration takes more choices and thought to put in place, and would rarely show up by accident. Some really wacky choices were made expanding Flutter from inception, methinks.

    • @luisfernandotrivelatto1975
      @luisfernandotrivelatto1975 2 года назад +2

      While we can discuss the validity of it, the approach of "lots of small widgets" instead of "lots of optional parameters" was a design choice from the start. It's discussed in the official docs, "Flutter architectural overview" section "Composition":
      "The class hierarchy is deliberately shallow and broad to maximize the possible number of combinations, focusing on small, composable widgets that each do one thing well. Core features are abstract, with even basic features like padding and alignment being implemented as separate components rather than being built into the core. (This also contrasts with more traditional APIs where features like padding are built in to the common core of every layout component.)"

  • @raul286162
    @raul286162 5 лет назад +1

    It's a little hard to follow and understand at same for no English speakers xD but these videos are great

  • @heshansandeepa9471
    @heshansandeepa9471 2 года назад +1

    very nice

  • @StingSting844
    @StingSting844 5 лет назад +2

    can't we set a height to the container itself instead of wrapping it in a limitedbox?

    • @reazon7
      @reazon7 5 лет назад +1

      container doesn't have maxHeight
      ..

  • @nested9301
    @nested9301 3 года назад

    its working without limited box :D

  • @benny-shen
    @benny-shen 2 года назад

    what's the difference compared to SizedBox?

  • @ricardormarcos
    @ricardormarcos 3 года назад

    Why not set the container constraint ?

  • @justapugontheinternet
    @justapugontheinternet 5 лет назад +3

    Can’t you just do this with a container and set he height and width?

    • @victorhugomacedoferreira7730
      @victorhugomacedoferreira7730 4 года назад

      Like she said in the video.. a Container always passes its constraints down to its child. This LimitedBox is basically a container that conditionally passes its constraints: only if the limitedbox's parent doesn't have them.

  • @williambluish
    @williambluish 5 лет назад +1

    😍

  • @raveeshdotme
    @raveeshdotme 5 лет назад +1

    Ummm why not just sized box?

  • @rababsalah918
    @rababsalah918 5 лет назад

    👍👍👍

  • @badrinathbnj
    @badrinathbnj 5 лет назад

    Interning..

  • @mustofa_id
    @mustofa_id 5 лет назад

    My index finger pressed thumb up automatically.

  • @psychedelic1123
    @psychedelic1123 5 лет назад +5

    what would be the difference if I just set constraints on a ListView child? Consider this example:
    ListView(
    children: [
    Container(
    constraints: BoxConstraints(maxHeight: 200.0),
    color: Colors.teal[100],
    )
    ],
    );

    • @alpertokcan9899
      @alpertokcan9899 5 лет назад +4

      This is usefull when you dont have control over the parent. So you put this on your child widget as topmost widget. For example Your code puts a fixed constraint. This one is disabled if there is a constraint on its parent, if not fixed box constraints apply. So you can be sure there will alvays be a constraint applying to your child.

    • @srijankumarsamanta5579
      @srijankumarsamanta5579 5 лет назад

      exactly I was thinking of it !!

    • @srijankumarsamanta5579
      @srijankumarsamanta5579 5 лет назад

      Or simply
      ListView(
      children: [
      Container(
      height: 200.0,
      color: Colors.teal[100],
      )
      ],
      );

  • @Sukhcha_in
    @Sukhcha_in 5 лет назад +1

    Documentation needs to be upgraded. There are lot of widgets, can't find which one perfectly fits my situation! 😒

  • @afwfawefewae
    @afwfawefewae 5 лет назад

    Why use LimitedBox instead of SizedBox?

    • @easyflamer
      @easyflamer 5 лет назад +1

      From @Alper Tokcan:
      Sizedbox always constraints its children but this constrains it only if parent doesnt. This could be usefull to have in child component. Put this on your child components as topmost widget and you have a widget that constrains itself when its parent doesnt! Like in a column or list. But somewhere else if parent constrains it, it respects the parents constrains.

  • @explore-planet-earth
    @explore-planet-earth 5 лет назад

    I don't get it @Emily.. inside listView children container when we set the height to some, we can attain the same output as shown in this video rit!! Or I'm missing something.. when actually this limited box required.. still confusing..

  • @jerarcaarthanis1461
    @jerarcaarthanis1461 4 года назад

    Sounds like constrained box

    • @nailgilaziev
      @nailgilaziev 4 года назад

      Do you know what the difference between them?

  • @havefun5519
    @havefun5519 2 года назад

    nightmare for nest widget

  • @Sciker
    @Sciker 5 лет назад

    Ok

  • @debola_is
    @debola_is 11 месяцев назад

    Why use a limited box instead of a sized box?

    • @marana.th4
      @marana.th4 8 месяцев назад +1

      because sized box has a fixed size, limited size will let it's child take any size it wants but not allowing it to exceed the "maxHeight" you set in the limitedBox

    • @debola_is
      @debola_is 8 месяцев назад +1

      @@marana.th4 thank you

  • @el7284
    @el7284 4 года назад

    BoxConstraints.maxheight.

  • @johnpeter7832
    @johnpeter7832 5 лет назад

    First

  • @WorstDeveloper
    @WorstDeveloper 4 года назад +1

    Instead of having a billion different widgets, why not make it more like html where you can do everything with a div?

  • @raveeshdotme
    @raveeshdotme 5 лет назад +1

    Ummm why not just sized box?