{"id":10250,"date":"2021-07-09T10:00:37","date_gmt":"2021-07-09T01:00:37","guid":{"rendered":"https:\/\/www.gigas-jp.com\/appnews\/?p=10250"},"modified":"2021-07-08T20:33:01","modified_gmt":"2021-07-08T11:33:01","slug":"creating-a-simple-gridview-in-flutter","status":"publish","type":"post","link":"https:\/\/www.gigas-jp.com\/appnews\/archives\/10250","title":{"rendered":"Creating a simple GridView in flutter"},"content":{"rendered":"\n<p>During  studying flutter, I learned a beautiful and simple grid system. These  interesting and simple grid view layout topics I would like to share you today. <\/p>\n\n\n\n<p>Ever created with a multiple layout with multiple rows within a column?<\/p>\n\n\n\n<p>Try  a GridView! While there are multiple GridView constructors, the most common way to create a GridView is the <strong><em>count <\/em><\/strong>constructor.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GridView.count(\n..\n..\n)<\/code><\/pre>\n\n\n\n<p>Start by listing all the items you want in the grid, <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GridView.count(\nchildren: [allItems],\n)<\/code><\/pre>\n\n\n\n<p>but it doesn&#8217;t end there, control how many items you want to across the grid, by setting the <strong><em>crossAxisCount<\/em><\/strong> property.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GridView.count(\ncrossAxisCount: 1,\nchildren: [allItems],\n)<\/code><\/pre>\n\n\n\n<p>Setting it to <strong><em>1<\/em><\/strong> makes it look like a normal list. And if your items want to some social distancing? Use <strong><em>mainAxisSpacing<\/em><\/strong>  gives horizontal space between the rows and <strong><em>crossAxisSpacing<\/em><\/strong> provides vertical space between the columns.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GridView.count(\nmainAxisSpacing: 28.0,\ncrossAxisCount: 2,\nchildren: [allItems],\n)<\/code><\/pre>\n\n\n\n<p>Now Let&#8217;s make simple grid view using GridView.count constructor.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GridView.count(\n  primary: false,\n  padding: const EdgeInsets.all(20),\n  crossAxisSpacing: 10,\n  mainAxisSpacing: 10,\n  crossAxisCount: 2,\n  children: &lt;Widget>[\n    Container(\n      padding: const EdgeInsets.all(8),\n      child: const Text(\"He'd have you all unravel at the\"),\n      color: Colors.teal[100],\n    ),\n    Container(\n      padding: const EdgeInsets.all(8),\n      child: const Text('Heed not the rabble'),\n      color: Colors.teal[200],\n    ),\n    Container(\n      padding: const EdgeInsets.all(8),\n      child: const Text('Sound of screams but the'),\n      color: Colors.teal[300],\n    ),\n    Container(\n      padding: const EdgeInsets.all(8),\n      child: const Text('Who scream'),\n      color: Colors.teal[400],\n    ),\n    Container(\n      padding: const EdgeInsets.all(8),\n      child: const Text('Revolution is coming...'),\n      color: Colors.teal[500],\n    ),\n    Container(\n      padding: const EdgeInsets.all(8),\n      child: const Text('Revolution, they...'),\n      color: Colors.teal[600],\n    ),\n  ],\n)<\/code><\/pre>\n\n\n\n<p>The result is!<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"700\" height=\"1024\" src=\"\/appnews\/wp-content\/uploads\/sites\/4\/2021\/07\/Screenshot_1625740582-2-700x1024.png\" alt=\"\" class=\"wp-image-10259\" srcset=\"https:\/\/www.gigas-jp.com\/appnews\/wp-content\/uploads\/sites\/4\/2021\/07\/Screenshot_1625740582-2-700x1024.png 700w, https:\/\/www.gigas-jp.com\/appnews\/wp-content\/uploads\/sites\/4\/2021\/07\/Screenshot_1625740582-2.png 1439w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/figure>\n\n\n\n<p>By Ami<\/p>\n<div class='wp_social_bookmarking_light'>\n            <div class=\"wsbl_google_plus_one\"><g:plusone size=\"medium\" annotation=\"none\" href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/10250\" ><\/g:plusone><\/div>\n            <div class=\"wsbl_hatena_button\"><a href=\"\/\/b.hatena.ne.jp\/entry\/https:\/\/www.gigas-jp.com\/appnews\/archives\/10250\" class=\"hatena-bookmark-button\" data-hatena-bookmark-title=\"Creating a simple GridView in flutter\" data-hatena-bookmark-layout=\"standard\" title=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\"> <img src=\"\/\/b.hatena.ne.jp\/images\/entry-button\/button-only@2x.png\" alt=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\" width=\"20\" height=\"20\" style=\"border: none;\" \/><\/a><script type=\"text\/javascript\" src=\"\/\/b.hatena.ne.jp\/js\/bookmark_button.js\" charset=\"utf-8\" async=\"async\"><\/script><\/div>\n            <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/10250\" data-text=\"Creating a simple GridView in flutter\" data-via=\"GIGASJAPAN_APPS\" data-lang=\"ja\">Tweet<\/a><\/div>\n            <div class=\"wsbl_facebook_like\"><div id=\"fb-root\"><\/div><fb:like href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/10250\" layout=\"button_count\" action=\"like\" width=\"100\" share=\"false\" show_faces=\"false\" ><\/fb:like><\/div>\n            <div class=\"wsbl_facebook_send\"><div id=\"fb-root\"><\/div><fb:send href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/10250\" colorscheme=\"light\" ><\/fb:send><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>During studying flutter, I learned a beautiful and simple grid system. These interesting and simple grid view  [&hellip;]<\/p>\n","protected":false},"author":19,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[100],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/10250"}],"collection":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/comments?post=10250"}],"version-history":[{"count":5,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/10250\/revisions"}],"predecessor-version":[{"id":10261,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/10250\/revisions\/10261"}],"wp:attachment":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/media?parent=10250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/categories?post=10250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/tags?post=10250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}