[코드팩토리] [초급] Flutter 3.0 앱 개발 - 10개의 프로젝트로 오늘 초보 탈출!
코드팩토리 디스코드에 질문하면 더욱 빠르게 질문을 받아 볼 수 있습니다! [코드팩토리 디스코드] https://bit.ly/3HzRzUM - 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. SatefulWidget 라이프 사이클 강의를 듣던 중 "인스턴스 되었다"를 제가 나름 정리했는데 제가 이해한 것이 맞을 까요? CodeFactory 예제에서는 CodeFactory 클래스가 정의되고 이를 HomeScreen에서 호출되어 실행된다. CodeFactory가 정의된 상태로 있지 않고, 실제로 사용되기 “메모리”에 객체가 생성되었기에, CodeFactory 가 인스턴스화 되었다고 볼수 있다. 즉, 인스턴스화는 두가지 개념을 말한다고 볼 수 있다. 클래스(설계도)로 객체(설계도에 따라 만들어진 제품) 를 만든다 실행(ex. 화면에 띄우기)을 위해 메모리가 객체가 만들어 지는 것
[코드팩토리] [초급] Flutter 3.0 앱 개발 - 10개의 프로젝트로 오늘 초보 탈출!
웹뷰 강의 듣는 중에 오류가 생겨 문의드립니다. pub dev에서 웹뷰 플러터 패키지를 설명대로 플러터 터미널을 이용해 내려받고 pubspec.yaml에서도 등록했습니다. 안드로이드/app/src 빌드.그래들 파일에도 minsdkversion을 19로 작성도 했습니다. 21도 적어봐라 flutter clean해서 다시 pub get 해라는 글도 봐서 그렇게 했는데도 안 됩니다...ㅜ 자꾸 디버깅 에러라며 코드 실행 자체가 안 되네요. 앱이 빌드가 안 됩니다. ㅜㅜ 웹뷰 패키지를 main.dart에 임포트할 때는 정상인데 디버깅 때 이럽니다. 그래서 pubspec.yaml에서 해당 웹뷰 패키지를 제거하면 또 잘 빌드 됩니다...해당 패키지만 켜면 안 돼요. 구글링 해보니 jdk를 21로 설정해라...그래들 업데이트를 해라 이래저래 해봤는데도 안 되네요.. 해당 내용은 이렇습니다. 어찌 해야할까요. 검색해서 이래저래 해봤는데 아무래도 한계인 거 같아 문의드립니다. Running Gradle task 'assembleDebug'... FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':webview_flutter_android:compileDebugJavaWithJavac'. > Could not resolve all files for configuration ':webview_flutter_android:androidJdkImage'. > Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. > Execution failed for JdkImageTransform: C:\Users\admin\AppData\Local\Android\sdk\platforms\android-34\core-for-system-modules.jar. > Error while executing process C:\Program Files\Android\Android Studio\jbr\bin\jlink.exe with arguments {--module-path C:\Users\admin\.gradle\caches\transforms-3\4a46fc89ed5f9adfe3afebf74eb8bfeb\transformed\output\temp\jmod --add-modules java.base --output C:\Users\admin\.gradle\caches\transforms-3\4a46fc89ed5f9adfe3afebf74eb8bfeb\transformed\output\jdkImage --disable-plugin system-modules} * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. BUILD FAILED in 3s Error: Gradle task assembleDebug failed with exit code 1
안녕하세요? 강의 잘 따라해 보고 있습니다. 제목 그대로 동영상 파일을 다운로드 받기 위해 flutter_file_downloader 패키지를 설치한 이후 앱을 재실행하면 오류가 발생합니다. ----------------------------------------------- FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring project ':flutter_file_downloader'. > Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl. > Namespace not specified. Specify a namespace in the module's build file. See https://d.android.com/r/tools/upgrade-assistant/set-namespace for information about setting the namespace. If you've specified the package attribute in the source AndroidManifest.xml, you can use the AGP Upgrade Assistant to migrate to the namespace value in the build file. Refer to https://d.android.com/r/tools/upgrade-assistant/agp-upgrade-assistant for general information about using the AGP Upgrade Assistant. * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. BUILD FAILED in 889ms Error: Gradle task assembleDebug failed with exit code 1 ----------------------------------------------- 현재 최신 버전이 2.0.0 인데,, 예제 소스 상의 버전이 1.2.1 인데, 이 버전을 받아 봐도 동일한 현상입니다. 동영상 강의에서 강의노트에 설명을 달아 놓으셨다고 하는데, 강의 노트를 찾을 수가 없네요.. 조언 부탁드립니다.
[코드팩토리] [중급] Flutter 진짜 실전! 상태관리, 캐시관리, Code Generation, GoRouter, 인증로직 등 중수가 되기 위한 필수 스킬들!
void paginate({ int fetchCount = 20, // 추가로 데이터 더 가져오기 // true = 더 가져오기 // false = 새로고침 bool fetchMore = false, // 강제로 다시 로딩하기 // true - CursorPaginationLoading() bool forceRefetch = false, }) async { // 5가지 가능성 // State의 상태 // 1) CursorPagination - 정상적으로 데이터가 있는 상태 // 2) CursorPaginationLoading - 데이터 로딩중(현재 캐시 없음 // 3) CursorPaginationError = 에러가 있는 상태 // 4) CursorPaginationRefetching = 첫번째 페이지부터 다시 데이터를 가져올때 // 5) CursorPaginationFetchMore - 추가 데이터를 paginate 해오라는 요청을 받았을때 // 바로 반환하는 상황 // 1) hasMore == false(기존 상태에서 이미 다음 데이터가 없다는 값을 들고 있다면) // 2) 로딩중 - fetchMore : true // fetchMore : false - 새로고침의 의도가 있음. try { if (state is CursorPagination && !forceRefetch) { final pState = state as CursorPagination; if (!pState.meta.hasMore) { return; } } final isLoading = state is CursorPaginationLoading; final isRefetching = state is CursorPaginationRefetching; final isFetchingMore = state is CursorPaginationFetchingMore; if (fetchMore && (isLoading || isRefetching || isFetchingMore)) { return; } // PaginationParams 생성 PaginationParams paginationParams = PaginationParams( count: fetchCount, ); // fetchMore if (fetchMore) { final pState = state as CursorPagination; state = CursorPaginationFetchingMore( meta: pState.meta, data: pState.data, ); paginationParams = paginationParams.copyWith( after: pState.data.last.id, ); } final resp = await repository.paginate( paginationParams: paginationParams, ); if (state is CursorPaginationFetchingMore) { final pState = state as CursorPaginationFetchingMore; // 기존 데이터에 새로운 데이터 추가 state = resp.copyWith(data: [ ...pState.data, ...resp.data, ]); } else { state = resp; } } catch (e) { state = CursorPaginationError(message: '데이터를 가져오지 못했습니다.'); } } 이부분이 있는데 왜 하위의 fetchMore의 else문에서 또 조건을 걸어놓는지 궁금합니다. // fetchMore if (fetchMore) { final pState = state as CursorPagination; state = CursorPaginationFetchingMore( meta: pState.meta, data: pState.data, ); paginationParams = paginationParams.copyWith( after: pState.data.last.id, ); } // 데이터를 처음부터 가져오는 상황 else { // 만약 데이터가 있는 상황이라면 기존 데이터 보존한 채로 Fetch(API 요청)을 진행 if (state is CursorPagination && !forceRefetch) { final pState = state as CursorPagination; state = CursorPaginationRefetching( meta: pState.meta, data: pState.data, ); } else { state = CursorPaginationLoading(); } }
메인화면에서 뒤로가기 눌렀을때 어플 종료를 하고 싶어서 메인화면에서 WillPopScope( onWillPop: () async => false, 이 부분을 수정하였습니다. 수정한 결과 어플이 종료는 되나. 다시 어플을 실행했을때 splash화면에서 다음 화면으로 넘어가지 않습니다.. 아마도 사용자 정보를 가져오지 못해서 그런것 같은데.. 방법이 없을까요?
[코드팩토리] [중급] Flutter 진짜 실전! 상태관리, 캐시관리, Code Generation, GoRouter, 인증로직 등 중수가 되기 위한 필수 스킬들!
강의 보면 로그인 스크린의 빌드 컨텍스트 내부에 storage를 선언하셨는데, class _LoginScreenState extends State<LoginScreen> { String user = ""; String password = ""; @override Widget build(BuildContext context) { final storage = FlutterSecureStorage(); final dio = Dio(); final emulatorIp = '10.0.2.2:3000'; final simulatorIp = '127.0.0.1:3000'; final ip = Platform.isIOS ? simulatorIp : emulatorIp; return ...; } } 이 부분에서 왜 빌드컨텍스트 내부에 작성했는지 궁금합니다.
4강애싱크 프로그래밍에서 12:46에서 addnumber함수는 비동기함수가 아니라 동기함수 아닌가요?그럼 위에 addnumber()가 끝나고(2초기다리는거까지 하고)나서 밑에 addnumber()가 실행돼야하는거 아닌가요?? 왜 위 addnumber의 2초를 기다리지 않고 밑에 addnumber를 실행하죠? Addnumber의 반환타입이 Future<void>가 아니라 그냥 void니까 동기함수 아닌가요??
[코드팩토리] [초급] Flutter 3.0 앱 개발 - 10개의 프로젝트로 오늘 초보 탈출!
에뮬레이터가 실행은 되는데 컴퓨터 재부팅하고 나니 이런 메세지가 뜨고 계속 <no device selected> 로 나옵니다. 실행을 해볼 수가 없어서 어떻게 수정하면 될까요? 코드팩토리 디스코드에 질문하면 더욱 빠르게 질문을 받아 볼 수 있습니다! [코드팩토리 디스코드] https://bit.ly/3HzRzUM - 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요.
섹션8에서 게시글 정보 가져오기에서16:00 WidgetsBinding.instance.addPostFrameCallback(callback) 나봅니다. 강의처럼 timeStamp가 나오지 않고, 그래서 그냥 진행했습니다. WidgetsBinding.instance.addPostFrameCallback((_) async { 그런데 다음과 같이 에러가 뜨네요. 이런 메세지가 뜨는 이유가 뭔가요
[코드팩토리] [중급] Flutter 진짜 실전! 상태관리, 캐시관리, Code Generation, GoRouter, 인증로직 등 중수가 되기 위한 필수 스킬들!
final List<Map<String,dynamic> products; 위와 같이 진행한다면 factory RestaurantDetailModel.fromJson({ required Map<String, dynamic> json, }) { return RestaurantDetailModel( id: json['id'], name: json['name'], thumbUrl: 'http://$ip${json['thumbUrl']}', tags: List<String>.from(json['tags']), priceRange: RestaurantPriceRange.values.firstWhere( (element) => element.name == json['priceRange'], ), ratings: json['ratings'], ratingsCount: json['ratingsCount'], deliveryTime: json['deliveryTime'], deliveryFee: json['deliveryFee'], detail: json['detail'], products: List<Map<String, dynamic>>.from(json['products']), ); } fromJson 도 위와 같이 변경될 것 같은데, 이런 방식은 비효율적이거나 권장되지 않는 방식인가요? 객체 안의 객체를 따로 모델링 하는 이유는 객체 안의 객체를 인스턴스화해서 재사용하는데 목적이 있는 건가요? 수업때 설명한 방식은 List 안에 Map 형태의 키값이 정해지지 않아 데이터 추출이 번거로워질 수 있다고 생각하면 되나요?