[Flutter] FractionallySizedBox class ์ •๋ฆฌ
ยท
๐Ÿ’ง flutter
FractionallySizedBox class FractionallySizedBox class๋Š” ์ƒ์œ„ ๋ถ€๋ชจ์˜ ์‚ฌ์ด์ฆˆ ๋น„์œจ์— ๋งž๊ฒŒ ๋งŒ๋“œ๋Š” ๊ฒƒ์ด๋‹ค. ์ฆ‰ ๋””์ž์ธ์˜ ํฌ๊ธฐ๊ฐ€ ์ƒ๋Œ€์ ์ด์–ด์•ผ ํ•  ๋•Œ ํฌ๊ธฐ๋ฅผ ์ƒ์œ„ ๋ถ€๋ชจ์˜ ์‚ฌ์ด์ฆˆ๋ฅผ ๋ฐ”ํƒ•์œผ๋กœ ๋น„์œจ๋กœ ํ‘œํ˜„ํ•˜๋Š” ๊ฒƒ์ด๋‹ค. example) FractionallySizedBox๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์ƒ์œ„ ๋ถ€๋ชจ์˜ ์‚ฌ์ด์ฆˆ ๋น„์œจ์„ ์ง€์ •ํ•˜์—ฌ child์˜ ํฌ๊ธฐ๋ฅผ ์ •ํ•˜๊ณ  ์žˆ๋‹ค. ์ฝ”๋“œ์—์„œ 0.7์€ 70%๋ฅผ ๋‚˜ํƒ€๋‚ธ๋‹ค. ์ฆ‰ ์ƒ์œ„ ๋ถ€๋ชจ ์‚ฌ์ด์ฆˆ์˜ 70%๋งŒํผ child๋ฅผ ๋งŒ๋“ค๊ฒ ๋‹ค๋Š” ์˜๋ฏธ์ด๋‹ค. widthFactor์ฒ˜๋Ÿผ heightFactor์„ ์‚ฌ์šฉํ•˜์—ฌ ๋†’์ด์˜ ๋น„์œจ๋„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด์ฒ˜๋Ÿผ FractionallySizedBox class๋Š” ์ƒ์œ„ ๋ถ€๋ชจ์˜ ์‚ฌ์ด์ฆˆ ๋น„์œจ๋กœ ํฌ๊ธฐ๋ฅผ ์ง€์ •ํ•  ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค.
[Flutter] FittedBox Class ์ •๋ฆฌ
ยท
๐Ÿ’ง flutter
FittedBox Class child ๋˜๋Š” ๋‚ด์šฉ์˜ ์–‘์— ๋”ฐ๋ผ ํฌ๊ธฐ๊ฐ€ ํ™•์žฅ๋˜๋Š” ์œ„์ ฏ์— ์˜ํ•ด ์˜ค๋ฒ„ํ”Œ๋กœ์šฐ๊ฐ€ ๋ฐœ์ƒ๋˜๋Š” ๊ฒฝ์šฐ FittedBox๋กœ ๊ฐ์‹ธ๋ฉด ์ „์ฒด ํฌ๊ธฐ๋ฅผ ๋„˜์ง€ ์•Š๊ฒŒ ๋˜๋ฉฐ ์˜ค๋ฒ„ํ”Œ๋กœ์šฐ๊ฐ€ ๋ฐฉ์ง€๋œ๋‹ค. alignment๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์›ํ•˜๋Š” ๋ฐฐ์—ด๋กœ ๋‚˜ํƒ€๋‚ผ ์ˆ˜ ์žˆ๋‹ค. example) ์‚ฌ์šฉ ์ „) ์‚ฌ์šฉ ํ›„) ์ด์ฒ˜๋Ÿผ ๋ถ€๋ชจ์—์„œ ์ฃผ์–ด์ง„ ํฌ๊ธฐ ๋‚ด์— child๋ฅผ ์ƒ์„ฑํ•  ๋•Œ ์˜ค๋ฒ„ํ”Œ๋กœ์šฐ๊ฐ€ ๋ฐœ์ƒํ•˜์ง€ ์•Š๋„๋ก ํ•˜๊ธฐ ์œ„ํ•ด ์ฃผ๋กœ ์‚ฌ์šฉํ•œ๋‹ค. fittedBox๋Š” ๋ถ€๋ชจ ํฌ๊ธฐ์— ๋งž์ถฐ child ํฌ๊ธฐ๋ฅผ ์กฐ์ •ํ•˜๋Š” ๊ฒƒ์ด๋‹ค. BoxFit.cover๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋ถ€๋ชจ ํฌ๊ธฐ์— ๋”ฑ ๋งž๊ฒŒ child ํฌ๊ธฐ๋ฅผ ์กฐ์ •ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ฐธ๊ณ ) https://medium.com/flutter-community/flutter-widgets-boxes-part-2-the-whol..
[Flutter] CustomSingleChildLayout ์ •๋ฆฌ
ยท
๐Ÿ’ง flutter
CustomSingleChildLayout childe์˜ ๋ ˆ์ด์•„์›ƒ์„ ์ง€์ •ํ•˜๋Š” ์œ„์ ฏ์ด๋‹ค. delegate์€ child ๋ ˆ์ด์•„์›ƒ์˜ constraints๋ฅผ ๊ฒฐ์ •ํ•  ์ˆ˜ ์žˆ๋‹ค. ๋˜ํ•œ child๋ฅผ ์–ด๋””์— ๋‘˜์ง€, parent์˜ ํฌ๊ธฐ๋ฅผ ๊ฒฐ์ •ํ•œ๋‹ค. ํ•˜์ง€๋งŒ parent๋Š” child์˜ ํฌ๊ธฐ์— ์˜์กดํ•˜์ง€ ์•Š๋Š”๋‹ค. CustomSingleChildLayout์€ delegate๋ฅผ ์ง€์ •ํ•ด์•ผ ํ•œ๋‹ค. ์ฃผ๋กœ grid๋ฅผ ๋งŒ๋“ค ๋•Œ ์“ฐ์ธ๋‹ค. ์ •๋ฆฌํ•˜๋ฉด, child์˜ ์œ„์น˜, ํฌ๊ธฐ๋ฅผ ๊ฒฐ์ •ํ•  ๋•Œ ์‚ฌ์šฉํ•˜๋Š” layout ์ค‘ ํ•˜๋‚˜์ด๋‹ค. example 1) const CustomSingleChildLayout({ Key key, @required this.delegate, Widget child, }) example 2) Widget single(){ ret..
[Flutter] Initializer lists ์ •๋ฆฌ
ยท
๐Ÿ’ง flutter
Initializer lists constructor ์‹คํ–‰ ์ „์— final fields๊ฐ€ ๊ฐ’์„ ๊ฐ€์ง€๋Š”์ง€๋ฅผ ํ™•์ธํ•˜๋Š” ๋“ฑ์˜ ์ดˆ๊ธฐ ์„ค์ •์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ๊ฐ€ ์žˆ๋‹ค. ์ฆ‰, default field์— ์‹คํ–‰ ์ „์— ๊ฐ’์ด ์žˆ๋„๋ก ํ•˜๊ธฐ ์œ„ํ•ด Initializer lists์—์„œ ์ดˆ๊ธฐํ™” ํ•˜๋Š” ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•œ๋‹ค. Point.fromJson(Map json) : x = json['x']!, y = json['y']! { print('In Point.fromJson(): ($x, $y)'); } assert๋Š” ๊ฐœ๋ฐœ ๋ชจ๋“œ์˜ debug์ค‘์—๋งŒ ์˜ํ–ฅ์„ ๋ฏธ์นœ๋‹ค. Initializer lists์—๋Š” ์ด๋ ‡๊ฒŒ debug์ค‘์—๋งŒ ์‹คํ–‰๋˜๋Š” assert๋ฅผ ๋„ฃ์„ ์ˆ˜ ์žˆ๋‹ค. class FirstTwoLetters { final String letterOne; ..
[Flutter] Using this in a constructor ์— ๋Œ€ํ•˜์—ฌ
ยท
๐Ÿ’ง flutter
about using this in a constructor this.propertyName ์€ ์งง๊ณ  ๊ฐ„๋‹จํ•˜๊ฒŒ constructor์˜ values์— ๊ฐ’์„ ํ• ๋‹นํ•  ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค. class MyColor { int red; int green; int blue; MyColor(this.red, this.green, this.blue); } final color = MyColor(80, 80, 128); ์ œ์‹œ๋œ ์ฝ”๋“œ์—์„œ this.์€ class ๋ณ€์ˆ˜์— ๊ฐ’์„ ๋„ฃ๊ฒ ๋‹ค๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•œ๋‹ค. ์ด๋Ÿฌํ•œ ๋ฐฉ์‹์€ named parameters์—์„œ๋„ ์‚ฌ์šฉ๋œ๋‹ค. using this in named parameters class MyColor { ... MyColor({required this.red, required this.gree..
[Flutter] Exceptions ์ด๋ž€!?
ยท
๐Ÿ’ง flutter
Exceptions ์˜๋ฏธ: exceptions๋Š” ์˜ˆ์ƒ์น˜ ๋ชปํ•œ ์ผ์ด ๋ฐœ์ƒํ–ˆ์Œ์„ ๋‚˜ํƒ€๋‚ด๋Š” ์˜ค๋ฅ˜์ด๋‹ค. ๊ธฐ๋Šฅ: dart code๋Š” exceptions๋ฅผ throw ํ•˜๊ณ  catchํ•  ์ˆ˜ ์žˆ๋‹ค. ํŠน์ง•: dart๋Š” exception๊ณผ error types๋ฅผ ์ œ๊ณตํ•˜์ง€๋งŒ, null์ด ์•„๋‹Œ ๊ฐ์ฒด๋งŒ throw ํ•  ์ˆ˜ ์žˆ๋‹ค. exceptions๋ฅผ ๋‹ค๋ฃจ๊ธฐ ์œ„ํ•ด ์•Œ์•„์•ผ ํ•˜๋Š” ์šฉ์–ด throw exception๋ฐœ์ƒ ์‹œ ๊ฐ์ฒด ๋˜๋Š” ์ฝ”๋“œ ๋“ฑ์„ ๋ฐ˜ํ™˜ํ•  ์ˆ˜ ์žˆ๋‹ค. //์ผ๋‹จ ์—๋Ÿฌ๋ฅผ ๋˜์ ธ๋ณธ๋‹ค๊ณ  ์ƒ๊ฐ throw ์‚ฌ์šฉ ์ฝ”๋“œ ์˜ˆ) //example 1 throw FormatException('Expected at least 1 section'); //example 2 throw 'Out of llamas!'; example 1 ์‚ฌ์šฉ์„ ๊ถŒ์žฅํ•œ๋‹ค. ์—..
git merge ์—๋Ÿฌ
ยท
๐Ÿˆ‍โฌ› git
git checkout์„ ํ•˜๋ ค๊ณ  ํ–ˆ์œผ๋‚˜ ์ด๋Ÿฐ ์—๋Ÿฌ๊ฐ€ ๋– ์„œ ์•„๋ฌด๊ฒƒ๋„ ํ•˜์ง€ ๋ชปํ•˜๋Š” ์ƒํ™ฉ์ด ๋˜์—ˆ๋‹ค. ํ˜„์žฌ vscode๋ฅผ ์‚ฌ์šฉ ์ค‘์ธ๋ฐ, ํด๋” ์˜†์— ! ์ด๋Ÿฐ ํ‘œ์‹œ๊ฐ€ ์ƒ๊ฒผ๋‹ค. ์•„๋ฌด๋ฆฌ ์—๋Ÿฌ๋ฅผ ์ฐพ์•„๋ณด์•„๋„ ์—๋Ÿฌ๋Š” ๋ณด์ด์ง€ ์•Š๊ณ , ๋นŒ๋“œ๊ฐ€ ๋˜์ง€ ์•Š์•˜๋‹ค. ๊ทธ๋ž˜์„œ ์ผ๋‹จ git status ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์–ด๋””์—์„œ ์–ด๋–ค ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋Š”์ง€ ํ™•์ธํ•ด ๋ณด์•˜๋‹ค. $git status ๊ทธ ๊ฒฐ๊ณผ ์ด๋Ÿฐ ๊ฒฐ๊ณผ๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ์—ˆ๋‹ค. ์•„๋ฌด๋ž˜๋„ ์ˆ˜์ •ํ•œ ๊ฒƒ์„ ์ œ๋Œ€๋กœ ์ €์žฅ ๋˜๋Š” push ํ•˜์ง€ ์•Š์€ ์ƒํƒœ์—์„œ merge๋ฅผ ํ•ด์„œ ๋ฐœ์ƒํ•œ ๋ฌธ์ œ์ธ ๊ฒƒ ๊ฐ™๋‹ค. ์ด๋ ‡๊ฒŒ git status๋ฅผ ํ†ตํ•ด ์—๋Ÿฌ๊ฐ€ ๋‚œ ๋ถ€๋ถ„์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค. ๊ทธ๋ž˜์„œ ์—๋Ÿฌ์— ๋‚˜์˜จ๋Œ€๋กœ ๊ฐ ํŒŒ์ผ์„ ํ•˜๋‚˜์”ฉ git addํ•˜์—ฌ ์ˆ˜์ •๋œ ๊ฒƒ์„ ์ €์žฅํ•˜์˜€๋‹ค. ์ž˜ ๋ณด์ผ์ง€ ๋ชจ๋ฅด๊ฒ ์œผ๋‚˜, ๊ธฐ์กด์— home.dart ํŒŒ์ผ์ด..