본문 바로가기

FLUTTER203

Flutter 비동기 간격을 건너서 BuildContext를 사용하지 마십시오., Do not use BuildContexts across async gaps 질문 내 프로젝트에서 새로운 린트 이슈를 발견했습니다. 간단히 말해서: 내 커스텀 클래스에서 BuildContext를 사용해야 합니다. aysnc 메서드와 함께 사용할 때 flutter 린트 도구가 행복하지 않습니다. 예시: MyCustomClass{ final buildContext context; const MyCustomClass({required this.context}); myAsyncMethod() async { await someFuture(); # if (!mounted) return; _MyWidgetState(); } class _MyWidgetState extends State { @override Widget build(BuildContext context) { return Icon.. 2023. 5. 31.
Flutter 변수를 매개변수로 사용하여 잘못된 상수 값입니다., Invalid Constant Value using variable as parameter 질문 변수 textSize = 10.0; // 또는 double textSize = 10.0; Flutter의 Text 위젯으로 변환 child: const Text('Calculate Client Fees', style: TextStyle(fontSize: textSize),) 여기서 오류가 발생합니다. 유효하지 않은 상수 값 반드시 const 값을 사용해야합니까? 왜 var 또는 double을 사용할 수 없습니까? 답변 당신은 Text 위젯을 const로 선언하고 있으며, 이는 그것의 모든 자식들이 const여야 한다는 것을 요구합니다. 이를 수정하려면, 이 경우에는 const Text 위젯을 사용하지 않아야 합니다. 왜냐하면 비-const 변수를 전달하려고 하기 때문입니다. Flutter는 cons.. 2023. 5. 31.
Flutter에서 borderRadius가 있는 Container에 테두리 추가하기, Add border to a Container with borderRadius in Flutter 질문 Container( child: Text( 'This is a Container', textScaleFactor: 2, style: TextStyle(color: Colors.black), ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Colors.white, border: Border( left: BorderSide( color: Colors.green, width: 3, ), ), ), height: 50, ), 이것은 녹색 왼쪽 테두리가 있는 둥근 모서리 컨테이너와 "This is a Container"라는 자식 텍스트를 표시해야하지만, 둥근 모서리 컨테이너와 자식 및 왼쪽 테두리가 보이지 않습니다. .. 2023. 5. 31.
Flutter 소켓 예외 해결 방법: 호스트 조회 실패 : 'www.xyz.com' (OS 오류 : 호스트 이름과 연관된 주소 없음, errno = 7), How to solve SocketException: Failed host lookup: 'www.xyz.com' (OS Error: No address associated with host.. 질문 20초 후에 http 호출을 시도하면 콘솔에서 다음 오류가 발생합니다: E/flutter (8274): [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception: E/flutter (8274): SocketException: Failed host lookup: 'flutter-project-xxxxx.firebaseio.com' (OS Error: No address associated with hostname, errno = 7) 이 오류는 앱 http 패키지를 통해 호출하는 모든 메서드 및 모든 경로에서 발생합니다. 저는 안드로이드 스튜디오의 AVD 가상 장치를 사용하여 Windows에서 플러터 앱을 개발하고 있습니다... 2023. 5. 31.