{"id":4436,"date":"2023-02-05T15:30:41","date_gmt":"2023-02-05T06:30:41","guid":{"rendered":"https:\/\/www.wsmeguro.jp\/wp\/?p=4436"},"modified":"2025-01-13T15:19:27","modified_gmt":"2025-01-13T06:19:27","slug":"flutter%e3%81%ae%e7%b7%b4%e7%bf%92%ef%bc%92","status":"publish","type":"post","link":"https:\/\/www.wsmeguro.jp\/wp\/?p=4436","title":{"rendered":"Flutter\u306e\u7df4\u7fd2\uff12"},"content":{"rendered":"<p>\u524d\u56de\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30a2\u30d7\u30ea\u306e\u30dc\u30bf\u30f3\u3092\u30c6\u30ad\u30b9\u30c8\u30dc\u30bf\u30f3\u306b\u5909\u3048\u3066\u3001\u30ea\u30bb\u30c3\u30c8\u3068\u30de\u30a4\u30ca\u30b9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<br \/>\n\u306a\u304a\u3001\u30ea\u30bb\u30c3\u30c8\u3092\u62bc\u3057\u305f\u3089\u3001\u30a2\u30e9\u30fc\u30c8\u30c0\u30a4\u30a2\u30ed\u30b0\u3092\u51fa\u3057\u3066\u78ba\u8a8d\u3057\u307e\u3059\u3002\u3067\u304d\u305f\u306e\u306f<a href=\"https:\/\/wsmeguro.jp\/demo\/flutter\/prac02\/#\/\" rel=\"noopener\" target=\"_blank\">\u3053\u3061\u3089<\/a>\u3002<br \/>\n1. \u6700\u521d\u306b\u95a2\u6570\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-js\" data-lang=\"JavaScript\"><code>void _decrementCounter() {\r\nsetState(() {\r\n_counter--;\r\n});\r\n}\r\n\r\nvoid _resetCounter() {\r\nsetState(() {\r\n_counter = 0;\r\n});\r\n}\r\n<\/code><\/pre>\n<\/div>\n<p>\uff12. \u30c6\u30ad\u30b9\u30c8\u30dc\u30bf\u30f3\u306f<a href=\"https:\/\/api.flutter.dev\/flutter\/material\/TextButton-class.html\" target=\"_blank\" rel=\"noopener\">\u672c\u5bb6\u306e\u30b5\u30a4\u30c8<\/a>\u3092\u53c2\u8003\u306b\u3057\u307e\u3057\u305f\u3002<br \/>\n\u307e\u305a\u3001FloatingActionButton\u3092\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\uff08\u6d88\u3057\u3066\u3082\u3044\u3044\u3067\u3059\uff09<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-js\" data-lang=\"JavaScript\"><code>\/\/ floatingActionButton: FloatingActionButton(\r\n\/\/ onPressed: _incrementCounter,\r\n\/\/ tooltip: 'Increment',\r\n\/\/ child: const Icon(Icons.add),\r\n\/\/ ), \/\/ This trailing comma makes auto-formatting nicer for build methods.\r\n<\/code><\/pre>\n<\/div>\n<p>\u7d9a\u3044\u3066\u3001\u30c6\u30ad\u30b9\u30c8\u30dc\u30bf\u30f3\u3092\uff13\u3064\u6a2a\u306b\u4e26\u3079\u307e\u3059\u3002\u672c\u5bb6\u306e\u30b5\u30a4\u30c8\u304b\u3089\u307b\u307c\u305d\u306e\u307e\u307e\u5f15\u7528\u3057\u3066\u307e\u3059\u3002Column\u3092Row\u306b\u5909\u3048\u305f\u611f\u3058\u3067\u3059\u3002<br \/>\n\u30ea\u30bb\u30c3\u30c8\u30dc\u30bf\u30f3\u306b\u306f\u30a2\u30e9\u30fc\u30c8\u30c0\u30a4\u30a2\u30ed\u30b0\u3092\u8868\u793a\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<a href=\"https:\/\/api.flutter.dev\/flutter\/material\/AlertDialog-class.html\" rel=\"noopener\" target=\"_blank\">\u672c\u5bb6\u306e\u30b5\u30a4\u30c8<\/a>\u304b\u3089\u5f15\u7528\u3057\u3066\u307e\u3059\u3002<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-dart\" data-lang=\"Dart\"><code>\r\n      body: Center(\r\n        child: Column(\r\n          mainAxisAlignment: MainAxisAlignment.center,\r\n          children: <Widget>[\r\n            const Text(\r\n              'You have pushed the button this many times:',\r\n            ),\r\n            const SizedBox(height: 30),\r\n            Text(\r\n              '$_counter',\r\n              style: Theme.of(context).textTheme.headlineMedium,\r\n            ),\r\n            const SizedBox(height: 30),\r\n            Row(\r\n              mainAxisAlignment: MainAxisAlignment.center,\r\n              children: [\r\n                TextButton(\r\n                  style: TextButton.styleFrom(\r\n                    textStyle:\r\n                        const TextStyle(fontSize: 20, color: Colors.blue),\r\n                  ),\r\n                  onPressed: _incrementCounter,\r\n                  child: const Text('PLUS'),\r\n                ),\r\n                const SizedBox(width: 30),\r\n                TextButton(\r\n                  style: TextButton.styleFrom(\r\n                    textStyle:\r\n                        const TextStyle(fontSize: 20, color: Colors.blue),\r\n                  ),\r\n                  onPressed: () => showDialog<String>( \/\/\u3053\u3053\u304b\u3089\u30a2\u30e9\u30fc\u30c8\u30c0\u30a4\u30a2\u30ed\u30b0\u3092\u8868\u793a\u3059\u308b\u30b3\u30fc\u30c9\r\n                    context: context,\r\n                    builder: (BuildContext context) => AlertDialog(\r\n                      title: const Text('AlertDialog'),\r\n                      content: const Text('RESET counter?'),\r\n                      actions: <Widget>[\r\n                        TextButton(\r\n                          onPressed: () => Navigator.pop(context, 'Cancel'),\r\n                          child: const Text('Cancel'),\r\n                        ),\r\n                        TextButton(\r\n                          onPressed: () => {\r\n                            setState(() {\r\n                              _resetCounter();\r\n                              Navigator.pop(context, 'OK');\r\n                            })\r\n                          },\r\n                          child: const Text('OK'),\r\n                        ),\r\n                      ],\r\n                    ),\r\n                  ),\r\n                  child: const Text('RESET'),\r\n                ),\r\n                const SizedBox(width: 30),\r\n                ClipRRect(\r\n                  borderRadius: BorderRadius.circular(4),\r\n                  child: Stack(\r\n                    children: <Widget>[\r\n                      Positioned.fill(\r\n                        child: Container(\r\n                          decoration: const BoxDecoration(\r\n                            gradient: LinearGradient(\r\n                              colors: <Color>[\r\n                                Color(0xFF0D47A1),\r\n                                Color(0xFF1976D2),\r\n                                Color(0xFF42A5F5),\r\n                              ],\r\n                            ),\r\n                          ),\r\n                        ),\r\n                      ),\r\n                      TextButton(\r\n                        style: TextButton.styleFrom(\r\n                          foregroundColor: Colors.white,\r\n                          padding: const EdgeInsets.all(16.0),\r\n                          textStyle: const TextStyle(fontSize: 20),\r\n                        ),\r\n                        onPressed: _decrementCounter,\r\n                        child: const Text('MINUS'),\r\n                      ),\r\n                    ],\r\n                  ),\r\n                ),\r\n              ],\r\n            ),\r\n          ],\r\n        ),\r\n      ),\r\n<\/code><\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u56de\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30a2\u30d7\u30ea\u306e\u30dc\u30bf\u30f3\u3092\u30c6\u30ad\u30b9\u30c8\u30dc\u30bf\u30f3\u306b\u5909\u3048\u3066\u3001\u30ea\u30bb\u30c3\u30c8\u3068\u30de\u30a4\u30ca\u30b9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002 \u306a\u304a\u3001\u30ea\u30bb\u30c3\u30c8\u3092\u62bc\u3057\u305f\u3089\u3001\u30a2\u30e9\u30fc\u30c8\u30c0\u30a4\u30a2\u30ed\u30b0\u3092\u51fa\u3057\u3066\u78ba\u8a8d\u3057\u307e\u3059\u3002\u3067\u304d\u305f\u306e\u306f\u3053\u3061\u3089\u3002 1. \u6700\u521d\u306b\u95a2\u6570\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002 void _&#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,665,505],"tags":[661,672],"class_list":["post-4436","post","type-post","status-publish","format-standard","hentry","category-flutter","category-textbutton","category-programming","tag-flutter"],"_links":{"self":[{"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=\/wp\/v2\/posts\/4436","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=4436"}],"version-history":[{"count":9,"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=\/wp\/v2\/posts\/4436\/revisions"}],"predecessor-version":[{"id":4451,"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=\/wp\/v2\/posts\/4436\/revisions\/4451"}],"wp:attachment":[{"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4436"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4436"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsmeguro.jp\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}