{"id":22771521,"url":"https://github.com/nivisi/notification_builder","last_synced_at":"2026-04-09T12:57:44.824Z","repository":{"id":61579925,"uuid":"552696289","full_name":"nivisi/notification_builder","owner":"nivisi","description":"🦻 A widget that builds using notifications dispatched via the build context.","archived":false,"fork":false,"pushed_at":"2022-10-19T05:08:44.000Z","size":75,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-02-05T13:51:24.677Z","etag":null,"topics":["build","buildcontext","context","dart","flutter","library","notification","package","plugin","ui","widget"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/notification_builder","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nivisi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-10-17T04:48:35.000Z","updated_at":"2022-10-17T07:42:16.000Z","dependencies_parsed_at":"2022-10-19T13:15:16.868Z","dependency_job_id":null,"html_url":"https://github.com/nivisi/notification_builder","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nivisi%2Fnotification_builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nivisi%2Fnotification_builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nivisi%2Fnotification_builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nivisi%2Fnotification_builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nivisi","download_url":"https://codeload.github.com/nivisi/notification_builder/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246314149,"owners_count":20757463,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["build","buildcontext","context","dart","flutter","library","notification","package","plugin","ui","widget"],"created_at":"2024-12-11T16:14:06.464Z","updated_at":"2025-12-30T23:16:28.694Z","avatar_url":"https://github.com/nivisi.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# notification_builder [![pub version][pub-version-img]][pub-version-url]\n\n🦻 A widget that builds using notifications dispatched via the build context.\n\n### Table of contents\n - [About](#about)\n   - [The problem](#the-problem)\n   - [The solution](#the-solution)\n   - [Result](#result)\n   - [If you don't want certain notification to trigger rebuilds...](#if-you-dont-want-certain-notification-to-trigger-rebuilds)\n - [Getting started](#getting-started)\n   - [pub](#pub)\n   - [Import](#import)\n\n## About\n\nNotifications — is a tool Flutter uses to pass the data higher in the widget tree hierarchy. Somewhere in depth of your widget tree you can fire a notification and it will go up, like a bubble. And on top, you can catch it using a `NotificationBuilder` to build your UI.\n\n### The problem\n\nImagine the following widget tree:\n\n```dart\nMyWidget(\n  color: // I want this to be changed once the button below is clicked!\n  child: const SomeChild(\n    child: AnotherChild(\n      // More and more widgets...\n      child: ChildWithTheButton(),\n    ),\n  ),  \n);\n\nclass ChildWithTheButton extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return TextButton(\n      title: 'Change colour',\n      onPressed: // Here! I want the colour to be changed on this button pressed!\n    );\n  }\n}\n```\n\nYou could either pass something like a `ChangeNotifier\u003cColor\u003e`, or pass a callback function to set the state, or even use an `InheritedWidget`. Another option is to use a `NotificationListener`.\n\n### The solution\n\n---\n\n\u003e 💡 [Click here](https://github.com/nivisi/notification_builder/blob/develop/src/example/lib/main.dart) to check out the full example.\n\n---\n\nDefine your notification:\n```dart\nclass ColorNotification extends Notification {\n  const ColorNotification(this.color);\n\n  final Color color;\n}\n```\n\nUse a NotificationBuilder to catch notifications:\n```dart\n// MyWidget\nNotificationBuilder\u003cColorNotification\u003e(\n  builder: (context, notification, child) {\n    // Note: the notification parameter will be null at the very first build.\n    // Use a fallback value like this.\n    final color = notification?.color ?? Colors.white;\n\n    return AnimatedContainer(\n      duration: const Duration(milliseconds: 200),\n      curve: Curves.fastOutSlowIn,\n      decoration: BoxDecoration(color: color),\n      child: child,\n    );\n  },\n  child: const SomeChild(...),\n),\n```\n\nFire notifications from the widget tree below the builder:\n```dart\nonPressed: () {\n  ColorNotification(color).dispatch(context);\n},\n```\n\n### Result\n\n\u003cimg width=300 src=\"https://user-images.githubusercontent.com/33932162/196101537-e3330376-f65c-45db-9101-f69396518437.gif\"/\u003e\n\n### If you don't want certain notification to trigger rebuilds...\n\nThen you can use the `buildWhen` parameter!\n\n```dart\nbuildWhen: (notification) {\n  // Now if the passed notification will have a red color it will be ignored!\n  return notification.color != Colors.red;\n}\n```\n\n## Getting started\n\n### pub\n\nAdd the package to `pubspec.yaml`:\n\n```\ndependencies:\n  notification_builder:\n```\n\n### Import\n\nAdd the dependency to your file:\n\n```dart\nimport 'package:notification_builder/notification_builder.dart';\n```\n\n\u003c!-- References --\u003e\n[pub-version-img]: https://img.shields.io/badge/pub-v0.0.1-0175c2?logo=flutter\n[pub-version-url]: https://pub.dev/packages/notification_builder\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnivisi%2Fnotification_builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnivisi%2Fnotification_builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnivisi%2Fnotification_builder/lists"}