출처: https://www.youtube.com/watch?v=U6rLIFn59Kw
MaterialApp -> google 스타일의 , 또는 커스텀 디자인의 (디자인 뿐만 아니라 기본세팅)
Cupertino -> iphone 스타일의 애플리케이션
MaterialApp
Scaffold -> 상단 중단 하단으로 구성되어있는 애플리케이션 개발용
appBar: (상단)
body: (중단)
bottomNavigationBar: (하단)
가로 배치: Row
세로 배치: Column
속성: mainAxisAlignment (Row의 경우 가로속성, Column의 경우 세로속성)
crossAxisAlignment(Row의 경우 세로속성, Column의 경우 가로속성)
Column 예시
Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: const [
Icon(Icons.star),
Icon(Icons.star)
],
),
세로로 별 두개를 배치(균등하게)
연습문제 정답?
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('앱임'),),
body: const Text('안녕'),
bottomNavigationBar: BottomAppBar(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: const [Icon(Icons.phone),
Icon(Icons.message),
Icon(Icons.contact_page),
],
),
))
);
}
}
BottomAppbar를 SizedBox로 감싸야한다. (정답참조본)
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('앱임'),),
body: const Text('안녕'),
bottomNavigationBar: BottomAppBar(
child: SizedBox(
height: 70,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: const [Icon(Icons.phone),
Icon(Icons.message),
Icon(Icons.contact_page),
],
),
)
))
);
}
}
'Flutter > 튜토리얼' 카테고리의 다른 글
Flutter Dart 함수 (0) | 2022.02.02 |
---|---|
Flutter - Isolates / Thread (0) | 2022.02.02 |
Flutter Button (0) | 2022.02.01 |
기본 위젯 구현하기 (0) | 2022.01.31 |
Flutter 설치하기(Windows) (0) | 2022.01.30 |