커스텀 위젯 변수 선언 위치 차이
미해결
[코드팩토리] [초급] Flutter 3.0 앱 개발 - 10개의 프로젝트로 오늘 초보 탈출!
StatelessWidget이나 StatefulWidget에서 변수를 선언할 때 빌드 함수 내에 선언하는 것과 빌드 함수 밖에 선언하는 것은 어떤 차이가 있나요?
- flutter
- 클론코딩
173만명의 커뮤니티!! 함께 토론해봐요.
미해결
[코드팩토리] [초급] Flutter 3.0 앱 개발 - 10개의 프로젝트로 오늘 초보 탈출!
StatelessWidget이나 StatefulWidget에서 변수를 선언할 때 빌드 함수 내에 선언하는 것과 빌드 함수 밖에 선언하는 것은 어떤 차이가 있나요?
미해결
코드로 배우는 React 19 with 스프링부트 API서버
섹션 3. 리액트와 API서버 통신 - 목록처리(1) 학습중인데요. serverData를 console.log로 찍어보면 current가 항상 0입니다. 어디서 확인해야할까요?
미해결
코드로 배우는 React 19 with 스프링부트 API서버
productRepository.selectList 호출시 이미지 리스트를 List객체로 반환되는 방법을 알고 싶습니다. 아래의 코드를 보면 이미지리스트는 한개(pi.ord=0)만 가져오는데요. imageList의 모든값이 List객체에 담겨 Page<Object[]>에 포함되는 방법을 알고 싶습니다. Page<Object[]> result = productRepository.selectList(pageable); @Query("select p, pi from Product p left join p.imageList pi where pi.ord = 0 and p.delFlag = false") Page<Object[]> selectList(Pageable pageable);
미해결
[코드팩토리] [초급] Flutter 3.0 앱 개발 - 10개의 프로젝트로 오늘 초보 탈출!
웹뷰 앱 만드는 부분 진행중입니다. HomeScreen 클래스 안에 homeUrl을 선언하면, ..loadRequest(homeurl) 부분에 인스턴스 멤버는 생성자?(initializer)안에 can't be accessed 라고 오류가 뜨는데, chatgpt랑 계속 대답을 주고 받았는데 제가 이해를 못해서 그런건지 안 와닿아서요.. HomeScreen 위젯을 생성할 때, 위에서부터 코드가 실행되니까 homeUrl이 먼저 초기화되서 될 것 같은데 왜 오류가 나나요? ㅠㅠ
미해결
Flutter 중급 2편 - 실전 앱 개발 - 미국 주식 앱 (with 클린 아키텍처)
class StoreViewModel with ChangeNotifier { String? regionName = ''; String barName = '지역별 서점'; bool isLoading = false; final StoreRepository repository; StoreViewModel(this.repository) { print('생성자호출'); _loadSimpleStores(); print(stores); } List<SimpleStore> stores = []; void onEvent(StoreEvent event, BuildContext context) { event.when(touchTile: (id) async { StoreInfo store = await repository.getStoreInfo(id); Navigator.push( context, MaterialPageRoute( builder: (context) => StoreDetailScreen(storeDetail: store)), ); }, searchStore: (query) async { }); } //지역 전체 Future<void> _loadSimpleStores() async { isLoading = true; notifyListeners(); stores = await repository.getStores(); isLoading = false; notifyListeners(); } } --------------------------------------------- class StoreViewScreen extends StatefulWidget { StoreViewScreen({ super.key, this.barName, this.regionName, }); String? barName; String? regionName; @override State<StoreViewScreen> createState() => _StoreViewScreenState(); } class _StoreViewScreenState extends State<StoreViewScreen> { TextEditingController _controller = TextEditingController(); @override Widget build(BuildContext context) { final customerInfoViewModel = context.watch<CustomerInfoViewModel>(); final storeViewModel = context.watch<StoreViewModel>(); return Scaffold( appBar: AppBar( centerTitle: true, title: Text( storeViewModel.barName, style: TextStyle( fontWeight: FontWeight.bold, ), ), leading: IconButton( onPressed: () { Navigator.pop(context); }, icon: Icon(Icons.close), ), ), body: Column(children: [ //입력창 + 검색창 Container( child: Row( children: [ Expanded( child: Container( decoration: BoxDecoration( border: Border.all(color: Colors.grey), // 테두리 색상 설정 borderRadius: BorderRadius.circular(8.0), // 테두리 둥글기 설정 ), child: TextField( controller: _controller, decoration: InputDecoration( hintText: '텍스트를 입력하세요.', // 힌트 텍스트 contentPadding: EdgeInsets.all(12.0), // 텍스트 입력 필드 내부의 여백 설정 border: InputBorder.none, // 기본 테두리 제거 ), ), ), ), TextButton(onPressed: () {}, child: Text('검색')) ], ), ), //지역 이름 or 내주변 Container( child: Row( children: [ Text( storeViewModel.regionName ?? '내 주변', style: TextStyle( fontSize: customerInfoViewModel.screenHeight / 20, fontWeight: FontWeight.bold), ), Text( '${storeViewModel.stores.length}가 검색 됨', style: TextStyle( fontSize: customerInfoViewModel.screenWidth / 20, fontWeight: FontWeight.bold), ), ], )), //서점 리스트 표시 Expanded( child: Container( child: !storeViewModel.isLoading ? ListView.builder( itemCount: storeViewModel.stores.length, itemBuilder: (BuildContext context, int index) { return GestureDetector( child: StoreSimpleInfo( id: storeViewModel.stores[index].id, profileUrl: storeViewModel.stores[index].imageUrl, storeName: storeViewModel.stores[index].name, storeAddr: storeViewModel.stores[index].address, category: storeViewModel.stores[index].category), onTap: () { storeViewModel.onEvent( StoreEvent.touchTile( storeViewModel.stores[index].id, ), context, ); }, ); }, ) : CircularProgressIndicator(), ), ), ]), ); } } 스크린을 열면 viewmodel 생성자로 리스트를 불러오고 싶은데 viewmodel 생성자가 작동을 안합니다 이유가 뭘까요 ㅠㅠ? 의존성주입 문제는 아닌것같아요
미해결
[코드팩토리] [초급] Flutter 3.0 앱 개발 - 10개의 프로젝트로 오늘 초보 탈출!
비디오 플레이어 만들기에서요 Setstate를 쓰지 않고요!!! 멈추고 시작하는 부분에서 시작중인가 그럼 멈춰라 멈추었나 그럼 시작해라. 이런 코드를 넣잖아요 그래서 아이콘이 바뀌지는 않지만!! 누르면 멈추고 실행이 동작은 되는데 왜 Setstate를 넣지 않으면 아이콘이 바뀌지않는건 당연하다 생각하는데. 멈추고 실행하는 동작도 안되야 하지 않나 싶어서요 이런 동작을 안할 거 같은데 말이죠…,,
해결됨
실무에 바로 적용하는 프런트엔드 테스트 - 1부. 테스트 기초: 단위・통합 테스트
mocking과 spy함수가 조금 헷갈립니다. 아래와 같이 정리하면 될까요? - spy 함수 : 빈 함수인데, vitest에서 이 함수를 감지하고 있고 함수가 call 되었는지, 인자는 무엇이었는지 검증하는 가짜 함수. - mocking : 종속성이 있는 라이브러리를 복사해두고, 그 중 사용해야 할 함수나 기능을 spy 함수로 대체하여 call 했는지 검사할 수 있는 프로세스. 그러면 mocking 자체는 spy 함수 없이 사용하는 것은 의미가 없다고 보면 될까요?
미해결
[코드팩토리] [초급] Flutter 3.0 앱 개발 - 10개의 프로젝트로 오늘 초보 탈출!
double.infinity를 써야 할지 MediaQuery. of (context).size.width를 써야 할지 헷갈리는데 어떤 걸 써야 하나요?
해결됨
[코드팩토리] [초급] Flutter 3.0 앱 개발 - 10개의 프로젝트로 오늘 초보 탈출!
flutter pub run build_runner build 터미널에서 실행 터미널창 내용 PS E:\_flutter\section24_calendar> flutter pub run build_runner build Deprecated. Use `dart run` instead. Building package executable... (6.4s) Built build_runner:build_runner. [INFO] Generating build script completed, took 352ms [INFO] Precompiling build script... completed, took 7.4s [INFO] Building new asset graph completed, took 994ms [INFO] Checking for unexpected pre-existing outputs. completed, took 1ms [INFO] Generating SDK summary completed, took 4.2s [WARNING] drift_dev on lib/database/drift_database.dart: Could not resolve Dart library package:section24_calendar/database/drift_database.dart This builder requires Dart inputs without syntax errors. However, package:section24_calendar/database/drift_database.dart (or an existing part) contains the following errors. drift_database.dart:24:1: A function body must be provided. Try fixing the errors and re-running the build. [WARNING] drift_dev on lib/database/drift_database.dart: Could not resolve Dart library package:section24_calendar/database/drift_database.dart This builder requires Dart inputs without syntax errors. However, package:section24_calendar/database/drift_database.dart (or an existing part) contains the following errors. drift_database.dart:24:1: A function body must be provided. Try fixing the errors and re-running the build. [INFO] Running build completed, took 14.4s [INFO] Caching finalized dependency graph completed, took 75ms [INFO] Succeeded after 14.5s with 68 outputs (158 actions) PS E:\_flutter\section24_calendar> [INFO] Succeeded after 14.5s with 68 outputs (158 actions) 라고 68개 생긴다고 나오는데 마우스 우클릭 해도 파일은 안생김 검색해보니 flutter pub add --dev drift_dev flutter pub run build_runner clean flutter pub run build_runner build --delete-conflicting-outputs 각각 해봐도 안생기네요 flutter pub add --dev drift_dev 해봄 PS E:\_flutter\section24_calendar> flutter pub add --dev drift_dev "drift_dev" is already in "dev_dependencies". Will try to update the constraint. Resolving dependencies... _fe_analyzer_shared 64.0.0 (67.0.0 available) analyzer 6.2.0 (6.4.1 available) ffi 2.1.0 (2.1.2 available) flutter_lints 2.0.3 (3.0.1 available) intl 0.18.1 (0.19.0 available) js 0.6.7 (0.7.0 available) lints 2.1.1 (3.0.0 available) matcher 0.12.16 (0.12.16+1 available) material_color_utilities 0.5.0 (0.8.0 available) meta 1.10.0 (1.12.0 available) ! path 1.9.0 (overridden) test_api 0.6.1 (0.7.0 available) web 0.3.0 (0.4.2 available) web_socket_channel 2.4.0 (2.4.3 available) Got dependencies! 13 packages have newer versions incompatible with dependency constraints. Try `flutter pub outdated` for more information. PS E:\_flutter\section24_calendar> flutter pub run build_runner clean 해봄 PS E:\_flutter\section24_calendar> flutter pub run build_runner clean Deprecated. Use `dart run` instead. Building package executable... (6.3s) Built build_runner:build_runner. [WARNING] Deleting cache and generated source files. This shouldn't be necessary for most applications, unless you have made intentional edits to generated files (i.e. for testing). Consider filing a bug at https://github.com /dart-lang/build/issues/new if you are using this to work around an apparent (and reproducible) bug. [WARNING] No asset graph found. Skipping cleanup of generated files in source directories. [INFO] Cleaning up source outputs completed, took 1ms [INFO] Cleaning up cache directory completed, took 37ms PS E:\_flutter\section24_calendar> flutter pub run build_runner build --delete-conflicting-outputs 해봄 PS E:\_flutter\section24_calendar> flutter pub run build_runner build --delete-conflicting-outputs Deprecated. Use `dart run` instead. [INFO] Generating build script completed, took 335ms [INFO] Reading cached asset graph completed, took 100ms [INFO] Checking for updates since last build completed, took 911ms [INFO] Running build completed, took 17ms [INFO] Caching finalized dependency graph completed, took 78ms [INFO] Succeeded after 102ms with 0 outputs (0 actions) PS E:\_flutter\section24_calendar> 어찌 해야 조을까요
미해결
Next + React Query로 SNS 서비스 만들기
아이디, 비밀번호를 입력하고 로그인 버튼을 누르면 500에러가 발생합니다. 9090 서버 포트는 잘 켜져있다고 뜨고, 코드 올리겠습니다. <auth.ts> import NextAuth from "next-auth"; import CredentialsProvider from "next-auth/providers/credentials"; import KakaoProvider from "next-auth/providers/kakao"; export const { handlers: { GET, POST }, auth, signIn, } = NextAuth({ pages: { signIn: "/i/flow/login", newUser: "i/flow/signup", }, providers: [ CredentialsProvider({ async authorize(credentials) { // credentials 안에 id창에서 입력하는 정보다 담겨있음 const authResponse = await fetch(`${process.env.AUTH_URL}/api/login`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ id: credentials.username, password: credentials.password, //next-auth의 credentials에는 username, password로 고정되어 있어서 이를 바꿔줌 }), }); //로그인 실패시 if (!authResponse.ok) { return null; } const user = await authResponse.json(); return user; }, }), //kakao로그인을 사용할때 // KakaoProvider(), ], }); <LoginModal.tsx> "use client"; import style from "@/app/(beforeLogin)/_component/login.module.css"; import { signIn } from "next-auth/react"; import { useRouter } from "next/navigation"; import { ChangeEventHandler, FormEventHandler, useState } from "react"; export default function LoginModal() { const [id, setId] = useState(""); const [password, setPassword] = useState(""); const [message, setMessage] = useState(""); const router = useRouter(); const onSubmit: FormEventHandler<HTMLFormElement> = async (e) => { e.preventDefault(); setMessage(""); try { await signIn("credentials", { username: id, password, redirect: false, }); //kakao, naver로 바꿀 수 있음 //client 일때는 next-auth/react의 signIn을 사용 //server 일때는 @/auth의 signIn을 사용 router.replace("/home"); } catch (error) { console.log(error); setMessage("아이디와 비밀번호가 일치하지 않습니다."); } }; const onClickClose = () => { router.back(); }; const onChangeId: ChangeEventHandler<HTMLInputElement> = (e) => { setId(e.target.value); }; const onChangePassword: ChangeEventHandler<HTMLInputElement> = (e) => { setPassword(e.target.value); }; return ( <div className={style.modalBackground}> <div className={style.modal}> <div className={style.modalHeader}> <button className={style.closeButton} onClick={onClickClose}> <svg width={24} viewBox="0 0 24 24" aria-hidden="true" className="r-18jsvk2 r-4qtqp9 r-yyyyoo r-z80fyv r-dnmrzs r-bnwqim r-1plcrui r-lrvibr r-19wmn03" > <g> <path d="M10.59 12L4.54 5.96l1.42-1.42L12 10.59l6.04-6.05 1.42 1.42L13.41 12l6.05 6.04-1.42 1.42L12 13.41l-6.04 6.05-1.42-1.42L10.59 12z"></path> </g> </svg> </button> <div>로그인하세요.</div> </div> <form onSubmit={onSubmit}> <div className={style.modalBody}> <div className={style.inputDiv}> <label className={style.inputLabel} htmlFor="id"> 아이디 </label> <input id="id" className={style.input} value={id} onChange={onChangeId} type="text" placeholder="" /> </div> <div className={style.inputDiv}> <label className={style.inputLabel} htmlFor="password"> 비밀번호 </label> <input id="password" className={style.input} value={password} onChange={onChangePassword} type="password" placeholder="" /> </div> </div> <div className={style.message}>{message}</div> <div className={style.modalFooter}> <button className={style.actionButton} disabled={!id && !password}> 로그인하기 </button> </div> </form> </div> </div> ); } <middleware.ts> export { auth as middleware } from "./auth"; export const config = { matcher: ["/compose/tweet", "/home", "/explore", "/messages", "/search"], }; <route.ts> export { GET, POST } from "@/auth"; 에러 내용 : TypeError: next_dist_server_web_exports_next_request__WEBPACK_IMPORTED_MODULE_0__ is not a constructor at reqWithEnvURL (webpack-internal:///(rsc)/./node_modules/next-auth/lib/env.js:15:12) at httpHandler (webpack-internal:///(rsc)/./node_modules/next-auth/index.js:139:139) at /Users/imhwarang/projects/zerocho/z-com/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:63815 at /Users/imhwarang/projects/zerocho/z-com/node_modules/next/dist/server/lib/trace/tracer.js:133:36 at NoopContextManager.with (/Users/imhwarang/projects/zerocho/z-com/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7062) 너무 길어서 다 올릴수는 없네요 에러내용을
미해결
Next + React Query로 SNS 서비스 만들기
안녕하세요. 디렉토리 구조를 afterlogin과 beforelogin구조로 나누어서 로그인을 분기치고 있고 auth.ts에서 서버로 부터 전달받은 토근값을 넣고 미들웨어에서 세션을 유무를 확인하여 login페이지로 리다이렉트 시키고 있습니다. afterlogin과 beforelogin으로 디렉토리가 어떤방식으로 나뉘는지 로직이 궁금합니다. 관련된 훅이 있는것인지?? 2. 실제 상용화된 서비스라고하면 로그인이 풀리는것을 방지하기 위해 BE로 토근값을 요청할텐데, 관련 로직은 어떤방식으로 구현하는게 좋은방법인지 요청드립니다.
해결됨
5분빨리 퇴근하자! 파이썬 데이터 분석, 시각화, 웹 대시보드 제작하기
버튼과 체크박스 모두 조건문을 사용할 때는 바로 아래에 텍스트가 출력되는데, 함수를 사용하면 대시보드 맨 위에 텍스트가 호출되는 것은 왜 그런건가요?(맨 위에 텍스트가 호출되어 출력된 부분이 전부 다 한 칸 씩 밀리게 됨)
미해결
[코드팩토리] [중급] Flutter 진짜 실전! 상태관리, 캐시관리, Code Generation, GoRouter, 인증로직 등 중수가 되기 위한 필수 스킬들!
https://riverpod.dev/ko/docs/migration/from_state_notifier riverpod 2 공식문서에 보면 Notifier/ AsyncNotifer 가 새롭게 도입되면서 StateNotifier는 더이상 사용되지 않는다고 나오는데 새로운 방식 강의 업데이트 안 해주시나요...?
해결됨
Flutter 중급 3편 - 의존성 주입 가이드
안녕하세요. 강의 잘 보고 있습니다. remote data source impl 관련해서 질문이 있습니다. @prod @Singleton(as: CommunityRemoteDataSource) class CommunityRemoteDataSourceApiImpl implements CommunityRemoteDataSource { final _dio = Session().dio; @override Future<CommunityResponseDTO> fetchCommunities() async { Response<dynamic> response = await _dio.get('get/community/path'); final responseDto = CommunityResponseDTO.fromJson(response.data); return responseDto; } } CommunityRemoteDataSource 의 구현체 CommunityRemoteDataSourceApiImpl 를 만들어서 사용중입니다. ApiImpl 은 실제 서버와 통신중 이며, http 라이브러리 Dio를 사용하고 있습니다. 여기서 테스트를 위해 DioMock 객체를 만들어서 사용하고자 합니다. 원래 CommunityRemoteDataSourceApiImpl 에 final _dio = Session().dio; 로 싱글턴으로 dio를 내부에 객체를 생성하고 있는데 이거를 주입받는 식으로 변경하여 테스트 시만 CommunityRemoteDataSourceApiImpl(DioMock()) 을 넣는 것인지, 아니면 CommunityRemoteDataSourceApiMockImpl 를 새로 또 만드는지 궁금합니다. 만약 CommunityRemoteDataSourceApiImpl(DioMock()) 로 주입을 받는 식이라면 Response<dynamic> response = await _dio.get('get/community/path'); final responseDto = CommunityResponseDTO.fromJson(response.data); 해당 코드들이 Dio() 일 때, DioMock() 일 때 달라야 할 것 같은데 어떻게 처리하는 것이 맞는지 궁금합니다. 감사합니다.
해결됨
Flutter로 SNS 앱 만들기
안녕하세요 댓글 입력 후 메인 화면 코멘트카운트가 업데이트 되지 않고 있습니다. CommentScreen에 callback 멤버 추가해서 하면 될것 같은데. 잘안되네요.. 도움 부탁드리겠습니다.
미해결
처음하는 플러터(Flutter) 기초부터 실전까지 [풀스택 Part4] (쉽고 견고하게 단계별로 다양한 프로젝트까지)
플러터 강의를 들으려고 하는데 로드맵대로 하지않고 바로 플러터를 들어도되나요? 플러터만 익히고싶고 파이썬부터 듣고싶진않아서요
해결됨
Flutter로 SNS 앱 만들기
가입완료 메세지표시와 입력항목 비활성화에서 메세지가 안나와요.
미해결
Next + React Query로 SNS 서비스 만들기
비번 확실히 틀리지 않았는데 계속 오류 뜨길래, 완전 삭제후 다시 설치해서 비번 쉬운걸로 다시 설정하고 입력해도 계속 비번오류 뜹니다.
미해결
Flutter 중급 1편 - 클린 아키텍처
import 'package:freezed_annotation/freezed_annotation.dart'; part 'photo.freezed.dart'; part 'photo.g.dart'; @freezed class Photo with _$Photo { factory Photo({ required int id, required String tags, @JsonKey(name: 'previewURL') required String previewUrl, }) = _Photo; factory Photo.fromJson(Map<String, dynamic> json) => _$PhotoFromJson(json); }
해결됨
코딩테스트 [ ALL IN ONE ]
글에 두서가 없어도 양해 바랍니다 이 수업 수강 이전에 코딩 문제를 풀 때 파이썬으로 재귀함수를 사용했던 적이 있습니다. 그때 알게 된것이 파이썬의 재귀함수에는 기본적으로 깊이의 제한이 있다는 것입니다. sys.recursionlimit()으로 확인해보니 재귀호출을 1000이상 못하도록 값이 제한되어 있고 이 값을 늘려서 사용하는것은 별로 추천되는 방법이 아닌걸로 알고 있습니다. C언어 사용할때에는 속도면에서 제한도 없고 파이썬보다 속도도 월등하다보니 재귀를 자주 사용했었는데 파이썬에서 재귀함수로 풀어야 하는 경우가 있을까요?