{"id":32623,"date":"2024-11-01T09:10:24","date_gmt":"2024-11-01T09:10:24","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=32623"},"modified":"2024-11-01T11:54:33","modified_gmt":"2024-11-01T11:54:33","slug":"flutter-course-8-3-decorating-the-appbar","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/32623\/","title":{"rendered":"Flutter Course: 8.3 Decorating the AppBar"},"content":{"rendered":"<p><body><\/p>\n<p>Flutter is a UI toolkit developed by Google that allows you to create high-quality applications for both iOS and Android with a single codebase. One of Flutter&#8217;s powerful features is the ease of customizing the user interface (UI). In this tutorial, we will explore various ways to decorate Flutter&#8217;s <code>AppBar<\/code>.<\/p>\n<h2>What is AppBar?<\/h2>\n<p><code>AppBar<\/code> is a toolbar that appears at the top of a Flutter application and is a basic UI element that includes titles, menus, navigation icons, etc. It remains at the top of the screen while users navigate through the app and can be adjusted to match the overall theme and style of the application.<\/p>\n<h2>Creating a Basic AppBar<\/h2>\n<p>By default, the <code>AppBar<\/code> is placed within a <code>Scaffold<\/code> widget. Below is the code for a simple Flutter application with a basic <code>AppBar<\/code> added:<\/p>\n<pre><code>import 'package:flutter\/material.dart';\n\nvoid main() {\n  runApp(MyApp());\n}\n\nclass MyApp extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return MaterialApp(\n      home: Scaffold(\n        appBar: AppBar(\n          title: Text('Basic AppBar'),\n        ),\n        body: Center(child: Text('Hello!')),\n      ),\n    );\n  }\n}<\/code><\/pre>\n<h2>Changing the AppBar Color<\/h2>\n<p>Changing the color of the AppBar is crucial when setting the app&#8217;s theme. The example below shows how to change the AppBar&#8217;s background color using the <code>backgroundColor<\/code> property:<\/p>\n<pre><code>appBar: AppBar(\n  title: Text('Color Changed AppBar'),\n  backgroundColor: Colors.blueAccent,\n),<\/code><\/pre>\n<p>By setting this, the AppBar&#8217;s background color will change to <code>blueAccent<\/code>.<\/p>\n<h2>Adding Icons to the AppBar<\/h2>\n<p>You can make the app&#8217;s functionality more intuitive by adding icons to the AppBar. Icon buttons can be added using the <code>actions<\/code> property. The example below adds a &#8216;search&#8217; icon and defines an action when clicked:<\/p>\n<pre><code>appBar: AppBar(\n  title: Text('AppBar with Icons'),\n  actions: <widget>[\n    IconButton(\n      icon: Icon(Icons.search),\n      onPressed: () {\n        \/\/ Action when the search icon is clicked\n        print('Search icon clicked');\n      },\n    ),\n  ],\n),<\/widget><\/code><\/pre>\n<h2>Changing the AppBar Title Style<\/h2>\n<p>You can customize the AppBar&#8217;s title style for more personalization. The code below shows how to change the font size and color of the title:<\/p>\n<pre><code>appBar: AppBar(\n  title: Text(\n    'Styled Title',\n    style: TextStyle(\n      fontSize: 20,\n      color: Colors.white,\n      fontWeight: FontWeight.bold,\n    ),\n  ),\n),<\/code><\/pre>\n<h2>Creating a Custom AppBar<\/h2>\n<p>You can create a custom AppBar that goes beyond the basic functionality. By implementing Flutter&#8217;s <code>PreferredSizeWidget<\/code>, you can create an AppBar with your desired design. Below is an example of a simple custom AppBar:<\/p>\n<pre><code>class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {\n  @override\n  Widget build(BuildContext context) {\n    return Container(\n      color: Colors.blue,\n      child: Padding(\n        padding: const EdgeInsets.all(16.0),\n        child: Row(\n          mainAxisAlignment: MainAxisAlignment.spaceBetween,\n          children: [\n            Text('Custom AppBar', style: TextStyle(color: Colors.white, fontSize: 20)),\n            Icon(Icons.settings, color: Colors.white),\n          ],\n        ),\n      ),\n    );\n  }\n\n  @override\n  Size get preferredSize => Size.fromHeight(56.0);\n}<\/code><\/pre>\n<p>To use this custom AppBar, simply assign it to the <code>appBar<\/code> property of the <code>Scaffold<\/code>:<\/p>\n<pre><code>appBar: CustomAppBar(),<\/code><\/pre>\n<h2>Adding a Menu Button to the AppBar<\/h2>\n<p>Adding a menu button to the AppBar allows users to select more options. The code below adds a menu and includes several selectable items:<\/p>\n<pre><code>appBar: AppBar(\n  title: Text('AppBar with Menu Button'),\n  actions: <widget>[\n    PopupMenuButton<string>(\n      onSelected: (String result) {\n        print('Selected Menu: $result');\n      },\n      itemBuilder: (BuildContext context) => <popupmenuentry<string>>[\n        const PopupMenuItem<string>(\n          value: 'Option 1',\n          child: Text('Option 1'),\n        ),\n        const PopupMenuItem<string>(\n          value: 'Option 2',\n          child: Text('Option 2'),\n        ),\n      ],\n    ),\n  ],\n),<\/string><\/string><\/popupmenuentry<string><\/string><\/widget><\/code><\/pre>\n<h2>Making the AppBar Transparent<\/h2>\n<p>In certain apps, the AppBar&#8217;s background is set to transparent to highlight the content below. In such cases, you can use <code>Colors.transparent<\/code> for the <code>backgroundColor<\/code> property of the <code>AppBar<\/code>:<\/p>\n<pre><code>appBar: AppBar(\n  title: Text('Transparent AppBar'),\n  backgroundColor: Colors.transparent,\n),<\/code><\/pre>\n<h2>Using Images with the AppBar<\/h2>\n<p>You can enhance the design variety by combining a background image with background colors and text in the AppBar. Below is how to set the AppBar&#8217;s background to an image:<\/p>\n<pre><code>appBar: AppBar(\n  title: Text('Image Background AppBar'),\n  flexibleSpace: Container(\n    decoration: BoxDecoration(\n      image: DecorationImage(\n        image: NetworkImage('Image URL'),\n        fit: BoxFit.cover,\n      ),\n    ),\n  ),\n),<\/code><\/pre>\n<p>In the code above, replace the &#8216;Image URL&#8217; part with the link of the image you want to use.<\/p>\n<h2>Conclusion<\/h2>\n<p>In this tutorial, we explored various ways to decorate and customize the AppBar in Flutter. The AppBar significantly impacts the overall user experience of the application, so it is important to style it in various ways as needed. Experiment with different features through each example and create an AppBar that reflects your own style.<\/p>\n<p>We will continue to provide in-depth content on various Flutter-related topics. If you have questions or additional topics you would like us to cover, please leave a comment. Thank you!<\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Flutter is a UI toolkit developed by Google that allows you to create high-quality applications for both iOS and Android with a single codebase. One of Flutter&#8217;s powerful features is the ease of customizing the user interface (UI). In this tutorial, we will explore various ways to decorate Flutter&#8217;s AppBar. What is AppBar? AppBar is &hellip; <a href=\"https:\/\/atmokpo.com\/w\/32623\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Flutter Course: 8.3 Decorating the AppBar&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[151],"tags":[],"class_list":["post-32623","post","type-post","status-publish","format-standard","hentry","category-flutter-course"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Flutter Course: 8.3 Decorating the AppBar - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/atmokpo.com\/w\/32623\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Flutter Course: 8.3 Decorating the AppBar - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Flutter is a UI toolkit developed by Google that allows you to create high-quality applications for both iOS and Android with a single codebase. One of Flutter&#8217;s powerful features is the ease of customizing the user interface (UI). In this tutorial, we will explore various ways to decorate Flutter&#8217;s AppBar. What is AppBar? AppBar is &hellip; \ub354 \ubcf4\uae30 &quot;Flutter Course: 8.3 Decorating the AppBar&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/32623\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:10:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:54:33+00:00\" \/>\n<meta name=\"author\" content=\"root\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:site\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"root\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"3\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/32623\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32623\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Flutter Course: 8.3 Decorating the AppBar\",\"datePublished\":\"2024-11-01T09:10:24+00:00\",\"dateModified\":\"2024-11-01T11:54:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32623\/\"},\"wordCount\":506,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Flutter course\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/32623\/\",\"url\":\"https:\/\/atmokpo.com\/w\/32623\/\",\"name\":\"Flutter Course: 8.3 Decorating the AppBar - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:10:24+00:00\",\"dateModified\":\"2024-11-01T11:54:33+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32623\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/32623\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/32623\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Flutter Course: 8.3 Decorating the AppBar\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/atmokpo.com\/w\/#website\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/atmokpo.com\/w\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"contentUrl\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"width\":400,\"height\":400,\"caption\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\"},\"image\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/bebubo4\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\",\"name\":\"root\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"caption\":\"root\"},\"sameAs\":[\"http:\/\/atmokpo.com\/w\"],\"url\":\"https:\/\/atmokpo.com\/w\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Flutter Course: 8.3 Decorating the AppBar - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/atmokpo.com\/w\/32623\/","og_locale":"ko_KR","og_type":"article","og_title":"Flutter Course: 8.3 Decorating the AppBar - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Flutter is a UI toolkit developed by Google that allows you to create high-quality applications for both iOS and Android with a single codebase. One of Flutter&#8217;s powerful features is the ease of customizing the user interface (UI). In this tutorial, we will explore various ways to decorate Flutter&#8217;s AppBar. What is AppBar? AppBar is &hellip; \ub354 \ubcf4\uae30 \"Flutter Course: 8.3 Decorating the AppBar\"","og_url":"https:\/\/atmokpo.com\/w\/32623\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:10:24+00:00","article_modified_time":"2024-11-01T11:54:33+00:00","author":"root","twitter_card":"summary_large_image","twitter_creator":"@bebubo4","twitter_site":"@bebubo4","twitter_misc":{"\uae00\uc4f4\uc774":"root","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"3\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/32623\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/32623\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Flutter Course: 8.3 Decorating the AppBar","datePublished":"2024-11-01T09:10:24+00:00","dateModified":"2024-11-01T11:54:33+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/32623\/"},"wordCount":506,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Flutter course"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/32623\/","url":"https:\/\/atmokpo.com\/w\/32623\/","name":"Flutter Course: 8.3 Decorating the AppBar - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:10:24+00:00","dateModified":"2024-11-01T11:54:33+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/32623\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/32623\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/32623\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Flutter Course: 8.3 Decorating the AppBar"}]},{"@type":"WebSite","@id":"https:\/\/atmokpo.com\/w\/#website","url":"https:\/\/atmokpo.com\/w\/","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","description":"","publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/atmokpo.com\/w\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/atmokpo.com\/w\/#organization","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","url":"https:\/\/atmokpo.com\/w\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/","url":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","contentUrl":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","width":400,"height":400,"caption":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8"},"image":{"@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/bebubo4"]},{"@type":"Person","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7","name":"root","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","caption":"root"},"sameAs":["http:\/\/atmokpo.com\/w"],"url":"https:\/\/atmokpo.com\/w\/author\/root\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32623","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/comments?post=32623"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32623\/revisions"}],"predecessor-version":[{"id":32624,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32623\/revisions\/32624"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=32623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=32623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=32623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}