{"id":32485,"date":"2024-11-01T09:09:22","date_gmt":"2024-11-01T09:09:22","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=32485"},"modified":"2024-11-01T11:55:07","modified_gmt":"2024-11-01T11:55:07","slug":"flutter-course-12-5-singlechildscrollview-widget","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/32485\/","title":{"rendered":"Flutter Course: 12.5 SingleChildScrollView Widget"},"content":{"rendered":"<p>Flutter is one of the most popular frameworks for developing mobile applications. With a variety of widgets, developers can easily design complex UIs. In this article, we will delve deeply into the <strong>SingleChildScrollView<\/strong> widget in Flutter and detail its usage with real-world examples.<\/p>\n<h2>Simple Example<\/h2>\n<p>The SingleChildScrollView widget provides a scrollable view when the child widget exceeds the size of the screen. The most basic usage is as follows:<\/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('SingleChildScrollView Example'),\n        ),\n        body: SingleChildScrollView(\n          child: Column(\n            children: <widget>[\n              Container(height: 200, color: Colors.red),\n              Container(height: 200, color: Colors.green),\n              Container(height: 200, color: Colors.blue),\n              Container(height: 200, color: Colors.yellow),\n              Container(height: 200, color: Colors.purple),\n            ],\n          ),\n        ),\n      ),\n    );\n  }\n}\n<\/widget><\/code><\/pre>\n<p>In the above example, multiple Container widgets are arranged vertically. If the height exceeds the screen, the SingleChildScrollView is activated, allowing the user to scroll to see all the content.<\/p>\n<h2>SingleChildScrollView Properties<\/h2>\n<p>SingleChildScrollView offers various properties. Each property is used to customize the scrollable view. The main properties are as follows:<\/p>\n<ul>\n<li><strong>padding:<\/strong> You can set the external padding for the scroll view.<\/li>\n<li><strong>scrollDirection:<\/strong> Sets the direction of the scroll. The default is vertical.<\/li>\n<li><strong>reverse:<\/strong> Reverses the scroll direction.<\/li>\n<li><strong>controller:<\/strong> Sets a ScrollController for controlling the scroll.<\/li>\n<li><strong>physics:<\/strong> Sets the physical properties of the scroll behavior.<\/li>\n<\/ul>\n<h3>Example: Padding and ScrollDirection<\/h3>\n<pre><code>SingleChildScrollView(\n  padding: EdgeInsets.all(16.0),\n  scrollDirection: Axis.horizontal,\n  child: Row(\n    children: <widget>[\n      Container(width: 200, height: 100, color: Colors.red),\n      Container(width: 200, height: 100, color: Colors.green),\n      Container(width: 200, height: 100, color: Colors.blue),\n      Container(width: 200, height: 100, color: Colors.yellow),\n    ],\n  ),\n)<\/widget><\/code><\/pre>\n<p>The above example sets the padding for SingleChildScrollView and changes the scroll direction to horizontal. This allows the user to create a UI that can be scrolled horizontally.<\/p>\n<h2>Using ScrollController<\/h2>\n<p>Using ScrollController, you can control the scroll position or perform actions such as scrolling to a specific position. Below is an example of using ScrollController:<\/p>\n<pre><code>class MyHomePage extends StatelessWidget {\n  final ScrollController _scrollController = ScrollController();\n\n  @override\n  Widget build(BuildContext context) {\n    return Scaffold(\n      appBar: AppBar(\n        title: Text('ScrollController Example'),\n      },\n      body: SingleChildScrollView(\n        controller: _scrollController,\n        child: Column(\n          children: <widget>[\n            Container(height: 600, color: Colors.red),\n            Container(height: 600, color: Colors.green),\n            ElevatedButton(\n              onPressed: () {\n                _scrollController.animateTo(\n                  100.0,\n                  duration: Duration(seconds: 1),\n                  curve: Curves.easeInOut,\n                );\n              },\n              child: Text('Scroll to 100'),\n            ),\n          ],\n        ),\n      ),\n    );\n  }\n}<\/widget><\/code><\/pre>\n<p>The above example demonstrates the functionality of automatically changing the scroll when the ElevatedButton is pressed. When the button is clicked, the scroll moves down by 100 pixels.<\/p>\n<h2>Setting Scroll Physical Responses<\/h2>\n<p>The <strong>physics<\/strong> property of SingleChildScrollView controls the physical response of the scroll. There are various physical responses, including the following:<\/p>\n<ul>\n<li><strong>AlwaysScrollableScrollPhysics:<\/strong> Ensures the view is always scrollable.<\/li>\n<li><strong>BouncingScrollPhysics:<\/strong> Adds a bounce effect when the scroll reaches the end.<\/li>\n<li><strong>ClampingScrollPhysics:<\/strong> Prevents further scrolling when the scroll reaches the end.<\/li>\n<\/ul>\n<h3>Example: Using BouncingScrollPhysics<\/h3>\n<pre><code>SingleChildScrollView(\n  physics: BouncingScrollPhysics(),\n  child: Column(\n    children: <widget>[\n      Container(height: 600, color: Colors.red),\n      Container(height: 600, color: Colors.green),\n    ],\n  ),\n)<\/widget><\/code><\/pre>\n<h2>Using with State Management<\/h2>\n<p>SingleChildScrollView is useful for displaying dynamic content when used with state management patterns. For example, you can manage data state using Provider or Riverpod. Below is a simple example of using it with Provider.<\/p>\n<pre><code>class NumberProvider extends ChangeNotifier {\n  List<int> numbers = [];\n\n  void addNumber() {\n    numbers.add(numbers.length);\n    notifyListeners();\n  }\n}\n\nclass NumberList extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return Consumer<numberprovider>(\n      builder: (context, provider, child) {\n        return SingleChildScrollView(\n          child: Column(\n            children: provider.numbers.map((number) {\n              return ListTile(title: Text('Number: $number'));\n            }).toList(),\n          ),\n        );\n      },\n    );\n  }\n}<\/numberprovider><\/int><\/code><\/pre>\n<p>This example demonstrates the ability to dynamically update the list by adding numbers through a button.<\/p>\n<h2>Conclusion<\/h2>\n<p>The SingleChildScrollView widget is a very useful tool in Flutter for displaying long content that requires scrolling. You can effectively utilize SingleChildScrollView through various properties and examples. This enables you to develop user-friendly apps that implement various scrolling-related features.<\/p>\n<p>In this tutorial, we explored the basic usage and advanced features of the SingleChildScrollView widget. If you have any additional questions or need assistance, please leave a comment and I will be happy to respond. Thank you!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Flutter is one of the most popular frameworks for developing mobile applications. With a variety of widgets, developers can easily design complex UIs. In this article, we will delve deeply into the SingleChildScrollView widget in Flutter and detail its usage with real-world examples. Simple Example The SingleChildScrollView widget provides a scrollable view when the child &hellip; <a href=\"https:\/\/atmokpo.com\/w\/32485\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Flutter Course: 12.5 SingleChildScrollView Widget&#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-32485","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: 12.5 SingleChildScrollView Widget - \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\/32485\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Flutter Course: 12.5 SingleChildScrollView Widget - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Flutter is one of the most popular frameworks for developing mobile applications. With a variety of widgets, developers can easily design complex UIs. In this article, we will delve deeply into the SingleChildScrollView widget in Flutter and detail its usage with real-world examples. Simple Example The SingleChildScrollView widget provides a scrollable view when the child &hellip; \ub354 \ubcf4\uae30 &quot;Flutter Course: 12.5 SingleChildScrollView Widget&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/32485\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:09:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:55:07+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\/32485\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32485\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Flutter Course: 12.5 SingleChildScrollView Widget\",\"datePublished\":\"2024-11-01T09:09:22+00:00\",\"dateModified\":\"2024-11-01T11:55:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32485\/\"},\"wordCount\":440,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Flutter course\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/32485\/\",\"url\":\"https:\/\/atmokpo.com\/w\/32485\/\",\"name\":\"Flutter Course: 12.5 SingleChildScrollView Widget - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:09:22+00:00\",\"dateModified\":\"2024-11-01T11:55:07+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32485\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/32485\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/32485\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Flutter Course: 12.5 SingleChildScrollView Widget\"}]},{\"@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: 12.5 SingleChildScrollView Widget - \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\/32485\/","og_locale":"ko_KR","og_type":"article","og_title":"Flutter Course: 12.5 SingleChildScrollView Widget - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Flutter is one of the most popular frameworks for developing mobile applications. With a variety of widgets, developers can easily design complex UIs. In this article, we will delve deeply into the SingleChildScrollView widget in Flutter and detail its usage with real-world examples. Simple Example The SingleChildScrollView widget provides a scrollable view when the child &hellip; \ub354 \ubcf4\uae30 \"Flutter Course: 12.5 SingleChildScrollView Widget\"","og_url":"https:\/\/atmokpo.com\/w\/32485\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:09:22+00:00","article_modified_time":"2024-11-01T11:55:07+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\/32485\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/32485\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Flutter Course: 12.5 SingleChildScrollView Widget","datePublished":"2024-11-01T09:09:22+00:00","dateModified":"2024-11-01T11:55:07+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/32485\/"},"wordCount":440,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Flutter course"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/32485\/","url":"https:\/\/atmokpo.com\/w\/32485\/","name":"Flutter Course: 12.5 SingleChildScrollView Widget - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:09:22+00:00","dateModified":"2024-11-01T11:55:07+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/32485\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/32485\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/32485\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Flutter Course: 12.5 SingleChildScrollView Widget"}]},{"@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\/32485","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=32485"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32485\/revisions"}],"predecessor-version":[{"id":32486,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32485\/revisions\/32486"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=32485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=32485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=32485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}