[코드팩토리] [중급] Flutter 진짜 실전! 상태관리, 캐시관리, Code Generation, GoRouter, 인증로직 등 중수가 되기 위한 필수 스킬들!
안녕하세요! 현재 설치한 go_router는 13.2.4 버전입니다. routerProvider에서 만들어주는 GoRotuer의 redirect에 authProvider에 있는 redirectLogic(GoRouterState state)함수는 파람은로 GoRouterState 를 받기로 되어 있지 않나요? 그래서 저는 아래처럼 routerProvider에서 만들어주는 GoRotuer의 redirect에 redirectLogic(state)를 넘겨줘야 에러가 없던데 강의에서는 어떻게 그냥 되셨을까요...? 아래는 강의 스크린샷입니다. 궁금해서 여쭤봅니당
[코드팩토리] [중급] Flutter 진짜 실전! 상태관리, 캐시관리, Code Generation, GoRouter, 인증로직 등 중수가 되기 위한 필수 스킬들!
안녕하세요 강사님, 잘 수강 중에 질문이 있습니다. retrofit이 만들어내는 restaurant_repository.g.dart 에서 getRestaurantDetail 함수 리턴쪽에 보시면, final value = RestaurantDetailModel.fromJson(_result.data!); 와 같이 되어 있는 것을 확인할 수 있습니다. 근데 백단에서 보통 data만 던지지 않고 응답코드, 메시지 등 정형화된 포맷으로 줄 수 있다고 생각이 듭니다. 예를 들어, 아래와 같이, { "code": 200, "message": "~", "result": { ~ } } 온다면, 혹시 _ result.data !.['result'] 와 같이 생성이 될 수 있도록 커스터마이징 할 수 있을까요?
안녕하세요! socket관련한 서비스를 진행해보고 싶어서 제로초님의 강의를 들은 수강생입니다. 현재 nest & flutter를 이용하고 있는데, flutter에서의 연결 및 다른 tool에서 socket io 연결이 되지 않으며 “외부 사이트로는 접근이 불가능한 오류” 가 생겨서 조심스럽게 여쭤봅니다. 현재 로직은 채팅을 생성시, 채팅을 보여주는 리스트가 실시간으로 새로고침이 되는 부분을 작업중입니다. 하지만, postman, httpie, hoppscotch의 부분에서 연결이 되지 않는 문제가 발생합니다. 많은 방법을 찾아봤지만, 터미널에서 socket io cli를 통해서 로그는 볼 수 있지만, 다른 tool에서는 이용이 불가능한 방법에 대해서 알고 싶어서 질문드립니다! Socket io를 통해서 local, dev서버 연결 완료 하지만 postman의 socket io기능을 통해서 테스트를 진행하려고 할 때, postman으로 연결 local에서는 문제가 없이 연길이 되지만, dev서버에서는 이러한 에러가 발생합니다. 또한 flutter 앱에서 연결을 하려면 다음과 같은 에러가 발생합니다. 오류 메시지 "WebSocketException: Connection to ' http://~~~~.com:81/socket.io/?EIO=4&transport=websocket# ' was not upgraded to websocket"는 클라이언트가 WebSocket 연결을 시도하였으나, 서버가 해당 연결을 WebSocket 프로토콜로 업그레이드하지 않았다는 것을 의미합니다. 이는 여러 가지 원인에 의해 발생할 수 있습니다: upgrade가 되지 않았다고 나와서 ,ngnix의 socket 부분에서 upgrade부분도 잘 넣어줬는데, 오류가 해결되지 않아서... 고민 끝에 질문 올립니다. Ngnix 설정부터 2주정도 시간을 들였지만, 해결이 되지 않아서…여쭤봅니다. 방화벽도 해제가 되어 있는데 연결이 안되고 있습니다.. 다음은 nest에서 작성한 코드 입니다! [chat.gateway.ts] import { WebSocketGateway, WebSocketServer, SubscribeMessage, OnGatewayConnection, OnGatewayDisconnect, OnGatewayInit, ConnectedSocket, MessageBody, } from '@nestjs/websockets'; import { Server, Socket } from 'socket.io'; @WebSocketGateway() export class ChatGateway implements OnGatewayInit, OnGatewayConnection, OnGatewayDisconnect { @WebSocketServer() server: Server; afterInit(server: Server) { console.log('WebSocket initialized'); } handleConnection(client: Socket) { console.log(`Client connected: ${client.id}`); // 수정: client 객체 직접 출력 대신 id 출력 } handleDisconnect(client: Socket) { console.log(`Client disconnected: ${client.id}`); } @SubscribeMessage('sendMessage') handleMessage( @ConnectedSocket() client: Socket, @MessageBody() data: { message: string } ): void { console.log(`Received message from ${client.id}: ${data.message}`); this.server.emit('newMessage', data); // 모든 클라이언트에게 메시지 전송 console.log(`Received message: ${data.message}`); } } [main.ts] import { ConfigService } from '@nestjs/config'; import { NestFactory } from '@nestjs/core'; import { NestExpressApplication } from '@nestjs/platform-express'; import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; import { join } from 'path'; import { AppModule } from './app.module'; import { HttpExceptionFilter } from './common/exceptions/http-exception.filter'; import { SuccessInterceptor } from './common/interceptors/success.interceptor'; import { IoAdapter } from '@nestjs/platform-socket.io'; import { CustomIoAdapter } from './adapters/custom-io.adapter'; async function bootstrap() { const app = await NestFactory.create<NestExpressApplication>(AppModule); app.useWebSocketAdapter(new CustomIoAdapter(app)); const configService = app.get(ConfigService); const port = configService.get('server.port'); const mongoUrl = configService.get('DB.MONGO_URL'); console.log('MongoDB URL:', mongoUrl); app.enableCors({ origin: true, credentials: true, }); app.useStaticAssets(join(__dirname, '..', 'client'), { prefix: '/api/v1/client', }); app.useGlobalInterceptors(new SuccessInterceptor()); app.useGlobalFilters(new HttpExceptionFilter()); app.setGlobalPrefix('api/v1'); const swagger_options = new DocumentBuilder() .setTitle('Nyam-Docs') .setDescription('API description') .setVersion('2.0.1') .addApiKey( { type: 'apiKey', name: 'x-token', in: 'header', description: 'Enter token', }, 'x-token', ) .addApiKey( { type: 'apiKey', name: 'x-type', in: 'header', description: 'Enter type', }, 'x-type', ) .build(); const document = SwaggerModule.createDocument(app, swagger_options); SwaggerModule.setup('api-docs', app, document); await app.listen(port, '0.0.0.0'); console.log(`Application Listening on Port : ${port}`); } bootstrap(); 다음은 custom한 io입니다 [custom.io.adpter.ts] import { IoAdapter } from '@nestjs/platform-socket.io'; import { INestApplication, Injectable } from '@nestjs/common'; import { ServerOptions } from 'socket.io'; @Injectable() export class CustomIoAdapter extends IoAdapter { constructor(app: INestApplication) { super(app); } createIOServer(port: number, options?: ServerOptions): any { const serverOptions: ServerOptions = { ...options, cors: { origin: '*', // 모든 도메인에서 접근 허용 methods: ['GET', 'POST', 'PUT', 'DELETE'], credentials: true }, transports: ['websocket', 'polling'], //pooling 없으면 연결 안 됨(socket) allowEIO3: true // Engine.IO 3.x 버전 클라이언트 허용 }; return super.createIOServer(port, serverOptions); } } 혹시 해결방법을 아시거나, 도움을 주실만한 정보가 있으시다면 알려주시면 정말 감사하겠습니다!
안녕하세요! Post데이터를 가져올때 DocumentReference로 가져오는경우와 Document로 가져오는경우에는 어떤 차이가 있나요? Document로 가져오는경우에 Toggle Value에 값을 설정할 수 없는 문제가 있더라구요.. 공식문서를 뒤져봐도 잘 알 수 없어서 질문 남겨 놓습니다. 감사합니다.
[코드팩토리] [중급] Flutter 진짜 실전! 상태관리, 캐시관리, Code Generation, GoRouter, 인증로직 등 중수가 되기 위한 필수 스킬들!
안녕하세요. 코드팩토리님. 강의를 참고하여 한가지 기능을 만들어보고자 했습니다. 현재까지 데이터모델을 생성하고, 데이터모델 타입으로 된 리스트들을 저장하는 프로바이더를 생성하여 read로 리스트를 추가 및 삭제하며, watch를 통해 목록을 보도록 하였습니다. 그런데 제가 추가하고자 하는 기능 중, consumerWidget과 같은 위젯을 사용하지 않고 때에 따라 함수를 부를 때에 함수 내부에서 프로바이더에 저장된 데이터목록을 불러와야 하는 상황이 되었고, 코드를 작성해보았는데 역시나 위젯이 아닌 함수에서 호출을 하려니 watch, read등 작동하지 않는 문제가 발생하였습니다. void scheduleAlarmFishs() async { //ref로 데이터 가져오기. final container = ProviderContainer(); final fishs = container.read(fishListProvider); // read 사용 print('Retrieved ${fishs.length}'); } 혹시 이런식으로 함수를 통한 접근은 아예 불가능한 건가요?ㅠㅠ
안녕하세요. 강의 잘 듣고 있습니다. 설정 잘 따라한 것 같은데 개발자 모드에서 아래와 같은 에러가 발생하면서 기본 이메일 로그인이 안 되네요. index.ts:152 POST https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=AIzaSyCK0XNd-BenICDlTBtp4tmPTugBWU9p0lQ 400 (Bad Request) 이런 경우에는 어떻게 해야 하나요...?
[코드팩토리] [초급] Flutter 3.0 앱 개발 - 10개의 프로젝트로 오늘 초보 탈출!
Calendar Scheduler 앱의 TextField 마무리 하기 편 Widget renderTextField 안에서 isTime을 이용해 내용 부분을 최대로 늘려준 부분이 잘 이해가 가지 않아 질문드립니다. isTime은 키보드 타입을 결정하기 위해 bool 타입으로 선언한 것과 true/false 로 타입 지정한 것까지는 이해가 갔는데, isTime 값으로 어떻게 expands 값을 결정하였는지 잘 모르겠습니다,, 그래서 expands 값에서 !isTime 대신 bool 타입으로 각각 false와 true를 넣어줬는데, false로 선언 시에는 내용 부분이 한 줄만 차지 하였는데, true로 선언하였더니 갑자기 오류가 났습니다. (minLines and maxLines must be null when expands is true.) isTime 값은 어떻게 결정되는지, 그리고 expands : true 를 넣으면 왜 오류가 뜨는지 궁금합니다.
[코드팩토리] [초급] Flutter 3.0 앱 개발 - 10개의 프로젝트로 오늘 초보 탈출!
안녕하세요. 에뮬레이터 세팅하는 과정에서 문제가 있어서 문의드립니다. 최대한 혼자 해보려고 해봤는데 잘 안되네요 wisdows 환경입니다. 여러 번 재설치도 해봤음에도 동일한 오류가 뜹니다. 오류메세지에 특별히 의미있는 내용은 없는 것 같아서... 우선 오류는 다음과 같이 발생합니다. Settings에서 플랫폼과 툴 설치한 내역입니다. 이외, 다른 설정들은 강의에 나온 설정과 동일하게 진행했습니다. HAXM의 경우, 인텔 지원 종료라고 하여 지우고도 진행해봤음에도 오류는 동일하긴 했습니다. 아래와 같이 cmd에서 직접 실행하는 경우는, 정상적으로 에뮬레이션 실행되는 것으로 보아, 안드로이드 스튜디오 설정 문제인 것으로 보이긴 하는데, 앱 개발 초보자인 상황에서 강의 촬영 시점과 달라서 버전이 조금 차이가 있다보니 환경설정에 어려움을 겪고 있어서 문의 납깁니다...
AuthState에 이렇게 문제가 생기고 The name 'AuthState' isn't a type, so it can't be used as a type argument. (Documentation) Try correcting the name to an existing type, or defining a type named 'AuthState'. 라고 뜹니다 어떻게 해결해야할지 모르겠어요