본문 바로가기

FLUTTER203

Flutter 플러터에서 열 너비 설정하기, Set column width in flutter 질문 I need to set a Column width in flutter, I have to do a layout with 3 sections, one should be 20% of the screen, the other one 60% and the last one 20%. I know that those 3 columns should be into a row, but I don't know a way to set the size, when I do that, the 3 columns take the same size. I will appreciate any feedback. 답변 크기를 하드 코딩하는 대신 Flex를 사용하는 것을 제안합니다. Row( children: [ Expanded( flex.. 2023. 6. 24.
Flutter 플러터 앱에 JSON 자산을 로드하는 방법은 무엇인가요?, How to load JSON assets into a Flutter App? 질문 내 Flutter 앱에 JSON 자산을로드하는 방법은 무엇입니까? 내 pubspec.yaml 파일은 다음과 같습니다: assets: - assets/data.json 데이터를로드하려고하면 항상 막힙니다. 시도해 봤습니다: final json = JSON.decode( DefaultAssetBundle.of(context).loadString("assets/data.json") ); 하지만 오류가 발생합니다: 인수 형식 'Future'은(는) 'String' 매개 변수 형식에 할당할 수 없습니다. 답변 다음을 시도해보세요 : String data = await DefaultAssetBundle.of(context).loadString("assets/data.json"); final j.. 2023. 6. 24.
Flutter 플러터에서 텍스트 위젯에 아이콘을 표시하는 방법은 무엇인가요?, How to show Icon in Text widget in flutter? 질문 나는 텍스트 위젯에서 아이콘을 보여주고 싶습니다. 어떻게 해야 할까요? 다음 코드는 IconData만 보여줍니다. Text("Click ${Icons.add} to add"); 답변 Flutter는 RichText() 내부에 위젯을 추가하기 위해 WidgetSpan()을 사용합니다. 예시: RichText( text: TextSpan( children: [ TextSpan( text: "Click ", ), WidgetSpan( child: Icon(Icons.add, size: 14), ), TextSpan( text: " to add", ), ], ), ) 위 코드는 다음과 같은 결과를 출력합니다: WidgetSpan의 자식 요소를 일반적인 위젯과 같이 다룰 수 있습니다. 2023. 6. 24.
Flutter FloatingActionButton의 크기를 변경하는 방법은 무엇인가요?, How to change the size of FloatingActionButton? 질문 저는 플러터에서 FloatingActionButton의 크기를 설정하려고 합니다. width/height를 설정하고 싶습니다. 즉, 버튼을 더 크게 만들고 싶습니다. 원형 버튼을 찾고 있었지만, 제가 찾은 것은 이것뿐이었습니다. 그래서 이것으로 작업을 시작했지만, 조금 더 큰 크기가 필요합니다. 답변 FittedBox를 사용하여 FAB를 Container 또는 SizedBox 안에 랩하고, 그 후에 너비와 높이를 변경하십시오. 예시: floatingActionButton: Container( height: 100.0, width: 100.0, child: FittedBox( child: FloatingActionButton(onPressed: () {}), ), ), 2023. 6. 24.