{"id":32467,"date":"2024-11-01T09:09:12","date_gmt":"2024-11-01T09:09:12","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=32467"},"modified":"2024-11-01T11:55:11","modified_gmt":"2024-11-01T11:55:11","slug":"flutter-course-11-2-layout-composition","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/32467\/","title":{"rendered":"Flutter Course: 11.2 Layout Composition"},"content":{"rendered":"<p><body><\/p>\n<p>Flutter is a powerful framework that allows you to easily create attractive User Interfaces (UI). In this lesson 11.2, we will delve deeply into the layout composition in Flutter. Layout composition is a crucial process for effectively placing complex UI elements. In this process, we will utilize various widgets and the layout system provided by Flutter.<\/p>\n<h2>1. Fundamental Concepts of Layout<\/h2>\n<p>Layout refers to the topic of how UI elements are arranged on the screen. Flutter uses widgets to compose layouts. Everything in Flutter is made up of widgets, and these widgets combine to form complex UIs. The layout system primarily uses containers, so the properties of the container determine the position of the UI.<\/p>\n<h3>1.1. Concept of Widgets<\/h3>\n<p>In Flutter, widgets are the components of the UI, and each widget has its own properties and layout. Flutter&#8217;s widgets are broadly categorized into StatelessWidget and StatefulWidget. StatelessWidget does not have a state and is used to create unchanging UIs. Conversely, StatefulWidget has a state and changes the UI according to state changes.<\/p>\n<h3>1.2. Parent-Child Relationship<\/h3>\n<p>Widgets have a parent-child relationship. A parent widget can include child widgets, enabling layout composition. For example, the <code>Column<\/code> widget can arrange multiple child widgets vertically.<\/p>\n<h2>2. Layout Widgets in Flutter<\/h2>\n<p>Flutter provides various layout widgets. In this section, we will look at the key layout widgets that are commonly used.<\/p>\n<h3>2.1. Container<\/h3>\n<p>The <code>Container<\/code> widget is the most basic widget and allows you to encapsulate other widgets to adjust size, padding, margins, etc. You can apply additional styles such as background color and borders using the <code>Container<\/code>.<\/p>\n<pre><code>Container(\n  width: 200,\n  height: 100,\n  color: Colors.blue,\n  padding: EdgeInsets.all(10),\n  child: Text('Hello, Flutter!'),\n)<\/code><\/pre>\n<h3>2.2. Row<\/h3>\n<p>The <code>Row<\/code> widget arranges child widgets horizontally. You can define alignment methods using the <code>mainAxisAlignment<\/code> and <code>crossAxisAlignment<\/code> properties.<\/p>\n<pre><code>Row(\n  mainAxisAlignment: MainAxisAlignment.spaceEvenly,\n  children: <widget>[\n    Icon(Icons.star),\n    Icon(Icons.star),\n    Icon(Icons.star),\n  ],\n)<\/widget><\/code><\/pre>\n<h3>2.3. Column<\/h3>\n<p>The <code>Column<\/code> widget lists child widgets vertically. Similarly, you can adjust arrangements through <code>mainAxisAlignment<\/code> and <code>crossAxisAlignment<\/code>.<\/p>\n<pre><code>Column(\n  mainAxisAlignment: MainAxisAlignment.start,\n  children: <widget>[\n    Text('Item 1'),\n    Text('Item 2'),\n    Text('Item 3'),\n  ],\n)<\/widget><\/code><\/pre>\n<h3>2.4. Stack<\/h3>\n<p>The <code>Stack<\/code> widget stacks multiple widgets on top of each other. You can adjust the position of each child widget using the <code>Positioned<\/code> widget.<\/p>\n<pre><code>Stack(\n  children: <widget>[\n    Container(color: Colors.red, width: 100, height: 100),\n    Positioned(\n      left: 20,\n      top: 20,\n      child: Container(color: Colors.blue, width: 50, height: 50),\n    ),\n  ],\n)<\/widget><\/code><\/pre>\n<h3>2.5. ListView<\/h3>\n<p>The <code>ListView<\/code> widget creates a scrollable list. It is very useful for easily listing multiple items.<\/p>\n<pre><code>ListView(\n  children: <widget>[\n    ListTile(title: Text('Item 1')),\n    ListTile(title: Text('Item 2')),\n    ListTile(title: Text('Item 3')),\n  ],\n)<\/widget><\/code><\/pre>\n<h2>3. Layout Properties<\/h2>\n<p>We will learn about the main properties that can be used when configuring layout widgets.<\/p>\n<h3>3.1. Padding<\/h3>\n<p>You can use the <code>Padding<\/code> widget to add padding to a widget, setting space around child widgets.<\/p>\n<pre><code>Padding(\n  padding: EdgeInsets.all(16.0),\n  child: Text('Hello, Flutter!'),\n)<\/code><\/pre>\n<h3>3.2. Margin<\/h3>\n<p>Margins can be set as properties of the <code>Container<\/code> widget. This property expands the space around the child widget.<\/p>\n<pre><code>Container(\n  margin: EdgeInsets.all(20),\n  child: Text('Hello with Margin!'),\n)<\/code><\/pre>\n<h2>4. Composing Complex Layouts<\/h2>\n<p>Now, let&#8217;s create more complex layouts from simple widget compositions. We will combine multiple widgets to form a more realistic UI.<\/p>\n<h3>4.1. Creating a Card Layout<\/h3>\n<p>Let&#8217;s create a simple layout displaying information using a card. We will combine various widgets to create a UI that includes all elements.<\/p>\n<pre><code>Card(\n  child: Column(\n    crossAxisAlignment: CrossAxisAlignment.start,\n    children: <widget>[\n      Padding(\n        padding: const EdgeInsets.all(16.0),\n        child: Text('Title', style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold)),\n      ),\n      Padding(\n        padding: const EdgeInsets.all(16.0),\n        child: Text('This is a sample card in Flutter.', style: TextStyle(fontSize: 16)),\n      ),\n      ButtonBar(\n        children: <widget>[\n          TextButton(child: Text('EDIT'), onPressed: () {\/*Edit logic*\/}),\n          TextButton(child: Text('DELETE'), onPressed: () {\/*Delete logic*\/}),\n        ],\n      ),\n    ],\n  ),\n)<\/widget><\/widget><\/code><\/pre>\n<h2>5. Composing Responsive Layouts<\/h2>\n<p>It is also essential to create responsive layouts to allow users to use the application on various screen sizes.<\/p>\n<h3>5.1. Using MediaQuery<\/h3>\n<p>In Flutter, you can use <code>MediaQuery<\/code> to dynamically detect the size of the screen. This allows you to apply designs suitable for various screen sizes.<\/p>\n<pre><code>final width = MediaQuery.of(context).size.width;\nfinal height = MediaQuery.of(context).size.height;\n<\/code><\/pre>\n<h3>5.2. LayoutBuilder<\/h3>\n<p>The <code>LayoutBuilder<\/code> widget receives specific constraints for the child widget. Through this, you can configure it to act differently based on the widget&#8217;s size.<\/p>\n<pre><code>LayoutBuilder(\n  builder: (BuildContext context, BoxConstraints constraints) {\n    return Container(\n      width: constraints.maxWidth &lt; 600 ? 100 : 200,\n      height: 100,\n      child: Text('Responsive Container'),\n    );\n  },\n)<\/code><\/pre>\n<h2>6. Conclusion<\/h2>\n<p>In this lesson, we learned about layout composition in Flutter. We saw how to create complex UIs using various widgets and how responsive design can enhance user experience. By understanding and utilizing the layout system, we can develop better applications.<\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Flutter is a powerful framework that allows you to easily create attractive User Interfaces (UI). In this lesson 11.2, we will delve deeply into the layout composition in Flutter. Layout composition is a crucial process for effectively placing complex UI elements. In this process, we will utilize various widgets and the layout system provided by &hellip; <a href=\"https:\/\/atmokpo.com\/w\/32467\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Flutter Course: 11.2 Layout Composition&#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-32467","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: 11.2 Layout Composition - \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\/32467\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Flutter Course: 11.2 Layout Composition - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Flutter is a powerful framework that allows you to easily create attractive User Interfaces (UI). In this lesson 11.2, we will delve deeply into the layout composition in Flutter. Layout composition is a crucial process for effectively placing complex UI elements. In this process, we will utilize various widgets and the layout system provided by &hellip; \ub354 \ubcf4\uae30 &quot;Flutter Course: 11.2 Layout Composition&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/32467\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:09:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:55:11+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=\"4\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/32467\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32467\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Flutter Course: 11.2 Layout Composition\",\"datePublished\":\"2024-11-01T09:09:12+00:00\",\"dateModified\":\"2024-11-01T11:55:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32467\/\"},\"wordCount\":548,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Flutter course\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/32467\/\",\"url\":\"https:\/\/atmokpo.com\/w\/32467\/\",\"name\":\"Flutter Course: 11.2 Layout Composition - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:09:12+00:00\",\"dateModified\":\"2024-11-01T11:55:11+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32467\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/32467\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/32467\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Flutter Course: 11.2 Layout Composition\"}]},{\"@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: 11.2 Layout Composition - \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\/32467\/","og_locale":"ko_KR","og_type":"article","og_title":"Flutter Course: 11.2 Layout Composition - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Flutter is a powerful framework that allows you to easily create attractive User Interfaces (UI). In this lesson 11.2, we will delve deeply into the layout composition in Flutter. Layout composition is a crucial process for effectively placing complex UI elements. In this process, we will utilize various widgets and the layout system provided by &hellip; \ub354 \ubcf4\uae30 \"Flutter Course: 11.2 Layout Composition\"","og_url":"https:\/\/atmokpo.com\/w\/32467\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:09:12+00:00","article_modified_time":"2024-11-01T11:55:11+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":"4\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/32467\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/32467\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Flutter Course: 11.2 Layout Composition","datePublished":"2024-11-01T09:09:12+00:00","dateModified":"2024-11-01T11:55:11+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/32467\/"},"wordCount":548,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Flutter course"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/32467\/","url":"https:\/\/atmokpo.com\/w\/32467\/","name":"Flutter Course: 11.2 Layout Composition - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:09:12+00:00","dateModified":"2024-11-01T11:55:11+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/32467\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/32467\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/32467\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Flutter Course: 11.2 Layout Composition"}]},{"@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\/32467","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=32467"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32467\/revisions"}],"predecessor-version":[{"id":32468,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32467\/revisions\/32468"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=32467"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=32467"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=32467"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}