์น๊ณต๋ทฐ/flutter13 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. flutter ํ๋ฌํฐ csv ํ์ผ ์ฝ๊ธฐ ๊ธฐ๋ฅ : ํ๋ฉด์์ ํน์ ๋ฒํผ์ ๋๋ฅด๋ฉด csv ํ์ผ์ ์ฝ์ด์จ๋ค. 1. pub csv ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ถ๊ฐ https://pub.dev/packages/csv/install csv | Dart Package A codec to transform between a string and a list of values. The string must be comma (configurable) separated values. pub.dev flutter pub add csv pubspec.yaml ํ์ผ์ ์๋์ ๊ฐ์ด ๋ฑ๋ก๋จ์ ํ์ธ dependencies: flutter: sdk: flutter # The following adds the Cupertino Icons font to your application. # Use .. 2023. 6. 26. ์ด์ 1 2 3 4 ๋ค์