์น๊ณต๋ทฐ49 dart ๊ธฐ์ด var, dynamic var๋ ์์ ๋ก์ด ํ์ ์ผ๋ก ๋ณ์๋ฅผ ์ ์ฅํ ์ ์์ง๋ง ์ฒ์์ ์ ์ฅ๋ ๋ณ์์ ํ์ ๋ง๊ณ ๋ค๋ฅธ ํ์ ์ ์ ์ฅ๋ ์ ์์ dynamic์ ์ฒ์์ ์ ์ฅ๋ ํ์ ๊ณผ๋ ์๊ด์์ด ๋ฌด์จ ํ์ ์ด๋ ์ ์ฅ ๊ฐ๋ฅ var name = 'abc'; name = 'ddd'; name = 3; //error dynamic name2 = 'abc'; name2 = 'ddd'; name2 = 3; //ok const, final ์ฝ๋๋ฅผ ์คํํ์ง ์์ ์ํ์์ ๊ฐ์ด ํ์ ๋๋ฉด const, ์คํ๋ ๋ ํ์ ๋๋ฉด final final DateTime now = DateTime.now(); //๋ฐํ์ ์์ const DateTime now2 = DateTime.now(); //error. ๋น๋ํ์ ์์์. ๋น๋ํ์์ ๊ฐ์ ์์์ผํ๋๋ฐ.. 2023. 7. 4. flutter ํ๋ฌํฐ firestore์์ ๋ฐ์ดํฐ ์ฝ์ด์ค๊ธฐ 1. ๋ชจ๋ธ ์์ฑ QuerySnapshot ๋ฐ์ดํฐ๋ฅผ ์ฝ์ด์ฌ๋, ์ํ๋ ์ค๋ธ์ ํธ ํํ๋ก ๊ฐ์ ธ์ค๊ฒ ํจ. (Category ์ค๋ธ์ ํธ ํ์ ์ผ๋ก ํ์ด์ด์คํ ์ด์ data writing๋ ์ํ) class HomeModel { final Stream categoriesStream = FirebaseFirestore.instance .collection(Constants().categories) .withConverter( fromFirestore: (snapshot, _) => Category.fromJson(snapshot.data()!), toFirestore: (category, _) => category.toJson(), ) .snapshots(); } 2. ์ถ๋ ฅ์ ์ํ๋ ์์ ฏ์์ StreamBuilder๋ก ๊ฐ.. 2023. 6. 28. flutter ํ๋ฌํฐ firestore์ ๋ฐ์ดํฐ ์ถ๊ฐํ๊ธฐ 1. cloud_firestore ์์กด์ฑ ์ถ๊ฐ ํฐ๋ฏธ๋์์ flutter pub add cloud_firestore 2. firebase ์ฝ์์์ firestore ์ฌ์ฉํ๊ฒ ํ๊ธฐ ์ฐ์ ํ ์คํธ ๋ชจ๋๋ก ์์ 3. project/android/app/build.gradle ํ์ผ์ minsdkVersion์ 21๋ก ๋ณ๊ฒฝ 4. uploadํ ๋ชจ๋ธ ํด๋์ค ์์ฑ class Category{ int id; String name; Category({ required this.id, required this.name }); //firestore์์ ๋ฐ์ดํฐ๋ฅผ ๋ฐ์ ๋๋ json์ผ๋ก ๋ฐ์ factory Category.fromJson(Map json){ return Category( id: json['id'] as int, n.. 2023. 6. 27. flutter ํ๋ฌํฐ ํ์ด์ด๋ฒ ์ด์ค ์ด๊ธฐ ์ธํ 1. ์ฐ์ ํ๋ฌํฐ ํ๋ก์ ํธ๋ ๋ง๋ค์ด ๋์ ์ํ์ 2. ํ์ด์ด๋ฒ ์ด์ค ํ๋ก์ ํธ๋ ํ๋ ํ๋์ 3. ํ์ด์ด๋ฒ ์ด์ค ์ฝ์๋ก ์ด๋ํด์ flutter ํ๋ก์ ํธ ์์ํ๊ธฐ ๋ฒํผ ํด๋ฆญ 3.1 ์์ ๊ณต๊ฐ ์ค๋น๋ ๋๋ด๋์ 3.2 flutterfire cli ์ค์น ๋ฐ ์คํ๋ ์๋ฃ 4. ํ๋ก์ ํธ ํด๋ lib/firebase_options.dart ํ์ผ ์์ฑ๋๊ฒ์ ํ์ธ - ๋ค๋ง ๋ด๋ถ์ ์ผ๋ก firebase_core ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ์์ด์ ์ค๋ฅ๊ฐ ๋์๋ ์ํ์ 5. firebase_core ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ถ๊ฐ flutter pub add firebase_core - ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ์ถ๊ฐ๋๋ฉด์ ์ค๋ฅ ์ฌ๋ผ์ง 6. main.dart ํ์ผ์ ์๋ ๋ด์ฉ ์ ๋ ฅ import 'package:firebase_core/firebase_core.dart'; imp.. 2023. 6. 26. ์ด์ 1 2 3 4 5 6 7 ยทยทยท 13 ๋ค์