{"id":4568,"date":"2025-01-17T17:36:49","date_gmt":"2025-01-17T08:36:49","guid":{"rendered":"https:\/\/www.wsmeguro.jp\/wp\/?p=4568"},"modified":"2025-01-17T17:37:23","modified_gmt":"2025-01-17T08:37:23","slug":"flutter%e3%81%ae%e7%b7%b4%e7%bf%923-2%ef%bc%9awidget%e9%9b%86%e3%82%92%e4%bd%9c%e6%88%90","status":"publish","type":"post","link":"https:\/\/www.wsmeguro.jp\/wp\/?p=4568","title":{"rendered":"Flutter\u306e\u7df4\u7fd23-2\uff1aWidget\u96c6\u3092\u4f5c\u6210"},"content":{"rendered":"<p>ChatGTP\u5148\u751f\u306bFlutter\u306fWidget\u304c\u8907\u96d1\u306b\u7d44\u307f\u5408\u308f\u305b\u3089\u308c\u3066\u3044\u308b\u306e\u3067\u3001\u53ef\u8aad\u6027\u3092\u4e0a\u3052\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u805e\u3044\u305f\u3068\u3053\u308d\u3001Widget\u3092\u5225\u30d5\u30a1\u30a4\u30eb\u306b\u3059\u308b\u3053\u3068\u3092\u52e7\u3081\u3089\u308c\u307e\u3057\u305f\u3002<br \/>\nFlutter\u306e\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u30dc\u30bf\u30f3\u306a\u3069\u3092\u8ffd\u52a0\u3057\u305f\u969b\u306b\u3001lib\/widget\/\u306e\u4e2d\u306bmy_buttons.dart\u3068my_row_column.dart\u3092\u4f5c\u6210\u3057\u3001\u305d\u306e\u4e2d\u306bWidget\u3092\u6574\u7406\u3057\u307e\u3057\u305f\u3002<a href=\"https:\/\/github.com\/wsmeguro\/flutter_prac03-2\" target=\"_blank\">\u3053\u3061\u3089<\/a>\u3092\u3054\u53c2\u7167<br \/>\n\u3053\u308c\u304b\u3089\u3001\u3053\u306eWidget\u3092\u30de\u30a4Widget\u96c6\u3068\u3057\u3066\u5145\u5b9f\u3055\u305b\u3066\u3044\u3053\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-dart\" data-lang=\"Dart\">\r\n=my_buttons.dart=\r\nimport 'package:flutter\/material.dart';\r\n\r\nclass MyFloatingActionButton extends StatelessWidget {\r\n  final Color color;\r\n  final IconData icon;\r\n  final String tooltip;\r\n  final VoidCallback onPressed;\r\n\r\n  \/\/ \u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u53d7\u3051\u53d6\u308b\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\r\n  const MyFloatingActionButton({\r\n    super.key,\r\n    required this.color,\r\n    required this.icon,\r\n    required this.tooltip,\r\n    required this.onPressed,\r\n  });\r\n\r\n  @override\r\n  Widget build(BuildContext context) {\r\n    return FloatingActionButton(\r\n      onPressed: onPressed, \/\/ \u547c\u3073\u51fa\u3057\u5143\u3067\u6307\u5b9a\u3057\u305f\u95a2\u6570\u3092\u5b9f\u884c\r\n      backgroundColor: color, \/\/ \u30dc\u30bf\u30f3\u306e\u80cc\u666f\u8272\r\n      tooltip: tooltip, \/\/ \u30c4\u30fc\u30eb\u30c1\u30c3\u30d7\r\n      child: Icon(icon), \/\/ \u30dc\u30bf\u30f3\u306e\u30a2\u30a4\u30b3\u30f3\r\n    );\r\n  }\r\n}\r\n\r\n=main.dart\u306e\u547c\u3073\u51fa\u3057\u90e8\u5206=\r\nimport 'widget\/my_buttons.dart' as mbtn;\r\n\u30fb\r\n\u30fb\r\n      \/\/ #region FloatingActionButton\r\n      floatingActionButton: Row(\r\n        mainAxisAlignment: MainAxisAlignment.start,\r\n        children: <Widget>[\r\n          const SizedBox(width: 30),\r\n          mbtn.MyFloatingActionButton(\r\n            color: Colors.pink,\r\n            icon: Icons.remove,\r\n            onPressed: _decrementCounter,\r\n            tooltip: 'Decrement',\r\n          ),\r\n          const Spacer(),\r\n          mbtn.MyElevatedButton(\r\n              name: \"\u521d\u671f\u5316\",\r\n              tooltip: \"Reset\",\r\n              onPressed: _initializeCounter,\r\n              fontSize: 20),\r\n          const Spacer(),\r\n          mbtn.MyFloatingActionButton(\r\n            color: Colors.green, \/\/ \u80cc\u666f\u8272\r\n            icon: Icons.add, \/\/ \u30a2\u30a4\u30b3\u30f3\r\n            tooltip: 'Increment', \/\/ \u30c4\u30fc\u30eb\u30c1\u30c3\u30d7\r\n            onPressed: _incrementCounter, \/\/ \u5b9f\u884c\u3059\u308b\u95a2\u6570\r\n          ),\r\n        ],\r\n      ), \/\/ This trailing comma makes auto-formatting nicer for build methods.\r\n      \/\/ #endregion FloatingActionButton\r\n<\/pre>\n<\/div>\n<p>import\u3059\u308b\u969b\u306b\u3001&#8221;as mbtn&#8221;\u3092\u5165\u308c\u3066\u3044\u307e\u3059\u304c\u3001\u306a\u304f\u3066\u3082\u5927\u4e08\u592b\u3067\u3059\u3002\u305f\u3060\u3057\u3001\u3042\u3063\u305f\u65b9\u304c\u308f\u304b\u308a\u3084\u3059\u3044\u3068\u601d\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n\u3067\u304d\u305f\u3082\u306e\u306f<a href=\"https:\/\/wsmeguro.jp\/demo\/flutter\/prac03-2\/\" target=\"_blank\">\u3053\u3061\u3089<\/a>\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ChatGTP\u5148\u751f\u306bFlutter\u306fWidget\u304c\u8907\u96d1\u306b\u7d44\u307f\u5408\u308f\u305b\u3089\u308c\u3066\u3044\u308b\u306e\u3067\u3001\u53ef\u8aad\u6027\u3092\u4e0a\u3052\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u805e\u3044\u305f\u3068\u3053\u308d\u3001Widget\u3092\u5225\u30d5\u30a1\u30a4\u30eb\u306b\u3059\u308b\u3053\u3068\u3092\u52e7\u3081\u3089\u308c\u307e\u3057\u305f\u3002 Flutter\u306e\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u30dc\u30bf\u30f3\u306a&#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,669,505],"tags":[661,672],"class_list":["post-4568","post","type-post","status-publish","format-standard","hentry","category-flutter","category-widget","category-programming","tag-flutter"],"_links":{"self":[{"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=\/wp\/v2\/posts\/4568","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=4568"}],"version-history":[{"count":1,"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=\/wp\/v2\/posts\/4568\/revisions"}],"predecessor-version":[{"id":4586,"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=\/wp\/v2\/posts\/4568\/revisions\/4586"}],"wp:attachment":[{"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4568"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4568"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4568"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}