๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

์›น๊ณต๋ทฐ/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.