[Flutter] AppBar의 "모든 것"
다음 Flutter 애플리케이션에서는 제목만 AppBar Tutorial로 설정하여 Scaffold에 간단한 AppBar를 표시합니다.
main.dart
import 'package:flutter/material.dart';void main() => runApp(const MyApp());/// main application widgetclass MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); static const String _title = 'Flutter Tutorial'; @override Widget build(BuildContext context) { return const MaterialApp( title: _title, home: MyStatelessWidget(), ); }}/// stateless widget that the main application instantiatesclass MyStatelessWidget extends StatelessWidget { const MyStatelessWidget({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('AppBar Tutorial'), ), body: const Center( child: Text( 'Hello World!', style: TextStyle(fontSize: 24), ), ), ); }} |
스크린샷 [안드로이드 에뮬레이터, ios 시뮬레이터]
AppBar에 IconButton 추가하기
main.dart
import 'package:flutter/material.dart';void main() => runApp(const MyApp());/// main application widgetclass MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); static const String _title = 'Flutter Tutorial'; @override Widget build(BuildContext context) { return const MaterialApp( title: _title, home: MyStatelessWidget(), ); }}/// stateless widget that the main application instantiatesclass MyStatelessWidget extends StatelessWidget { const MyStatelessWidget({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('AppBar Tutorial'), actions: <Widget>[ IconButton( icon: const Icon(Icons.add_alert), onPressed: () { ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text('You pressed bell icon.'))); }, ), ], ), body: const Center( child: Text( 'Hello World!', style: TextStyle(fontSize: 24), ), ), ); }} |
스크린샷 [안드로이드 에뮬레이터, ios 시뮬레이터]
![[Flutter] AppBar의 "모든 것" [Flutter] AppBar의 "모든 것"](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUa6eJ4xL76yRtMEsWZNxLJOnPCMse9E54lE-kau8CmUqKo2P-8AOvpiOco_kxWWfdnsc_G186Spc7OLRnKIlWHNx2CkDlq7yd36Ku2WEWz23ZAC2hjUHGju-p4ZSncwbReNTmqmgSEbeOV1jif9ImJPn2bccRnJIjmNOzOf553W5ij8OSXO34WSOd/s16000/appbar.jpg)
![[Flutter] AppBar의 "모든 것" [Flutter] AppBar의 "모든 것"](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjx6l8bZMcI30zny_KwF1VbooMwewZ-o71G-Gg6Q9dao801HpGS7csIvASRcIjxz6X2fYh5Zh2ADSrk3XarHBPXHEeKXSr0omaMm_kVqthVjufAL18pDXYZ7G-Em9cN_NNJzckQ1w3wfXVz1tmqMsmP_4bU2fbj9uR6LqZjkOQ2aqDtABEpvw__yUD/s16000/app-bar-flutter-korea.jpg)
댓글
댓글 쓰기