{"id":10900,"date":"2021-11-05T10:00:00","date_gmt":"2021-11-05T01:00:00","guid":{"rendered":"https:\/\/www.gigas-jp.com\/appnews\/?p=10900"},"modified":"2021-11-04T20:12:58","modified_gmt":"2021-11-04T11:12:58","slug":"lets-build-flutter-rotatedbox-with-me","status":"publish","type":"post","link":"https:\/\/www.gigas-jp.com\/appnews\/archives\/10900","title":{"rendered":"Let&#8217;s build flutter RotatedBox with me!"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" src=\"https:\/\/www.gigas-jp.com\/appnews\/wp-content\/uploads\/sites\/4\/2021\/11\/Screenshot_1636014142.png\" alt=\"\" class=\"wp-image-10901\" width=\"263\" height=\"556\" \/><\/figure>\n\n\n\n<p>Sometimes we may try our design horizontal or 90 degree for a bit more interesting layout. If you want to do that, Flutter has answered. Just use <strong>RotatedBox<\/strong>.<\/p>\n\n\n\n<p>RotatedBox has provided a child and a number of quarter turns you want to rotate. One quarter to 90 degree turns. <\/p>\n\n\n\n<p>So,<\/p>\n\n\n\n<p>If we set 1 quarter, that will turn to 90 degree.<\/p>\n\n\n\n<p>If we set 2 quarter, that will turn to 180 degree <\/p>\n\n\n\n<p>If we set 3 quarter, that will turn to 270 degree<\/p>\n\n\n\n<p>If we set 4 quarter, that will turn to 360 degree.<\/p>\n\n\n\n<p>If we use 5 quarter, that will turn to 90 degree again.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>RotatedBox(\nquarterTurns : 3,\nchild: MyWidget(),\n)<\/code><\/pre>\n\n\n\n<p> Let&#8217;s build example with RotatedBox.<\/p>\n\n\n\n<p>Firstly, add assets image to pubspec.yaml file. After adding image assets, run flutter pub get.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>assets:\n  - assets\/<\/code><\/pre>\n\n\n\n<p>Second step is  in your main.dart file, that&#8217;s need to create a rotated box. Inside a <strong>RotatedBox<\/strong>() widget, we will call quarterTurns and a child.<\/p>\n\n\n\n<p>Inside a child, we will add inside a ClipPath and his child&#8217;s property with image. The result will be underneath screen capture.<\/p>\n\n\n\n<p>Example code :<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">return Scaffold(\n  backgroundColor: Colors.<em>grey<\/em>[100],\n  appBar: AppBar(\n    title: const Text(\"Rotated Box\"),\n    backgroundColor: Colors.<em>blueGrey<\/em>[800],\n\n  ),\n  body: const Center(\n      child: RotatedBox(\n          quarterTurns: 5,\n          child: ClipPath(\n              child: Image(\n                image: AssetImage(\"assets\/logo.png\"),\n                fit: BoxFit.contain,\n                height: 200,\n\n              )\n\n          )\n      )\n  ),\n);\n\n<\/pre>\n\n\n\n<p>Hoped you enjoyed with 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\/10900\" ><\/g:plusone><\/div>\n            <div class=\"wsbl_hatena_button\"><a href=\"\/\/b.hatena.ne.jp\/entry\/https:\/\/www.gigas-jp.com\/appnews\/archives\/10900\" class=\"hatena-bookmark-button\" data-hatena-bookmark-title=\"Let&#8217;s build flutter RotatedBox with me!\" 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\/10900\" data-text=\"Let&#8217;s build flutter RotatedBox with me!\" 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\/10900\" 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\/10900\" colorscheme=\"light\" ><\/fb:send><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes we may try our design horizontal or 90 degree for a bit more interesting layout. If you want to do t [&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\/10900"}],"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=10900"}],"version-history":[{"count":4,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/10900\/revisions"}],"predecessor-version":[{"id":10909,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/10900\/revisions\/10909"}],"wp:attachment":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/media?parent=10900"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/categories?post=10900"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/tags?post=10900"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}