글

라벨이 flutter인 게시물 표시

flutter drift vs hive

`Hive`와 `Drift`는 Flutter에서 로컬 데이터를 저장하기 위한 두 가지 인기있는 패키지입니다. 각각의 특징과 장단점을 알아보겠습니다. ### Hive #### 장점: 1. **성능**: Hive는 빠른 읽기 및 쓰기 연산을 제공합니다. 2. **간단함**: Hive의 API는 매우 간단하며, 객체를 빠르게 저장하고 검색할 수 있습니다. 3. **타입 안정성**: Hive는 Dart의 strong typing을 지원합니다. 4. **Zero Serialization**: Hive는 런타임 시 객체 직렬화가 필요 없습니다, 빠르게 데이터를 읽고 쓸 수 있습니다. 5. **다양한 데이터 유형 지원**: Hive는 간단한 키-값 스토어로도, 복잡한 JSON 객체로도 사용할 수 있습니다. 6. **크로스 플랫폼**: Android, iOS, 데스크톱 및 브라우저에서 사용할 수 있습니다. #### 단점: 1. **SQL 미지원**: Hive는 SQL 쿼리를 지원하지 않습니다. 따라서 복잡한 쿼리나 조인을 실행할 수 없습니다. 2. **데이터베이스 관계 미지원**: Hive는 관계형 데이터베이스가 아니므로, 테이블 간의 관계를 설정할 수 없습니다. ### Drift (moor) #### 장점: 1. **SQL 지원**: Drift는 SQLite를 기반으로 하므로 SQL 쿼리를 지원합니다. 2. **강력한 쿼리**: 조인, 서브쿼리, 복잡한 WHERE 절 등을 사용할 수 있습니다. 3. **타입 안전성**: Drift는 컴파일 타임에 쿼리 검사를 지원하여 타입 안전성을 제공합니다. 4. **반응형 프로그래밍**: Drift는 `Stream`을 이용한 반응형 프로그래밍을 지원합니다. 5. **데이터 마이그레이션**: 스키마 변경을 안전하게 관리할 수 있습니다. #### 단점: 1. **복잡성**: SQL과 스키마 마이그레이션 등을 관리해야 하므로 Hive보다 초기 학습 곡선이 높을 수 있습니다. 2. **성능**: Hive가 직렬화가 필요 없는 반면, Drift...

플러터 version: 1.0.0+1 뜻

Flutter에서 `version: 1.0.0+1`과 같은 표시는 앱의 버전 정보를 나타냅니다. 이 문자열은 두 부분으로 나뉩니다: 1. **Semantic Version (시맨틱 버전)**: `1.0.0` - 이 부분은 앱의 "시맨틱 버전"을 나타냅니다. 일반적으로 `[Major].[Minor].[Patch]` 형식을 따릅니다.     - `Major`: 주요한 변화가 있을 때 증가시킵니다.     - `Minor`: 새로운 기능이 추가되었지만 하위 호환성이 유지될 때 증가시킵니다.     - `Patch`: 버그 수정과 같은 작은 변화가 있을 때 증가시킵니다. 2. **Build Number (빌드 번호)**: `+1` - 이 부분은 앱의 "빌드 번호"를 나타냅니다. 이 번호는 앱의 각 빌드를 구별하는 데 사용됩니다. 일반적으로 새로운 빌드가 생성될 때마다 이 번호를 증가시킵니다. ### Android에서 - `versionCode`는 빌드 번호에 해당합니다. 이 값은 정수여야 하며, 이전 버전보다 커야 합니다. - `versionName`은 시맨틱 버전에 해당합니다. ### iOS에서 - `CFBundleShortVersionString`은 시맨틱 버전에 해당합니다. - `CFBundleVersion`은 빌드 번호에 해당합니다. 따라서, Flutter의 `version: 1.0.0+1` 설정은 Android의 `versionCode`를 1로, `versionName`을 "1.0.0"으로 설정하고, iOS의 `CFBundleVersion`을 1로, `CFBundleShortVersionString`을 "1.0.0"으로 설정합니다.

flutte initstate에서 sqlite db 수정

  https://stackoverflow.com/questions/60777126/how-to-load-initial-state-data-from-sqlite-database-when-flutter-app-open

[flutter] 에러 Ignoring ffi-1.13.1 because its extensions are not built.

 flutter 실행했더니 생긴 오류 brew install cocoapod해서 해결

[flutter]No MediaQuery widget ancestor found

 [flutter]No MediaQuery widget ancestor found return scaffold로 해놨었는데 scaffold를 materialapp로 감싸주니 해결됨

flutter 완성 준비

  앱 아이콘 만들기 https://asufi.tistory.com/entry/Flutter-Flutter-%EC%95%B1-%EC%B6%9C%EC%8B%9C-%ED%95%98%EA%B8%B0-release-build-apk 스플래쉬 스크린 만들기 플러그인 써도 되고 공식문서 참고해도 되고 https://docs.flutter.dev/development/ui/advanced/splash-screen

[flutter] text에 노란 줄

 scaffold를 안써서 생김 https://stackoverflow.com/questions/47114639/yellow-lines-under-text-widgets-in-flutter

[flutter http] Error: XMLHttpRequest error

이미지
flutter 앱에서 django 서버에서 http로 api 받아오는 것을 하고 있었다. 그런데  http.get이 작동안함. 코드를 고쳤더니  Error: XMLHttpRequest error. 이런 에러가 뜨는데 영 무슨 에러인지 모르겠어서 검색을 했더니 비슷한 에러 질문 글들에서 CORS에러, 서버에서 접근을 막은 것일 거라는 답글이 많았다. 크롬으로 실행해서 개발자 도구 열어서 확인 했더니 그게 맞음을 확인. 서버에서 cors관련 설정을 추가하고 경로 지정을 할 수 있는데 그냥 전부 허용으로 해서 해결했다

flutter 코드 formatting 자동 완성

 환경 마다 다 다르다 여기서 참고하기 https://docs.flutter.dev/development/tools/formatting beautify 나 formatting 플러그인을 사용해도 되지만 flutter에 해당하는 건 잘 없다 flutter 앱에 기능으로 포함되어 있는데 설정에 들어가서 format 검색해서 format on paste  format on type format on save 를 활성화해 주었더니 해당 상황에서 작동한다.

primarySwatch는 Colors.black을 받지 않는다.

The argument type 'Color' can't be assigned to the parameter type 'MaterialColor?'  material color를 받기 때문에 white랑 black을 에러가 난다 https://stackoverflow.com/questions/52577366/error-while-changing-the-flutter-theme-color-to-black

flutter admob 구글 배너 광고 추가

 flutter admob 구글 베너 광고 추가 https://developers.google.com/admob/android/quick-start?hl=ko#import_the_mobile_ads_sdk https://developers.google.cn/admob/flutter/banner?hl=ko#banner_ad_events 공식 튜토리얼 따라해서 성공 코드 import 'package:flutter/material.dart' ; import 'package:google_mobile_ads/google_mobile_ads.dart' ; class adtest extends StatefulWidget { const adtest({Key? key}) : super (key: key) ; @override _adtestState createState () => _adtestState () ; } class _adtestState extends State<adtest> { final BannerAd myBanner = BannerAd ( adUnitId: BannerAd. testAdUnitId , size: AdSize. banner , request: AdRequest () , listener: BannerAdListener () , ) ; @override Widget build (BuildContext context) { myBanner .load() ; final AdWidget adWidget = AdWidget (ad: myBanner ) ; return Scaffold ( body: Container ( alignment: Alignment. center , child: adWidget , width: myBanner . size . width .toDouble() , ...

[flutter]multidex 에러

이걸로 해결 https://282-ground.tistory.com/167  

[flutter]The Google Mobile Ads SDK was initialized incorrectly

 The Google Mobile Ads SDK was initialized incorrectly manifest파일에서 잘못된 위치여서 그랬던 것 https://stackoverflow.com/questions/65633194/the-google-mobile-ads-sdk-was-initialized-incorrectly

[flutter]Your project requires a newer version of the Kotlin Gradle plugin.

  ┌─ Flutter Fix ────────────────────────────────────────────────────────────────────────────────┐ │ [!] Your project requires a newer version of the Kotlin Gradle plugin.                       │ │ Find the latest version on https://kotlinlang.org/docs/gradle.html#plugin-and-versions, then │ │ update ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\android\build.gradle:               │ │ ext.kotlin_version = '<latest-version>'                                                      │ └──────────────────────────────────────────────────────────────────────────────────────────────┘ minsdk 고쳤더니 나온 오류 ext.kotlin_version은  projectName/android/app/build.gradle 쪽이 아니라 projectName/android/build.gradle 여기에 있다 https://stackoverflow.com/questions/70919127/your-project-requ...

[flutter] uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:google_mobile_ads]

 uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:google_mobile_ads]  ..../AndroidManifest.xml as the library might be using APIs not available in 16 Suggestion: use a compatible library with a minSdk of at most 16, or increase this project's minSdk version to at least 19, or use tools:overrideLibrary="io.flutter.plugins.googlemobileads" to force usage (may lead to runtime failures) 에러가 친절하게 minSdk를 고치라고 알려줬다. minSdk는 안드로이드 build gradle에 minsdkversion 고치면 된다고한다. https://stackoverflow.com/questions/52060516/how-to-change-android-minsdkversion-in-flutter-project --- ..안드로이드만 바꿔도 되는건가?

[flutter] Navigator operation requested with a context that does not include a Navigator.

 Navigator operation requested with a context that does not include a Navigator. https://stackoverflow.com/questions/50124355/flutter-navigator-not-working/50125296 void main() => runApp(MaterialApp(home: FooClass(),)); 로 고쳐서 해결

flutter sqlite에서 리턴 했는데 Instance of 'Future'라고 뜸

future는 기다려서 받아야하는데 await 쓰는 걸 잊어버렸다 https://stackoverflow.com/questions/55744894/instance-of-futuredynamic-in-flutter

flutter sqlite database storage location 플러터 db위치

  I want to have an SQLite db in my flutter app, so i followed this flutter cookbook:   https://flutter.dev/docs/cookbook/persistence/sqlite I open the database with the following path:  join(await getDatabasesPath(), 'doggie_database.db')  exactly like the tutorial. I ran the app on my Android phone (not emulator). Now i want to inspect the database file on my PC, but i cannot find the file on my phone. I debugged the above statement and it resolves to  /data/user/0/*mypackage*.*app-name*/databases/doggie_database.db , but i can't find the folder  /data  (only  Android/data ) or the file in my file manager neither on my phone nor on my pc. Where is the file and how can i extract it from my phone? I found the solution that works on Android. It is possible to extract the database file by using adb. Connect the phone via USB use the adb shell type  run-as *mypackage*.*app-name* you are in the  /data/data/*mypackage*.*app-name*  folder...