FlutterStudy1th-Week9

Henry Choยท2023๋…„ 10์›” 4์ผ
1

flutterStudy1th

๋ชฉ๋ก ๋ณด๊ธฐ
9/10

9์ฃผ์ฐจ(23.09.27 ~ 10.03)

๐Ÿ’– ํ•ต์‹ฌ 3์ค„ ์š”์•ฝ

  • ์˜ค๋žœ๋งŒ์— ์ƒˆ๋ฒฝ๊นŒ์ง€ ๋‹ฌ๋ ค์„œ ์กธ์—… ์ž‘ํ’ˆ ์™„์„ฑ
  • ๋ฆฌ๋ทฐ๊ฐ€ ๋” ์ค‘์š”: ๊ฐœ๋ฐœ ์‹œ ๋ฐœ์ƒํ•œ ์ด์Šˆ ํ•ด๊ฒฐ์ฑ… ์ •๋ฆฌ ํ•„์š”
  • ๊ฐœ์„ ์ด ๋” ์ค‘์š”: ๋‹ค์Œ ์กธ์ž‘์€ ๋ฌด์กฐ๊ฑด ๋ฐค์ƒ˜ ์—†์ด, ํ•˜๋ฃจ ์•ˆ์— ๋๋‚ธ๋‹ค.

๐ŸŽฏ ์ด๋ฒˆ ์ฃผ ๋ชฉํ‘œ

โœ… ์กธ์—… ์ž‘ํ’ˆ ์™„์„ฑ

๐Ÿ‘ ์นญ์ฐฌํ•˜๊ณ  ์‹ถ์€ ์ 

  • ์กธ์—… ์ž‘ํ’ˆ ์„ ๋ชฉํ‘œ ๋Œ€๋น„ 70% ์ •๋„๋Š” ๊ตฌํ˜„ ํ•œ ๊ฒƒ ๊ฐ™๋‹ค.

๐Ÿ˜ญ ๊ณ ์น˜๊ฑฐ๋‚˜ ๋ฒ„๋ ค์•ผ ํ•  ์ 

  • ๋‹ค๋ฅธ ์ฑŒ๋ฆฐ์ง€๋•Œ๋„ ํ•ญ์ƒ ์ง€๋‚˜๊ณ ๋‚˜์„œ ํ›„ํšŒํ–ˆ์ง€๋งŒ ์—ฌ์ „ํžˆ ์กธ์ž‘ ์ œ์ถœ ์ „๋‚  ์ƒˆ๋ฒฝ 4์‹œ๊นŒ์ง€ ๊ฐœ๋ฐœ์„ ํ–ˆ๋‹ค.
    ๋‹ค์Œ ์ฑŒ๋ฆฐ์ง€ ๋•Œ๋Š” ๊ผญ ์š•์‹ฌ์„ ๋ฒ„๋ฆฌ๊ณ  ๋ฏธ๋ฆฌ, ๋นจ๋ฆฌ ํ•˜์ž

๐Ÿƒโ€โ™€๏ธ ์ผ์ผ ์Šคํ”„๋ฆฐํŠธ

23.09.27 ~ 10.01
โœ… ์ถ”์„ ์—ฐํœด์— ํ‹ฑํ†ก ์กธ์—… ์ž‘ํ’ˆ ๋งŒ๋“ค๊ธฐ ์™„๋ฃŒ

23.10.02
โœ… Day57-Implicit Animations 1/2

23.10.03
โœ… Day57-Implicit Animations 2/2 ์™„๋ฃŒ

โœ๏ธ ์ด๋ฒˆ ์ฃผ ๋ฐฐ์šด ๋‚ด์šฉ

์กธ์—… ์ž‘ํ’ˆ์„ ๋งŒ๋“ค๋ฉด์„œ ๋‚˜์˜จ ์ด์Šˆ๋“ค

  1. Where ์ ˆ์„ ๋‘ ๊ฐœ ์ด์ƒ์˜ ํ•„๋“œ์— ๋Œ€ํ•ด ์ง€์ •ํ•˜๊ณ  ์ฟผ๋ฆฌํ•  ๊ฒฝ์šฐ composite index ๊ด€๋ จ ์—๋Ÿฌ๊ฐ€ ๋‚˜๊ณ  ํ•ด๋‹น URL ์„ ํด๋ฆญํ•˜์—ฌ ์ง์ ‘ ์ƒ์„ฑ ํ•ด์ฃผ์–ด์•ผ ์ฟผ๋ฆฌ๊ฐ€ ๊ฐ€๋Šฅํ•˜๋‹ค.
subscribeMyPosts(String userId) => _db
      .collection("posts")
      .where("creatorId", isEqualTo: userId)
      .orderBy("createdAt", descending: true)
      .snapshots()
      .map(
        (event) => event.docs
            .map(
              (doc) => fromSnapshotToPostModel(doc, userId),
            )
            .where((x) => x != null)
            .map((e) => e!)
            .toList(),
      );
flutter: [cloud_firestore/failed-precondition] The query requires an index. You can create it here:
https://console.firebase.google.com/v1/r/project/../firestore/indexes?create_composite=Ck9wcm..

create_composite

  1. streamProvider๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ ํ•ด๋‹น collection๋“ค์€ ๊ฐ๊ฐ์ด microservice ๋ผ ์ƒ๊ฐ ํ•˜๊ณ  ์ค‘๋ณต ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•˜๋Š” ๊ฒƒ์ด ์ข‹๋‹ค.
    eg) likes, commentCount, hasAvatar
class PostModel {
  final String id;
  final String payload;
  final Mood mood;
  final Timestamp createdAt;
  final bool liked;
  final int likes; // redundant
  final int commentCount; // redundant
  final String creatorEmail;
  final String creatorId;
  final bool hasAvatar; // redundant
 }
  1. MainNavigation ๊ณผ ๊ฐ™์ด OffsetStage ๋ฅผ ์“ฐ๋Š” ๊ฒฝ์šฐ go_router๋‚˜ Navigator.push ๊ฐ€ ์•„๋‹ˆ๋ผ index state ๊นŒ์ง€ ๋ณ€ํ™”์‹œํ‚ค๋Š” onTap ์„ ๊ฐ Screen์— ๋„˜๊ฒจ์ฃผ์–ด์•ผ ํ•œ๋‹ค.
 void _onTap(int index) {
    context.go("/${_tabs[index]}");
    setState(() {
      _selectedIndex = index;
    });
  }
  1. horizontal ListWheelScrollView
RotatedBox(
  quarterTurns: -1,
  child: ListWheelScrollView(
    magnification: 2.0,
    onSelectedItemChanged: (x) {
      setState(() {
        selected = x;
      });
      print(selected);
    },
    controller: _scrollController,
    children: List.generate(
        itemCount,
        (x) => RotatedBox(
            quarterTurns: 1,
            child: AnimatedContainer(
                duration: Duration(milliseconds: 400),
                width: x == selected ? 60 : 50,
                height: x == selected ? 60 : 50,
                alignment: Alignment.center,
                decoration: BoxDecoration(
                    color: x == selected ? Colors.red : Colors.grey,
                    shape: BoxShape.circle),
                child: Text('$x')))),
	    itemExtent: itemWidth,
  	)
)
  1. Mood ์˜ variant ๋ฅผ enum์œผ๋กœ ์ฒ˜๋ฆฌ
enum Mood {
  happy("happy", "๐Ÿ˜Š"),
  thoughtful("thoughtful", "๐Ÿค”"),
  love("love", "๐Ÿ˜"),
  amazed("amazed", "๐Ÿคฉ"),
  laughing("laughing", "๐Ÿ˜‚"),
  sad("sad", "๐Ÿ˜ข"),
  angry("angry", "๐Ÿ˜ก"),
  shocked("shocked", "๐Ÿคฏ");

  const Mood(this.id, this.emoji);
  final String id;
  final String emoji;

  factory Mood.from(String id) {
    return Mood.values.firstWhere(
      (value) => value.id == id,
    );
  }
}
  1. Image.network.errorBuilder ์˜ค๋™์ž‘
    ์œ ์‚ฌ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์™€ try catch ๋ชจ๋‘ ์‹œ๋„ ํ•ด๋ณด์•˜์œผ๋‚˜ 404 ์ผ ์‹œ panic
    => ๊ฒฐ๊ตญ hasAvatar ๋ฅผ post ์—๋„ ํ•œ ๋ฒŒ ๋” ์ €์žฅํ•˜์—ฌ ๋กœ์ง์ƒ์œผ๋กœ ์ฐจ๋‹จ

  2. 3๊ฐœ ์ด์ƒ์˜ Hero๋ฅผ ์“ฐ๊ณ  ์‹ถ์€ ๊ฒฝ์šฐ ์–ด๋–ป๊ฒŒ ํ•ด์•ผํ• ๊นŒ?

    • 3 ๊ฐœ ์ด์ƒ์˜ Hero ์— ๋™์ผ id ๋ฅผ ๋„ฃ์œผ๋ฉด ์—๋Ÿฌ ๋ฐœ์ƒ
    • a ์™€ b๋ฅผ id = x, b๋ฅผ c๋ผ๋Š” Hero ๋กœ ๊ฐ์‹ผ ํ›„ d๋ฅผ id = y ๋กœ ์—ฐ๊ฒฐํ•˜๋ฉด ๋  ์ˆ˜๋„?
  3. ๊ฐ€๋”์”ฉ IOS ์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ ๋ฌผ๋ฆฌํ‚ค๋ณด๋“œ ์›Œ๋‹์ด ๋œจ๋ฉด์„œ ํ‚ค๋ณด๋“œ ์ž…๋ ฅ์ด ์•ˆ๋˜๋Š” ์ด์Šˆ ์žˆ์Œ..
    ์ƒˆ๋กœ๊ณ ์นจ์œผ๋กœ ํ•ด๊ฒฐ์ด ๋˜๊ธดํ•˜์ง€๋งŒ ๋นˆ๋ฒˆํ•˜๊ฒŒ ๋ฐœ์ƒ

โ•โ•โ•โ•โ•โ•โ•โ• Exception caught by services library โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
A KeyUpEvent is dispatched, but the state shows that the physical key is not pressed. If this occurs in real application, please report this bug to Flutter. If this occurs in unit tests, please ensure that simulated events follow Flutter's event model as documented in `HardwareKeyboard`. This was the event: KeyUpEvent#20d1f(physicalKey: PhysicalKeyboardKey#f0183(usbHidUsage: "0x000700e2", debugName: "Alt Left"), logicalKey: LogicalKeyboardKey#e5ce6(keyId: "0x200000104", keyLabel: "Alt Left", debugName: "Alt Left"), character: null, timeStamp: 910:04:52.571258)
'package:flutter/src/services/hardware_keyboard.dart':
hardware_keyboard.dart:1
Failed assertion: line 432 pos 16: '_pressedKeys.containsKey(event.physicalKey)'
  1. FutureBuilder, StreamBuilder ๋‚จ์šฉ
    ์ถฉ๋ถ„ํžˆ ๋” provider๋ฅผ ์ชผ๊ฐœ์„œ builder ์•ˆ์— ๋„ฃ์„ ์ˆ˜ ์žˆ์—ˆ์„ ๊ฒƒ ๊ฐ™์€๋ฐ ์ผ๋‹จ ๊ธ‰ํ•˜๋‹ˆ๊นŒ FutureBuilder์™€ StreamBuilder ๋กœ ์ฒ˜๋ฆฌํ–ˆ๋‹ค.
    ์‚ฌ์‹ค ๋‘ ๋ฐฉ๋ฒ• ๋ชจ๋‘ data ์กด์žฌ ์—ฌ๋ถ€์™€ error ์ฒ˜๋ฆฌ ๋ฐฉ์‹์€ ๋น„์Šทํ•œ๋ฐ ๊ตณ์ด ์ชผ๊ฐœ์„œ ์ฒ˜๋ฆฌํ•˜๊ณ  widget ํŠธ๋ฆฌ์—์„œ builder ์‚ฌ์šฉ์„ ์ง€์–‘ํ•˜๋Š”๊ฒŒ ์ตœ์„ ์ธ๊ฐ€?
    StreamBuilder

๐Ÿค”ย ์งˆ๋ฌธ

๐Ÿ’– ์ฃผ๊ฐ„ ํšŒ์˜์™€ ์กฐ๋ณ„ ํ™œ๋™

  • ๋ชฉํ™”๋‹˜๊ป˜์„œ ๊ฐ•์˜ ์ „๋ฐ˜์— ๋Œ€ํ•œ ์š”์•ฝ์„ ํ•ด์ฃผ์…”์„œ ์ข‹์•˜์Šต๋‹ˆ๋‹ค.

๊ธฐ์–ต์— ๋‚จ๋Š” ๊ฒƒ

profile
Full stack tech visionary

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