본문 바로가기

StatefulWidget10

Flutter 네트워크에서 이미지를 로드하는 더 좋은 방법은 플러터입니다., Better way to load images from network flutter 질문 네트워크에서 이미지를 로드하고 GridView에 표시하려고 합니다. StatefulWidget을 사용하고 이미지를 build 메서드 내에서 로드하고 있습니다. 그러나 내가 이해한 바에 따르면 build 메서드 내에서 네트워크 호출을 하는 것은 좋지 않다고 생각합니다. 어떻게하면 BLoC 파일 내에서 네트워크에서 이미지를 다운로드하고 나중에 다운로드한 이미지 목록을 위젯에 전달할 수 있을까요? 아래는 현재의 구현입니다. class MovieList extends StatefulWidget { @override State createState() { return MovieListState(); } } class MovieListState extends State { @override void initS.. 2024. 1. 3.
Flutter 플러터에서 왜 stateful 위젯은 두 개의 클래스로 정의되는 건가요?, Why are stateful widgets defined as two classes in flutter? 질문 나는 플러터/다트에 새로 왔으므로 앱을 만들려고 노력하는 동안 왜 일부 사항들이 특정한지 이해하려고 노력합니다. 플러터 문서에는 다음과 같이 상태를 가지는 위젯의 예제 코드가 있습니다: class YellowBird extends StatefulWidget { const YellowBird({ Key key }) : super(key: key); @override _YellowBirdState createState() => new _YellowBirdState(); } class _YellowBirdState extends State { @override Widget build(BuildContext context) { return new Container(color: const Color(0xFF.. 2023. 12. 18.
Flutter 플러터에서 DropdownButtons와 DropdownMenuItems를 어떻게 사용자 정의해야 하나요?, How should I customize DropdownButtons and DropdownMenuItems in Flutter? 질문 기본 DropdownButton은 DropdownMenuItems와 함께 연결되어 연한 회색 드롭다운을 반환합니다. 드롭다운을 어떻게 사용자 정의할 수 있을까요? (예: 배경색, 드롭다운 너비) DropdownButton과 DropdownMenuItem의 style 속성을 변경할 수 있습니다. 아래와 같이: return new DropdownButton( value: ..., items: ..., onChanged: ..., style: new TextStyle( color: Colors.white, ), ); 하지만 이렇게 해도 드롭다운의 배경색은 변경되지 않습니다. DropdownMenu를 복사하고 확장해야 할까요? Flutter는 가까운 미래에 이 위젯에 대한 사용자 정의 기능을 추가할 계획이.. 2023. 12. 15.
Flutter 다른 예외가 발생했습니다: 'MyApp' 타입은 'StatelessWidget' 타입의 하위 타입이 아닙니다., Another exception was thrown: type 'MyApp' is not a subtype of type 'StatelessWidget' 질문 나는 방금 Flutter를 사용하기 시작했고 코드를 실행하는 동안이 문제가 발생했습니다. "Another exception was thrown: type 'MyApp' is not a subtype of type 'StatelessWidget'"라는 오류가 발생합니다. 흥미로운 점은 내 코드에는 'StatelessWidget'조차도 없다는 것입니다. import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatefulWidget { @override State createState() { // TODO: implement createState return _MyAppState(); } }.. 2023. 9. 22.