-
Flutter_03. Excercise> Frontend/Flutter 2023. 4. 18. 21:30
1. 그 동안 배운 내용을 바탕으로 아래의 화면을 만들어보자.
2.
import 'package:flutter/material.dart'; import 'components/start_screen.dart'; void main() { runApp( MaterialApp( home: Scaffold( body: Container( decoration: const BoxDecoration( gradient: LinearGradient( colors: [ Color.fromARGB(255, 78, 13, 151), Color.fromARGB(255, 107, 15, 168), ], begin: Alignment.topLeft, end: Alignment.bottomRight, ), ), child: const StartScreen(), ), ), ), ); }
import 'package:flutter/material.dart'; class StartScreen extends StatelessWidget { const StartScreen({super.key}); @override Widget build(BuildContext context) { return Center( // Center widget centers the content inside of it both horizontally and vertically. child: Column( mainAxisSize: MainAxisSize.min, // this will take minimal vertical space as needed. children: [ Image.asset( 'assets/images/quiz-logo.png', width: 300, ), const SizedBox(height: 80), // define exact size of th widget, not take available space. const Text( 'Learn Flutter the Fun way', style: TextStyle(color: Colors.white, fontSize: 24), ), const SizedBox(height: 30), OutlinedButton( onPressed: () => {}, style: OutlinedButton.styleFrom(foregroundColor: Colors.white), child: const Text('Start Quiz'), ) ], ), ); } }
- OutlinedButton 스타일은 style: OutlinedButton.styleFrom(foregroundColor: Colors.white) 을 통해서 지정할 수 있다.
- SizedBox(height: n)을 통해 위젯간 간격 조정 가능
- mainAxisSize: MainAxisSize.min ㅇㄹ
3. Start Quiz 버튼에 아이콘과 클릭시 반응 추가.
OutlinedButton.icon( // ways to add Icon onPressed: () => {}, style: OutlinedButton.styleFrom(foregroundColor: Colors.white), icon: const Icon(Icons.arrow_right_alt), // can be use anywhere else label: const Text('Learn Now !'), )
'> Frontend > Flutter' 카테고리의 다른 글
Flutter_05. If-Statement & 퀴즈 데이터 (0) 2023.04.22 Flutter_04. Rendering Contents conditionally (0) 2023.04.19 Flutter_20230414_02. StatefulWidget (0) 2023.04.17 Flutter_20230414_01. Flutter (0) 2023.04.14 Flutter_20230413_00. Flutter 입문 (0) 2023.04.13