전체 글
-
[메모] flutter const, finalflutter 2021. 11. 17. 14:35
https://medium.com/dartlang-korea/dart-final-%EA%B3%BC-const-bc8c6c024ef4 final 과 const 선언 final 과 const 는 아래와 같은 방식으로 선언한다. final double pi = 3.141592; const double e = 2.71828; 위에서 정의된 pi 와 e 는 이제 다른 값으로 변경할 수 없다. 다른 값을 변경하려고 시도하면 컴파일 오류가 발생한다. final 과 const 는 한번 설정한 값을 변경할 수 없게 한다는 공통점이 있는 반면, 차이점도 존재한다. const 의 경우, 컴파일 타임에서 상수를 정의할 수 있다. 즉, const 로 정의한 상수는 런타임에서 정의되는 값을 설정할 수 없다는 의미다. 예를 들어 ..
-
[메모 스크랩] bloc state는 항상 불변이어야하는가?flutter 2021. 11. 17. 14:31
https://github.com/felangel/bloc/issues/292 상태는 항상 불변이어야 합니까? #292 닫은 VivekKannaV 가 이 문제를 열었습니다. on 14 May 2019 · 3개의 댓글 코멘트 양수인 펠란젤 라벨 질문 프로젝트 bloc Done 중요한 단계 이정표 없음 연결된 풀 리퀘스트 pull 요청을 성공적으로 병합하면 이 문제가 종료될 수 있습니다. 아직 없음 알림 사용자 정의 구독하다 이 스레드에서 알림을 받고 있지 않습니다. 참가자 2명 VivekKannaV 댓글을 달다 on 14 May 2019 • 편집 일부 블로그 또는 자습서에서 변경할 수 없는 주석이 있는 상태를 생성하는 것을 보았습니다 . 참고: flutter_bloc_with_stream 항상 불변이어야 ..
-
파이어스토어 해당 값이 있는지 없는지 확인파이어베이스 2021. 11. 5. 20:18
좋아요 기능이나 기타 여러가지 검증작업시, 해당 값이 있나 없나 파악해야 할 때가 있습니다. 다른 방법도 있겠지만.. 저같은경우 기본 콜렉션 밑에 서브 콜렉션으로 검증이 필요한 도큐먼트를 입력하게하여 구현했습니다. //게시글에 좋아요를 클릭한 사용자의 아이디값을 입력 Future addPostLikeUser(String? postUid, String? userId, var ref) { return ref .collection('likeUser') .doc(userId) .set({'userId': authBloc.currentUserId, 'postUid': postUid}); } //좋아요 한적 있는지 체크 Future ifExistLike(String? postUid, String userId) { ..
-
파이어베이스 도큐먼트 id 자동생성파이어베이스 2021. 11. 3. 15:01
파이어스토어에서 문서의 유니크id를 얻으려면 String docsUid = await _db .collection('posts') .add(post.toMap() as Map) .then((docs) => _db.collection('posts').doc(docs.id).id); 이런식으로 문서를 insert후에 해당 문서의 id값을 가져와도 되지만, 어떠한 이유로 문서 add가 되지 않을시, 해당 문서id를 가져올 수가 없고, 그문서와 문서id에 영향받게되는 일련의 작업들이 있다면 오류를 발생시킬 수있으므로 좋은 방법이 아니다. 때문에 미리 지정된 id를 사용하는게 좋고, 그래야 쓰기과정부터 batch 작업단위에 포함시킬 수 있다. 입력하기 전에 미리 생성할 수도 있다. DocumentReference..
-
flutter batch 사용flutter 2021. 10. 27. 16:16
String docsUid = await _db .collection('posts') .add(post.toMap() as Map) .then((docs) => _db.collection('posts').doc(docs.id).id); --> 파이어베이스에 1개의 문서를 입력하고 그 도큐먼트 id를 저장했다. var ref = _db.collection('posts').doc(docsUid); WriteBatch writeBatch = _db.batch(); -> 쓰기 배치 인스턴스를 생성했다. var wrongRef = _db.collection('postssssss').doc(docsUid); -> 존재하지 않는 경로의 레퍼런스를 일부러 할당해봤다. writeBatch.update(wrongRef, ..
-
flutter -> kotlin 함수 호출kotlin 2021. 10. 19. 19:02
Flutter에서 코틀린 함수 호출.. in Flutter -> static const platform = const MethodChannel('io.myapp.application'); 함수 호출할때.. await platform.invokeMethod('getTestFunc'); getTestFunc부에 함수 이름 넣으면됨. 호출받는 MainActivity ...> package com.project.application import android.content.Context import android.content.ContextWrapper import android.content.Intent import android.content.IntentFilter import android.os.Batte..
-
키보드 고정 UIflutter 2021. 9. 8. 22:34
https://pub.dev/packages/keyboard_attachable keyboard_attachable | Flutter Package A Flutter package to build widgets that can be attached to the soft keyboard. pub.dev 를 사용하면 키보드가 활성화될때 고정된 UI를 보여줄 수 있습니다. import 후 하단과 같이 사용합니다. KeyboardAttachable( backgroundColor: Colors.blue, child: Container( padding: const EdgeInsets.all(16), color: Colors.blue, child: // 원본 const TextField( decoration: Inp..
-
flutter 텍스트 폰트크기 고정flutter 2021. 9. 8. 22:30
return MaterialApp( builder: (context, child) { return MediaQuery( data: MediaQuery.of(context).copyWith(textScaleFactor: 1), child: child!, ); }, // 뒷부분 코드 임의 삭제 이런식으로 MaterialApp의 builder 에서 textScaleFactor 값을 주면 핸드폰의 글자 폰트 크기와 관계없이 앱내부적으로 폰트 크기를 고정할 수 있습니다.