Flutter Study with FLUS_Week3

Philip Yoonยท2022๋…„ 9์›” 17์ผ

Flutter_W3

์˜ค๋Š˜์˜ ๋ชฉํ‘œ

๐Ÿ“ย ์–ด๋–ค Layout Widget๋“ค์ด ์žˆ๊ณ , ์–ด๋–ค ์—ญํ• ์ธ์ง€ ๋น ๋ฅด๊ฒŒ ์ตํžŒ๋‹ค.

๐Ÿ“ย code lab์„ ๊ณต๋ถ€ํ•˜๋ฉฐ ์ง์ ‘ ๋ฐฐ์šด ๋‚ด์šฉ์„ ์ ์šฉํ•ด๋ณธ๋‹ค.

๐Ÿ”ธ * Multi-child layout widgets์€ ํ•˜์œ„ widget ํ•ญ๋ชฉ๋“ค์„ ๋ฐฐ์น˜ํ•˜๋Š” widget์ž…๋‹ˆ๋‹ค. * Sigle-child layout์€ ํ•˜๋‚˜์˜ child ๋ผ๋ฉด, ์œ„ Mulit๋Š” children ์˜ ๊ฐœ๋…์œผ๋กœ ์—ฌ๋Ÿฌ๊ฐœ์˜ ํฌ๊ธฐ๋ฅผ ์กฐ์ •ํ•ฉ๋‹ˆ๋‹ค.
  • Column class
    • ๋‹ค์ˆ˜์˜ ์ž์‹ ์œ„์ ฏ๋“ค์„ ์„ธ๋กœ๋กœ ํ‘œ์‹œํ•˜๋Š” ์œ„์ ฏ
    • Column ์œ„์ ฏ์€ ์Šคํฌ๋กค ๋˜์ง€ ์•Š์œผ๋ฉฐ(์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ room๋ณด๋‹ค ์—ด์— ๋” ๋งŽ์€ ์ž์‹ ์œ„์ ฏ์„ ๊ฐ–๋Š” ๊ฒƒ์„ ์˜ค๋ฅ˜๋กœ ๊ฐ„์ฃผ) -> ์Šคํฌ๋กค ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•˜๋ ค๋ฉด ListView์‚ฌ์šฉ
    • ๊ฐ€๋กœ๋กœ ํ‘œ์‹œํ•˜๋Š” ์œ„์ ฏ์— ๊ฒฝ์šฐ Row ์œ„์ ฏ ์‚ฌ์šฉ
    • ์ž์‹ ์œ„์ ฏ์ด ํ•˜๋‚˜์ผ ๊ฒฝ์šฐ, ์ •๋ ฌ ๋˜๋Š” ์ค‘์‹ฌ์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐฐ์น˜ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Œ
child: Column(
    children: const <Widget>[
      Text('Deliver features faster'),
      Text('Craft beautiful UIs'),
      Expanded(
        child: FittedBox(
          child: FlutterLogo(),
        ),
      ),
    ],
  )),
  • Column ์œ„์ ฏ์— ListVIew()๋ฅผ ๋„ฃ๊ณ  ์‹ถ๋‹ค๋ฉด Expanded() or Flexible()๋กœ ๋ฌถ๋Š”๋‹ค.

    • ๋งŒ์•ฝ์— size๋ฅผ ์ฃผ๊ณ  ์‹ถ์œผ๋ฉด
      SizedBox()๋กœ ๋ฌถ๋Š”๋‹ค.
  • CustomMultiChildLayout class

    • ๋Œ€๋ฆฌ์ž๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์—ฌ๋Ÿฌ ์ž์‹์˜ ํฌ๊ธฐ๋ฅผ ์กฐ์ •ํ•˜๊ณ  ๋ฐฐ์น˜ํ•˜๋Š” ์œ„์ ฏ์ด๋‹ค
    • ๋Œ€๋ฆฌ์ธ์€ ๊ฐ ์ž์‹์— ๋Œ€ํ•œ ๋ ˆ์ด์•„์›ƒ ์ œ์•ฝ ์กฐ๊ฑด์„ ๊ฒฐ์ •ํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ๊ฐ ์ž์‹์„ ๋ฐฐ์น˜ํ•  ์œ„์น˜๋ฅผ ๊ฒฐ์ •ํ•  ์ˆ˜ ์žˆ๋‹ค.
    • ๋Œ€๋ฆฌ์ž๋Š” ๋ถ€๋ชจ์˜ ํฌ๊ธฐ๋ฅผ ๊ฒฐ์ •ํ•  ์ˆ˜๋„ ์žˆ์ง€๋งŒ, ๋ถ€๋ชจ์˜ ํฌ๊ธฐ๋Š” ์ž์‹์˜ ํฌ๊ธฐ์— ๋”ฐ๋ผ ๋‹ฌ๋ผ ์งˆ ์ˆ˜ ์—†๋‹ค.
  • CustomMultiChildLayout์€ ์—ฌ๋Ÿฌ ์œ„์ ฏ์˜ ํฌ๊ธฐ์™€ ์œ„์น˜ ์‚ฌ์ด์— ๋ณต์žกํ•œ ๊ด€๊ณ„๊ฐ€ ์žˆ์„๋•Œ ์ ํ•ฉํ•˜๋‹ค.

    CustomMultiChildLayout Constructors

    CustomMultiChildLayout({Key? key, required MultiChildLayoutDelegate delegate, List children = const []})
    Creates a custom multi-child layout.

  • CustomSingleChildLayout์€ ๋‹จ์ผ ์ž์‹์˜ ๋ ˆ์ด์•„์›ƒ์„ ์ œ์–ดํ•˜๋ ค ํ• ๋•Œ ์ ํ•ฉํ•˜๋‹ค.
    Stack ์œ„์ ฏ์€ ์œ„์ ฏ์„ ํ•˜๋‚˜ ๋˜๋Š” ๋‹ค๋ฅธ ์—์ง€์— ์ •๋ ฌ ํ• ๋•Œ ์ ํ•ฉํ•˜๋‹ค.

  • Flow ์œ„์ ฏ์€ which provides paint-time control of its children using transform matrices.(๋ณ€ํ™˜ํ–‰๋ ฌ)

  • ๊ฐ ์ž์‹์€ ๋Œ€๋ฆฌ์ž์— ๋Œ€ํ•œ ์œ„์ ฏ์„ ์‹๋ณ„ํ•˜๊ธฐ ์œ„ํ•ด LayoutId ์œ„์ ฏ์— ๋ž˜ํ•‘๋˜์–ด์•ผ ํ•œ๋‹ค.

  • Flow class

    • FlowDelegate์˜ ๋…ผ๋ฆฌ์— ๋”ฐ๋ผ ์ž์‹์˜ ํฌ๊ธฐ๋ฅผ ํšจ์œจ์ ์œผ๋กœ ์กฐ์ •ํ•˜๊ณ  ๋ฐฐ์น˜ํ•˜๋Š” ์œ„์ ฏ์ด๋‹ค.
    • Flow ๋ ˆ์ด์•„์›ƒ์€ ๋ณ€ํ™˜ํ–‰๋ ฌ์„ ์‚ฌ์šฉํ•˜์—ฌ ์ž์‹์˜ ์œ„์น˜๋ฅผ ๋ณ€๊ฒฝํ•˜๋Š”๋ฐ ์ตœ์ ํ™”๋˜์–ด ์žˆ๋‹ค.
    • Flow ์ปจํ…Œ์ด๋„ˆ๋Š” ๋Œ€๋ฆฌ์ž์˜ FlowDelegate.getSize ํ•จ์ˆ˜์— ์˜ํ•ด ์ž์‹๊ณผ ๋…๋ฆฝ์ ์œผ๋กœ ํฌ๊ธฐ๊ฐ€ ์กฐ์ •๋œ๋‹ค.

Single-child layout ์œ„์ ฏ

  • LimitedBox
    • A box that limits its size only when it's unconstrained.
  • Offstage
    • A widget that lays the child out as if it was in the tree, but without painting anything, without making the child available for hitโ€ฆ
  • OverflowBox
    • A widget that imposes different constraints on its child than it gets from its parent, possibly allowing the child to overflow the parent.
  • Padding
    • A widget that insets its child by the given padding.
  • SizedBox
    • A box with a specified size. If given a child, this widget forces its child to have a specific width and/or height (assuming values areโ€ฆ
  • SizedOverflowBox
    • A widget that is a specific size but passes its original constraints through to its child, which will probably overflow.
  • Transform
    • A widget that applies a transformation before painting its child.

Multi-child layout ์œ„์ ฏ

Sliver ์œ„์ ฏ

  • CupertinoSilverNavigationBar
  • CustomScrollView
  • SilverAppBar
  • SilverChildBuilder Delegate
    • A delegate that supplies children for slivers using a builder callback.
  • SliverChildLIst Delegate
    • A delegate that supplies children for slivers using an explicit list.
  • SliverFixedExtent List
    • A sliver that places multiple box children with the same main axis extent in a linear array.
  • SliverGrid
    • A sliver that places multiple box children in a two dimensional arrangement.
  • SliverList
    • A sliver that places multiple box children in a linear array along the main axis.
  • SLiverPadding
    • A sliver that applies padding on each side of another sliver.
  • SliverPersistentHeader
    • A sliver whose size varies when the sliver is scrolled to the edge of the viewport opposite the sliver's GrowthDirection.
  • SliverToBoxAdapter
    • A sliver that contains a single box widget.
profile
๊ฐœ๋ฐœ ํฌ์ง€์…˜์€ Native Android ์ž…๋‹ˆ๋‹ค.

0๊ฐœ์˜ ๋Œ“๊ธ€