티스토리 뷰
Flutter Layout Demo 코드 (리팩토링 후)
- main.dart
- views/layout_demo_page.dart
- components/icon_group.dart
// main.dart
import 'package:flutter/material.dart';
import 'views/layout_demo_page.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.orange),
useMaterial3: true,
),
home: LayoutDemoPage(),
);
}
}
//views/layout_demo_page.dart
import 'package:flutter/material.dart';
import '../components/icon_group.dart';
class LayoutDemoPage extends StatelessWidget {
const LayoutDemoPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.primaryContainer,
title: Text(
'Flutter Layout Demo',
style: TextStyle(
color: Theme.of(context).colorScheme.onPrimaryContainer),
),
),
body: Column(
children: [
Image.asset(
'assets/m.webp',
width: 600,
height: 190,
fit: BoxFit.cover,
),
Padding(
padding: const EdgeInsets.all(32),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(bottom: 8),
child: Text(
'스위스에 멋진 캠프 그라운드',
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
Text(
'캔더스태그 / 스위스',
style: TextStyle(color: Colors.grey.shade500),
),
],
),
),
Icon(
Icons.star,
color: Colors.red,
),
Text('41')
],
),
),
IconGroup(),
Padding(
padding: const EdgeInsets.all(32),
child: Text(
'Lake Oeschinen lies at the foot of the Blüemlisalp in the '
'Bernese Alps. Situated 1,578 meters above sea level, it '
'is one of the larger Alpine Lakes. A gondola ride from '
'Kandersteg, followed by a half-hour walk through pastures '
'and pine forest, leads you to the lake, which warms to 20 '
'degrees Celsius in the summer. Activities enjoyed here '
'include rowing, and riding the summer toboggan run.',
softWrap: true,
),
)
],
),
);
}
}
// components/icon_group.dart
import 'package:flutter/material.dart';
class IconGroup extends StatelessWidget {
const IconGroup({
super.key,
});
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Column(
children: [Icon(Icons.call), Text('CALL')],
),
Column(
children: [Icon(Icons.route), Text('ROUTE')],
),
Column(
children: [Icon(Icons.share), Text('SHARE')],
),
],
);
}
}
'플러터(Flutter)' 카테고리의 다른 글
플러터 로그인 구현 (0) | 2024.10.24 |
---|---|
플러터 이미지 주사위 (0) | 2024.10.24 |
플러터 레이아웃 (0) | 2024.10.23 |
플러터 4.4.1 웹뷰 webview_flutter (0) | 2023.10.07 |
플러터 net::ERR_CLEARTEXT_NOT_PERMITTED (0) | 2023.10.07 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- C
- 포인터
- ocajp
- proc
- MySQL
- 자바
- 파이썬
- Python
- ocjap
- 프로씨
- 파싱
- 플러터
- KG
- php
- 문자열
- xe addon
- EC
- ocpjp
- esql
- xe애드온
- 인포믹스
- webix
- 자바 smtp
- XE3
- XE
- JDBC
- C언어
- 이클립스
- 오라클
- 스크래핑
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
글 보관함