TIL #007
191110 일
오늘 배운 점
<Flutter>
1. Firebase를 통한 Google 소셜 로그인 성공 - GradleException 에러 해결
- Firebase SDK를 도입하는 과정에서 build.gradle을 수정해야 하는데, 분명 Firebase에서 시키는 대로 코드를 입력했는데 cannot resolve symbol ~ 관련 GradleException 에러가 발생한다. 이럴 때는 프로젝트 전체를 한번 깨끗하게 밀어야(?) 한다.
- 이렇게 안드로이드 스튜디오에서 File > Invalidate Caches / Restart를 눌러서 프로젝트 관련 모든 캐시를 무효화(삭제)하고 재빌드하는 방법이다.
- 만병통치약이라는 이 방법도 해결되지 않아 찾아본 방법은 GradleException을 FileNotFoundException으로 바꾸어주는 것. Android API 29 Java 버전에서 GradleException()은 더 이상 지원하지 않는다는 걸 발견했다. (진짜 도큐멘테이션 업데이트 좀 해라 플러터야)
- 이 문제를 해결하고 나니 나머지는 순탄했다.
참고한 링크 : https://kim-hoya.tistory.com/45
https://github.com/flutter/flutter/issues/29608
2. 공감 및 북마크 status 받아오기
void like(int i) async { //잔수정
ReMentParam.allReMents[i].isLike = jsonData['isLike'];
}
class ReMentOne {
bool isLike;
bool isMyment;
factory ReMentOne.fromJson () {
return ReMentOne(
json['isLike'],
json['isMyment'],
);
}
}
3. 댓글 및 대댓글 작성, 업로드
- TextEditingController를 활용
class _WriteCommentState extends State<WriteComment> {
final TextEditingController _textEditingController = TextEditingController();
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: _buildText(),
),
);
}
Widget _buildText() {
return Container(
margin: const EdgeInsets.symmetric(horizontal: 8.0),
child: Row(
children: <Widget>[
Flexible(
child: TextField(
controller: _textEditingController,
onSubmitted: _handleSubmitted,
decoration: InputDecoration.collapsed(
hintText: "댓글을 입력하세요",
),
),
),
Container(
margin: const EdgeInsets.symmetric(horizontal: 4.0),
child: IconButton(
icon: Icon(Icons.send),
onPressed: () => _handleSubmitted(_textEditingController.text),
),
),
],
),
);
}
void _handleSubmitted(String text) async {
final res = await http.post(
Cookie.serverUrl + '/writeUpMent', headers: {HttpHeaders.cookieHeader: Cookie.rawCookie}, body: {'postId': PostParam.postId, 'text': text});
final jsonData = json.decode(res.body);
print(jsonData);
_textEditingController.clear();
}
}
4. 글/댓글 삭제하기, 사용자가 작성한 글/댓글만 삭제 버튼 뜨게 하기
- 삭제 후 리스트 새로고침하기는 아직 시도중
_data.rementOne[i].isMyment == true ?
OutlineButton(
borderSide: BorderSide(color: Colors.red),
textColor: Colors.red,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0)),
child: Text('삭제',
style: TextStyle(fontSize: 18, fontFamily: 'Noto_Bold'),),
onPressed: () async {
final id = ReMentParam.allReMents[i]._id;
_data.rementOne.removeWhere((item) => item._id == id);
final res = await http.get(Cookie.serverUrl + '/removeDownMent/' + id, headers: {HttpHeaders.cookieHeader: Cookie.rawCookie});
final jsonData = json.decode(res.body);
_refresh();
}): Container(),
내일 배울 점
<Flutter>
1. 리스트 새로고침하기
- RefreshIndicator와 onFresh 활용
2. 프로필 수정 기능
3. 팔로잉한 사용자들 게시물 불러오는 기능
4. 토요일에 테스트할 검색 텍스트 필드 넣기 (MongoDB)
5. 토요일에 소셜로그인 테스트
더보기
- 배포까지 얼마 안 남아서 할 일이 무쟈게 많다ㅜㅜ
'삽질하는 개발자 hashblown' 카테고리의 다른 글
프론트엔드 개발자의 TIL #009 (0) | 2019.11.12 |
---|---|
프론트엔드 개발자의 TIL #008 (0) | 2019.11.11 |
프론트엔드 개발자의 TIL #006 (0) | 2019.11.09 |
프론트엔드 개발자의 TIL #005 (0) | 2019.11.08 |
프론트엔드 개발자의 TIL #004 (0) | 2019.11.07 |
댓글