{"id":61,"date":"2026-04-25T08:45:55","date_gmt":"2026-04-24T23:45:55","guid":{"rendered":"https:\/\/tate.stars.ne.jp\/wpb\/?p=61"},"modified":"2026-04-25T08:55:08","modified_gmt":"2026-04-24T23:55:08","slug":"rivercount","status":"publish","type":"post","link":"https:\/\/tate.stars.ne.jp\/wpb\/rivercount.html","title":{"rendered":"Rivercount"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>\nmain.dart\nimport 'package:flutter\/material.dart';\nimport 'package:flutter_riverpod\/flutter_riverpod.dart';\n\nclass CounterNotifier extends Notifier&lt;int&gt; {\n  @override\n  int build() =&gt; 0;\n  void increment() =&gt; state++;\n  void decrement() =&gt; state--;\n  void reset() =&gt; state = 0;\n\/\/ void increment() {\n\/\/ state = state + 1;\n \/\/ }\n}\n\nfinal counterProvider = NotifierProvider&lt;CounterNotifier, int&gt;(() {\n  return CounterNotifier();\n});\n\nvoid main() {\nrunApp(\n const ProviderScope(\n child: MyApp(),\n ),\n);\n}\n\nclass MyApp extends StatelessWidget {\n const MyApp({super.key});\n @override\n  Widget build(BuildContext context) {\n   return const MaterialApp(\n   home: MyHomePage(title: 'Flutter Count Home Page'),\n  );\n }\n}\n\nclass MyHomePage extends ConsumerWidget {\n  const MyHomePage({super.key, required this.title});\n  final String title;\n@override\nWidget build(BuildContext context, WidgetRef ref) {\n final counter = ref.watch(counterProvider);\n return Scaffold(\n appBar: AppBar(\n backgroundColor: Theme.of(context).colorScheme.inversePrimary,\n   title: Text(title),\n ),\nbody: Center(\nchild: Column(\n mainAxisAlignment: MainAxisAlignment.center,\n children: &lt;Widget&gt;&#91;\n  const Text(\n  'You have pushed the button Count',\n     ),\n  Text(\n  '$counter', style: const TextStyle(fontSize: 98),\n  ),\n  ],\n ),\n ),\n floatingActionButton: Column(\n  mainAxisAlignment: MainAxisAlignment.end,\n  children: &#91;\n  FloatingActionButton(\n onPressed: () =&gt; ref.read(counterProvider.notifier).increment(),\n    child: const Icon(Icons.add),\n  ),\n  const SizedBox(height: 5),\n  FloatingActionButton(\n  onPressed: () =&gt; ref.read(counterProvider.notifier).decrement(),\n  child: const Icon(Icons.remove),\n  ),\n const SizedBox(height: 20),\n  FloatingActionButton(\n   onPressed: () =&gt; ref.read(counterProvider.notifier).reset(),\n   child: const Icon(Icons.refresh),\n   ),  \n  ],\n ),\n);\n}\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":66,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"saved_in_kubio":false,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-61","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dart"],"_links":{"self":[{"href":"https:\/\/tate.stars.ne.jp\/wpb\/wp-json\/wp\/v2\/posts\/61","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tate.stars.ne.jp\/wpb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tate.stars.ne.jp\/wpb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tate.stars.ne.jp\/wpb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tate.stars.ne.jp\/wpb\/wp-json\/wp\/v2\/comments?post=61"}],"version-history":[{"count":1,"href":"https:\/\/tate.stars.ne.jp\/wpb\/wp-json\/wp\/v2\/posts\/61\/revisions"}],"predecessor-version":[{"id":62,"href":"https:\/\/tate.stars.ne.jp\/wpb\/wp-json\/wp\/v2\/posts\/61\/revisions\/62"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tate.stars.ne.jp\/wpb\/wp-json\/wp\/v2\/media\/66"}],"wp:attachment":[{"href":"https:\/\/tate.stars.ne.jp\/wpb\/wp-json\/wp\/v2\/media?parent=61"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tate.stars.ne.jp\/wpb\/wp-json\/wp\/v2\/categories?post=61"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tate.stars.ne.jp\/wpb\/wp-json\/wp\/v2\/tags?post=61"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}