본문 바로가기

Flutter/Flutter FAQ380

Flutter 플러터와 다트의 try-catch 구문에서 catch가 실행되지 않습니다., Flutter and Dart try catch—catch does not fire 질문 아래의 HTML을 한국어로 번역하되, HTML 태그와 태그 안의 텍스트는 영어로 유지해주세요. 주어진 단축 코드 예시: ... print("1 parsing stuff"); List subjectjson; try { subjectjson = json.decode(response.body); } on Exception catch (_) { print("throwing new error"); throw Exception("Error on server"); } print("2 parsing stuff"); ... catch 블록은 디코딩이 실패할 때마다 실행될 것으로 예상합니다. 그러나 잘못된 응답이 반환되면 터미널에는 예외가 표시되고 catch나 계속 진행하는 코드가 실행되지 않습니다... flutte.. 2023. 12. 18.
Flutter 플러터 '뒤로' 버튼과 반환 데이터, Flutter Back button with return data 질문 나는 두 개의 버튼이 있는 인터페이스를 가지고 있으며, 이 버튼들은 팝되고 true 또는 false를 반환합니다. 다음과 같이: onPressed: () => Navigator.pop(context, false) 나는 앱바의 뒤로 가기 버튼을 조정해야 하는데, 이 버튼은 팝되고 false를 반환해야 합니다. 이를 수행할 수 있는 방법이 있을까요? 답변 더 쉬운 방법은 WillPopScope로 body를 감싸는 것입니다. 이렇게 하면 위쪽의 뒤로 가기 버튼과 아래쪽의 Android 뒤로 가기 버튼 모두 작동합니다. 두 개의 뒤로 가기 버튼이 모두 false를 반환하는 예제입니다: final return = Navigator.of(context).push(MaterialPageRoute( builder.. 2023. 12. 18.
Flutter 미래 빌더에서 여러 가지 방법을 사용할 수 있을까요?, Can I use multiple method on a future builder? 질문 @override Widget build(BuildContext context) { widget.groupid; widget.event_id; var futureBuilder = new FutureBuilder( future: _getAllTickets(), builder: (BuildContext context, AsyncSnapshot snapshot) { print(snapshot.connectionState); switch (snapshot.connectionState) { case ConnectionState.none: case ConnectionState.waiting: return new Text('...'); default: if (snapshot.hasError) return new.. 2023. 12. 18.
Flutter 플러터에서 둥근 모서리가 있는 캐시 이미지를 생성하세요., Create rounded cached image in Flutter 질문 네트워크에서 이미지를 가져오고 Flutter에서 캐시된 원형 이미지를 만들고 싶습니다. 네트워크에서 가져온 원형 이미지를 캐시하지 않는 코드를 찾았습니다. new Container( width:80.0, height: 80.0, decoration: new BoxDecoration( shape: BoxShape.circle, image: new DecorationImage( image: new NetworkImage('https://pbs.twimg.com/profile_images/945853318273761280/0U40alJG_400x400.jpg'), ), ), ), 이제 네트워크에서 이미지를 가져오고 캐시하고 표시하는 위젯을 찾았습니다. new CachedNetworkImage(imageU.. 2023. 12. 18.