{"id":10344,"date":"2021-08-20T10:00:32","date_gmt":"2021-08-20T01:00:32","guid":{"rendered":"https:\/\/www.gigas-jp.com\/appnews\/?p=10344"},"modified":"2021-08-19T18:53:38","modified_gmt":"2021-08-19T09:53:38","slug":"flutter-physical-model","status":"publish","type":"post","link":"https:\/\/www.gigas-jp.com\/appnews\/archives\/10344","title":{"rendered":"Flutter &#8211; Physical Model"},"content":{"rendered":"\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" src=\"\/appnews\/wp-content\/uploads\/sites\/4\/2021\/08\/Screenshot_1628755319-485x1024.png\" alt=\"\" class=\"wp-image-10373\" width=\"240\" height=\"508\" srcset=\"https:\/\/www.gigas-jp.com\/appnews\/wp-content\/uploads\/sites\/4\/2021\/08\/Screenshot_1628755319-485x1024.png 485w, https:\/\/www.gigas-jp.com\/appnews\/wp-content\/uploads\/sites\/4\/2021\/08\/Screenshot_1628755319.png 1080w\" sizes=\"(max-width: 240px) 100vw, 240px\" \/><\/figure>\n\n\n\n<p>All of the best app start with a square, squarely in the middle of the screen. But to turn this abstract idea into something more real we need to think outside the box.<\/p>\n\n\n\n<p>All of the best app start with a square, squarely in the middle of the screen. But to turn this abstract idea into something more real we need to think outside the box.<\/p>\n\n\n\n<p>If you look at the real physical box the only way you&#8217;re able to see it with some light, and that light casts a shadow. What if we want our abstract boxes to have a real shadow? Just like a real box. So that our users have a mental model for what the things in your app are.<\/p>\n\n\n\n<p>Well, that&#8217;s what a Physical Model is for.  Just take whatever widget you&#8217;re working with, wrap it inside of a Physical Model and give it a color.  <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PhysicalModel(\n  child: BlueBox(),\n  color: Colors.black,\n)<\/code><\/pre>\n\n\n\n<p>Wait! There is no shadow. By default Physical Model&#8217;s <strong>elevation<\/strong> is <strong>zero<\/strong>,  so we need to pick that box up to be able to see the shadow. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PhysicalModel(\n  child: BlueBox(),\n  color: Colors.black,\n  elevation:  8.0\n)<\/code><\/pre>\n\n\n\n<p>But unlike the real world we have additional options, for our Physical model&#8217;s shadows, like it&#8217;s color.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PhysicalModel(\n  child: BlueBox(),\n  color: Colors.black,\n  shadowColor: Colors.pink,\n  elevation:  8.0,\n)<\/code><\/pre>\n\n\n\n<p>You can also change the roundness of the shadow&#8217;s corners.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PhysicalModel(\n  child: BlueBox(),\n  color: Colors.black,\n  shadowColor: Colors.pink,\n  elevation:  8.0,\n  borderRadius: \n   BorderRadius: circular(45),\n)<\/code><\/pre>\n\n\n\n<p>or simply update what shape it takes.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PhysicalModel(\n  child: BlueBox(),\n  color: Colors.black,\n  shadowColor: Colors.pink,\n  elevation:  8.0,\n  shape: BoxShape.circle,\n)<\/code><\/pre>\n\n\n\n<p>Physical Model is super useful, when you have ideas for custom shadow effects,  it&#8217;s also used under the hood in widgets like Material to build material shadow.<\/p>\n\n\n\n<p>Let&#8217;s create simple Physical model!!\u3000The result screenshoot is at the top. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    return Scaffold(\n      body: Center(\n        child: PhysicalModel(\n          elevation: 20.0,\n          shadowColor: Colors.red,\n          color: Colors.red,\n          child: Container(\n            width: 200,\n            height: 200,\n            decoration: BoxDecoration(\n              shape: BoxShape.circle,\n              border: Border.all(\n                color: Colors.red,\n                width: 1.0,\n              ),\n            ),\n          ),\n        ),\n      ),\n    );<\/code><\/pre>\n\n\n\n<p> Hope you enjoyed this post! <\/p>\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\/10344\" ><\/g:plusone><\/div>\n            <div class=\"wsbl_hatena_button\"><a href=\"\/\/b.hatena.ne.jp\/entry\/https:\/\/www.gigas-jp.com\/appnews\/archives\/10344\" class=\"hatena-bookmark-button\" data-hatena-bookmark-title=\"Flutter &#8211; Physical Model\" 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\/10344\" data-text=\"Flutter &#8211; Physical Model\" 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\/10344\" 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\/10344\" colorscheme=\"light\" ><\/fb:send><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>All of the best app start with a square, squarely in the middle of the screen. But to turn this abstract idea  [&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\/10344"}],"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=10344"}],"version-history":[{"count":11,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/10344\/revisions"}],"predecessor-version":[{"id":10377,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/10344\/revisions\/10377"}],"wp:attachment":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/media?parent=10344"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/categories?post=10344"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/tags?post=10344"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}