{"id":4473,"date":"2023-02-12T20:42:17","date_gmt":"2023-02-12T11:42:17","guid":{"rendered":"https:\/\/www.wsmeguro.jp\/wp\/?p=4473"},"modified":"2025-01-17T16:13:15","modified_gmt":"2025-01-17T07:13:15","slug":"flutter%e3%81%ae%e7%b7%b4%e7%bf%92%ef%bc%9a%e3%83%ac%e3%82%b9%e3%83%9d%e3%83%b3%e3%82%b7%e3%83%96%e3%83%ab","status":"publish","type":"post","link":"https:\/\/www.wsmeguro.jp\/wp\/?p=4473","title":{"rendered":"flutter\u306e\u7df4\u7fd2\uff14\uff1a\u30ec\u30b9\u30dd\u30f3\u30b7\u30d6\u30eb"},"content":{"rendered":"<p>\u672c\u5bb6\u306e<a href=\"https:\/\/docs.flutter.dev\/development\/ui\/layout\/adaptive-responsive\" rel=\"noopener\" target=\"_blank\">\u30b5\u30a4\u30c8\u306e\u7d9a\u304d<\/a>\u3092\u3084\u3063\u3066\u3044\u307e\u3059\u3002\u7d9a\u304d\u306f\u30ec\u30b9\u30dd\u30f3\u30b7\u30d6\u30eb\u306fLayout builder\u3067\u3084\u308b\u3068\u3042\u308a\u307e\u3059\u3002\u3061\u3087\u3063\u3068\u5909\u3048\u3066\u3067\u304d\u305f\u306e\u306f<a href=\"https:\/\/wsmeguro.jp\/demo\/flutter\/prac05\/#\/\" rel=\"noopener\" target=\"_blank\">\u3053\u3061\u3089<\/a>\u3002<br \/>\n\u5e45\u304c\uff16\uff10\uff10\u3088\u308a\u3082\u5927\u304d\u3051\u308c\u3070 _buildWideContainers;\u3000\u5c0f\u3055\u3051\u308c\u3070 _buildNormalContainer\u304c\u547c\u3073\u51fa\u3055\u308c\u308b\u4ed5\u7d44\u307f\u3067\u3059\u3002<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-dart\" data-lang=\"Dart\"><code>\r\nimport 'package:flutter\/material.dart';\r\n\r\nvoid main() => runApp(const MyApp());\r\n\r\nclass MyApp extends StatelessWidget {\r\n  const MyApp({super.key});\r\n\r\n  static const String _title = 'Flutter Code Sample';\r\n\r\n  @override\r\n  Widget build(BuildContext context) {\r\n    return const MaterialApp(\r\n      title: _title,\r\n      home: MyStatelessWidget(),\r\n    );\r\n  }\r\n}\r\n\r\nclass MyStatelessWidget extends StatelessWidget {\r\n  const MyStatelessWidget({super.key});\r\n\r\n  @override\r\n  Widget build(BuildContext context) {\r\n    return Scaffold(\r\n      appBar: AppBar(title: const Text('LayoutBuilder Example')),\r\n      body: LayoutBuilder(\r\n        builder: (BuildContext context, BoxConstraints constraints) {\r\n          if (constraints.maxWidth > 600) {\r\n            return _buildWideContainers();\r\n          } else {\r\n            return _buildNormalContainer();\r\n          }\r\n        },\r\n      ),\r\n    );\r\n  }\r\n\r\n  Widget _buildNormalContainer() {\r\n    return Center(\r\n      child: Column(\r\n        mainAxisAlignment: MainAxisAlignment.spaceEvenly,\r\n        children: <Widget>[\r\n          Container(\r\n            height: 100.0,\r\n            width: 100.0,\r\n            color: Colors.red,\r\n          ),\r\n          Container(\r\n            height: 100.0,\r\n            width: 100.0,\r\n            color: Colors.yellow,\r\n          ),\r\n          Container(\r\n            height: 100.0,\r\n            width: 100.0,\r\n            color: Colors.blue,\r\n          ),\r\n        ],\r\n      ),\r\n    );\r\n  }\r\n\r\n  Widget _buildWideContainers() {\r\n    return Center(\r\n      child: Row(\r\n        mainAxisAlignment: MainAxisAlignment.spaceEvenly,\r\n        children: <Widget>[\r\n          Container(\r\n            height: 100.0,\r\n            width: 100.0,\r\n            color: Colors.amber,\r\n          ),\r\n          Container(\r\n            height: 100.0,\r\n            width: 100.0,\r\n            color: Colors.green,\r\n          ),\r\n        ],\r\n      ),\r\n    );\r\n  }\r\n}\r\n<\/code><\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u5bb6\u306e\u30b5\u30a4\u30c8\u306e\u7d9a\u304d\u3092\u3084\u3063\u3066\u3044\u307e\u3059\u3002\u7d9a\u304d\u306f\u30ec\u30b9\u30dd\u30f3\u30b7\u30d6\u30eb\u306fLayout builder\u3067\u3084\u308b\u3068\u3042\u308a\u307e\u3059\u3002\u3061\u3087\u3063\u3068\u5909\u3048\u3066\u3067\u304d\u305f\u306e\u306f\u3053\u3061\u3089\u3002 \u5e45\u304c\uff16\uff10\uff10\u3088\u308a\u3082\u5927\u304d\u3051\u308c\u3070 _buildWideContainers;\u3000\u5c0f\u3055\u3051\u308c\u3070 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"categories":[603,670,505],"tags":[661,672],"class_list":["post-4473","post","type-post","status-publish","format-standard","hentry","category-flutter","category-layoutbuilder","category-programming","tag-flutter"],"_links":{"self":[{"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=\/wp\/v2\/posts\/4473","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4473"}],"version-history":[{"count":4,"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=\/wp\/v2\/posts\/4473\/revisions"}],"predecessor-version":[{"id":4569,"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=\/wp\/v2\/posts\/4473\/revisions\/4569"}],"wp:attachment":[{"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}