-
Flutter_20230414_01. Flutter> Frontend/Flutter 2023. 4. 14. 20:47
1. Review.
-Task: From Parent add 2 colors to gradient_container.dart
- 기존 부모에서 넘겨주는 부분과 Child Constructor 수정:
body: const GradientContainer("Hello World", Color.fromARGB(255, 4, 2, 80), Color.fromARGB(255, 45, 7, 98))
const GradientContainer(this.text, this.color1, this.color2, {super.key});
- 이때, 기존에 사용하던 BoxDecoration의 const 를 삭제해야한다. 이유는, Color가 list형태인데, list 는 변화될 수 있기 떄문.
decoration: BoxDecoration( gradient: LinearGradient( colors: [color1, color2], begin: startAlignment, end: endAlignment, )),
2. Implement Images on Flutter.
- 상위 폴더에서 assets/images 파일을 넣고, libs내 pubspec.yaml파일내, assets: 주석을 해제
- 아래와 같이 - assets/images/파일명.확장자 를 삽입
assets: - assets/images/dice-1.png - assets/images/dice-2.png - assets/images/dice-3.png - assets/images/dice-4.png - assets/images/dice-5.png - assets/images/dice-6.png
- 사용할 곳에서 아래와 같이 Images.asset으로 이미지 넣어준다. (Images.asset은 생성자.)
child: Image.asset('assets/images/dice-2.png'), // way to add images
'> Frontend > Flutter' 카테고리의 다른 글
Flutter_05. If-Statement & 퀴즈 데이터 (0) 2023.04.22 Flutter_04. Rendering Contents conditionally (0) 2023.04.19 Flutter_03. Excercise (0) 2023.04.18 Flutter_20230414_02. StatefulWidget (0) 2023.04.17 Flutter_20230413_00. Flutter 입문 (0) 2023.04.13