[코드팩토리] [초급] Flutter 3.0 앱 개발 - 10개의 프로젝트로 오늘 초보 탈출!
안녕하세요, Flutter에 익숙해지기 위해 해당 강의를 보며 샘플 코드(?)와 비슷하게 코드를 추가하고 hot reload 버튼을 눌렀습니다. 그러자 IOS simulator(iPhone 14 Pro Max)에서 "Lookup failed: title in @getters in MyHomePage in package:hello_world/main.dart" 에러가 발생하여 추가 한 코드가 정상동작을 하는지, 수정해야 하는 부분이 있는지 확인이 불가능하게 되었습니다. 혹시 제가 추가한 코드에서 문제가 될 만한 부분이 있을까요? 제가 추가한 코드와 IOS simulator 에러 화면 첨부드립니다.
[코드팩토리] [중급] Flutter 진짜 실전! 상태관리, 캐시관리, Code Generation, GoRouter, 인증로직 등 중수가 되기 위한 필수 스킬들!
안녕하세요. 실험적으로 Code Generator 기능을 이용해서 프로바이더를 다시 작성해보고 있습니다. 궁금한 게 Section 9. 다섯 번째 강의를 보는데, 1분 대에 나오는 RestaurantStateNotifier와 StateNotifierProvider를 어떻게 CodeGenerator를 이용해서 고칠 수 있을까 고민 중입니다. 시도한 코드는 아래와 같은데요(import는 생략했습니다): part 'restaurant_provider.g.dart'; @Riverpod(keepAlive: true) class Restaurant extends _$Restaurant { final RestaurantRepository repository; Restaurant({ required this.repository, }) { paginate(); } // 초기 상태는 Loading 상태로 @override CursorPaginationBase build() { return CursorPaginationLoading(); } paginate() async { final response = await repository.paginate(); state = response; } } 코드 제너레이션은 잘 되는데, 문제는 이를 실행시키려고 하니 다음과 같은 에러가 뜹니다. Launching lib/main.dart on iPhone 14 Pro Max in debug mode... main.dart:1 Xcode build done. 3.9s Failed to build iOS app Error (Xcode): lib/restaurant/provider/restaurant_provider.g.dart:15:3: Error: The argument type 'Restaurant Function({RestaurantRepository repository})' can't be assigned to the parameter type 'Restaurant Function()' because 'Restaurant Function({RestaurantRepository repository})' is nullable and 'Restaurant Function()' isn't. restaurant_provider.g.dart:15 Could not build the application for the simulator. Error launching application on iPhone 14 Pro Max. Exited 이전까지는 잘 됐었는데, 바로 직전 강의에서 CursorPaginationBase를 만들고, 이를 상속받는 CursorPagination 상태들을 구현하고 나서부터, 문제가 발생한 것 같습니다. 아마 CursorPagination의 경우는 data와 meta라는 필드가 들어가는데, 어디선가 Code generation에 문제가 생겨서, CursorPaginationBase가 아닌, data와 Meta를 필요로 하는 생성자가 호출된 건 아닌가 의심하는 중입니다. 아래는 위 코드로 생성된 .g.dart 파일입니다. // GENERATED CODE - DO NOT MODIFY BY HAND part of 'restaurant_provider.dart'; // ************************************************************************** // RiverpodGenerator // ************************************************************************** String _$restaurantHash() => r'50915edab0a63433f5d54b932240cf504147e391'; /// See also [Restaurant]. @ProviderFor(Restaurant) final restaurantProvider = NotifierProvider<Restaurant, CursorPaginationBase>.internal( Restaurant.new, name: r'restaurantProvider', debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') ? null : _$restaurantHash, dependencies: null, allTransitiveDependencies: null, ); typedef _$Restaurant = Notifier<CursorPaginationBase>; // ignore_for_file: unnecessary_raw_strings, subtype_of_sealed_class, invalid_use_of_internal_member, do_not_use_environment, prefer_const_constructors, public_member_api_docs, avoid_private_typedef_functions 어떻게 하면 Code Generator를 이용해서 문제를 해결할 수 있을까요?
[코드팩토리] [초급] Flutter 3.0 앱 개발 - 10개의 프로젝트로 오늘 초보 탈출!
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 코드팩토리 디스코드 https://bit.ly/3HzRzUM Flutter 강의를 구매하시면 코드팩토리 디스코드 서버 플러터 프리미엄 채널에 들어오실 수 있습니다! 디스코드 서버에 들어오시고 저에게 메세지로 강의를 구매하신 이메일을 보내주시면 프리미엄 채널에 등록해드려요! 프리미엄 채널에 들어오시면 모든 질의응답 최우선으로 답변해드립니다! video영상을 choose하면 compressing video를 거치고 메인으로 돌아가버려요 뭐가 문제일까요?
[코드팩토리] [초급] Flutter 3.0 앱 개발 - 10개의 프로젝트로 오늘 초보 탈출!
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 코드팩토리 디스코드 https://bit.ly/3HzRzUM Flutter 강의를 구매하시면 코드팩토리 디스코드 서버 플러터 프리미엄 채널에 들어오실 수 있습니다! 디스코드 서버에 들어오시고 저에게 메세지로 강의를 구매하신 이메일을 보내주시면 프리미엄 채널에 등록해드려요! 프리미엄 채널에 들어오시면 모든 질의응답 최우선으로 답변해드립니다! 강의대로 따라해도,최신버전을 넣어도 Pub get 에러가 계속생기는데 다른 설정을 따로 해야하나요? 윈도우10 사용중입니다
[코드팩토리] [초급] Flutter 3.0 앱 개발 - 10개의 프로젝트로 오늘 초보 탈출!
안녕하세요 강사님, 구글지도 사용해보기 수업을 듣는데 지도가 나타나지 않아 질문드립니다. PlatformView, registerViewFactory가 호출되었는지 확인하라는 메세지로 파악했으나 해결 방법을 찾지 못하고 있습니다. 에러 메세지는 아래와 같습니다. [VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(unregistered_view_type, A UIKitView widget is trying to create a PlatformView with an unregistered type: < plugins.flutter.io/google_maps >, If you are the author of the PlatformView, make sure registerViewFactory is invoked. See: https://docs.flutter.dev/development/platform-integration/platform-views#on-the-platform-side-1 for more details. If you are not the author of the PlatformView, make sure to call GeneratedPluginRegistrant.register ., null) #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:652:7) #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:310:18) <asynchronous suspension> #2 PlatformViewsService.initUiKitView (package:flutter/src/services/platform_views.dart:242:5) <asynchronous suspension> #3 UiKitViewState. createNewUiKitView (package:flutter/src/widgets/platform_view.dart:649:44) <asynchronous suspension>
[코드팩토리] [초급] Flutter 3.0 앱 개발 - 10개의 프로젝트로 오늘 초보 탈출!
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 코드팩토리 디스코드 https://bit.ly/3HzRzUM Flutter 강의를 구매하시면 코드팩토리 디스코드 서버 플러터 프리미엄 채널에 들어오실 수 있습니다! 디스코드 서버에 들어오시고 저에게 메세지로 강의를 구매하신 이메일을 보내주시면 프리미엄 채널에 등록해드려요! 프리미엄 채널에 들어오시면 모든 질의응답 최우선으로 답변해드립니다! 강의에 나온대로 resolveWith를 사용해서 실행했는데 버튼을 눌러도 계속 빨강색으로 뜨고 하얀색으로 바뀌질 않아요. 뭐가 문제인걸까요?ㅠㅠ
일단 새로운 프로젝트 만들고 premain 추가해주는 것 까진 강의를 그대로 따라하시면 됩니다. manifest plugin 부터 조금 차이가 있어서 거기부터 설명하면, build gradle 에 다음과 같이 추가한다. tasks.named('jar') { manifest { attributes( 'Implementation-Title': project.name, 'Implementation-Version': project.version, 'Premain-Class' : "com.java.magicianAgent.MagicianAgent", 'Can-Redefine-Classes' : true, 'Can-Retransform-Classes' : true) } } 터미널에서 다음 명령어를 통해 build 한다 ./gradlew clean build build.libs file 안에 있는 jar file 을 확인한다. (옵션) 강의에서와 마찬가지로 zip file 로 변경하면 확인가능합니다. 저같은 경우 SNAPSHOT.jar 과 SNAPSHOT -plain.jar 이렇게 2개가 생겼는데 SNAPSHOT.jar 은 제가 spring boot 로 실행서 그런지 관련 설정들이 보이고 SNAPSHOT -plain.jar 이 맞는거 같더라구요. jar file 의 절대 경로를 복사해 VM option 에 추가한다. 여기서부터는 다시 강의와 같습니다. VM option 이 안보이시면 오른쪽에 Modify options 클릭하면 add vm options 라고 보이실 겁니다. 이상한거나 궁금한거 있으시면 말씀해주세요. gradle 을 쓰시는 모든 분들도 마술을 성공시킵시다 하하
2일째 고민을 해보았는데.. 2%까지만 맞고 틀리다고 합니당..ㅠㅠ 포기하고 싶지 않은 마음에 도움을 요청합니다!! 제가 짠 코드는 이렇습니다! import java.io.*; import java.util.*; // 불이 하나가 아닌 여러개일 수 있다. public class Main { public static int R; public static int C; public static String[][] map; public static int[][] visitedFire; public static int[][] visitedHuman; public static int[] dx; public static int[] dy; public static Node fireLocation; public static Node humanLocation; public static Queue<Node> fireQueue; public static void main(String[] args) throws IOException { // 초기화 BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); StringTokenizer st = new StringTokenizer(br.readLine()); R = Integer.parseInt(st.nextToken()); C = Integer.parseInt(st.nextToken()); map = new String[R][C]; // 0으로 초기화 visitedFire = new int[R][C]; visitedHuman = new int[R][C]; dx = new int[]{0,1,0,-1}; dy = new int[]{-1,0,1,0}; fireQueue = new LinkedList<>(); // 맵 입력 for (int i = 0; i < R; i++) { String S = br.readLine(); for (int j = 0; j < C; j++) { // 불 좌표, 지훈이 좌표 찾기 map[i][j] = String.valueOf(S.charAt(j)); if(map[i][j].equals("J")){ humanLocation = new Node(j,i); map[i][j] = "."; // .으로 변경 }else if(map[i][j].equals("F")){ // 불이 여러개, 불이 아무것도 없을 수 있다. -> 반레 fireLocation = new Node(j,i); fireQueue.add(fireLocation); visitedFire[i][j] = 1; } } } // (1) 불이 이동할 수 있는 최단경로 fireBfs(); // (2) 사람이 이동할 수 있는 최단경로 + 길 비교해야함 humanBfs(humanLocation.y, humanLocation.x); // 가능한 길 찾아서 int result = Integer.MAX_VALUE; // (3) 가장 짧은 최단거리 찾기 (가장자리 찾기) for (int i = 0; i < visitedHuman.length; i++) { for (int j = 0; j < visitedHuman[i].length; j++) { if((0<i && i<R-1) && 0 < j && j < C-1)continue; // 가장자리가 아닌 경우 pass if(visitedHuman[i][j] > 0) { result = Math.min(result, visitedHuman[i][j]); } } } if(result == Integer.MAX_VALUE){ System.out.println("IMPOSSIBLE"); }else{ System.out.println(result); } } public static void humanBfs(int y, int x){ // tkfk visitedHuman[y][x] = 1; Node node = new Node(x,y); Queue<Node> queue = new LinkedList<>(); queue.add(node); while(queue.size()>0){ Node cur = queue.poll(); for (int i = 0; i < 4; i++) { int nx = cur.x + dx[i]; int ny = cur.y + dy[i]; if(nx < 0 || nx >= C || ny < 0 || ny >= R) continue; if(visitedHuman[ny][nx] == 0 && (map[ny][nx].equals("."))){ if(visitedHuman[ny][nx] < visitedFire[ny][nx] || visitedFire[ny][nx] == 0){ visitedHuman[ny][nx] = visitedHuman[cur.y][cur.x] + 1; Node next = new Node(nx,ny); queue.add(next); } } } } } public static void fireBfs(){ while(fireQueue.size()>0){ Node cur = fireQueue.poll(); for (int i = 0; i < 4; i++) { // 4방향 탐지 int nx = cur.x + dx[i]; int ny = cur.y + dy[i]; if(nx < 0 || nx >= C || ny < 0 || ny >= R) continue; if(visitedFire[ny][nx] == 0 && (map[ny][nx].equals("."))){ visitedFire[ny][nx] = visitedFire[cur.y][cur.x] + 1; // 이동함을 표현 Node next = new Node(nx,ny); fireQueue.add(next); } } } } public static class Node { int x; int y; Node(int x, int y){ this.x = x; this.y = y; } } }
[Bloc 응용] 실전 앱 만들기 (책 리뷰 앱) : SNS 로그인, Firebase 적용, Bloc 상태 관리, GoRouter
review_write_page에서 ReviewBox 부분에 리뷰를 작성후 textfield에서 focus out이 되었을때 작성한 리뷰 text가 안보이는 현상이 있습니다. text가 사라지고 저장을 하게 되면 DB에는 데이터가 제대로 들어갑니다. 혹시 이부분은 어디를 수정해야 될까요?
[코드팩토리] [중급] Flutter 진짜 실전! 상태관리, 캐시관리, Code Generation, GoRouter, 인증로직 등 중수가 되기 위한 필수 스킬들!
동일하게 restaurant_repository에서 @Headers 를 통해 'accessToken' : 'true' 라는 map을 헤더에 넣어주었음에도 dio.dart에서는 해당 onRequest에서 header가 빈 map으로 나오는 현상이 발생합니다. url과 GET 요청이라는 정보는 제대로 들어갑니다. 혹시 무슨 문제인지 알고 계신가요?
void main() { int total = 0; for (int i = 0; i < 10; i++) { total += 1; if (total == 5) { break; } } print(total); } ->5 여기서 0이였던 i 값이 1(i++)이되고 total 은 1이 되며(total+=1) 또 반복으로 i 값이 2가되고 total 은 2가 되고 쭉 반복되어 total 이 5가되었을때 나와서 출력된거맞나요?
안녕하세요 강의 잘 듣고있습니다. 컬렉션 List<data type> 변수 = ['지수', '제니']; Map <key:value> 변수 = { 'key' : 'value'}; Set<data type> 변수 ' { ........}; enum Status {..} List 만 [] 대괄호 나머지는 {}중괄호를 쓰는 이유가 뭔가요 그냥 공식일까요? 그리고 enum Status { approved, pending, rejected } void main() { Status status = Status.approved; print(status); } 이 예제에서 Status는 키워드 인가요?