{"id":15490761,"url":"https://github.com/blaugold/widget_mask","last_synced_at":"2025-04-22T19:11:19.395Z","repository":{"id":48642902,"uuid":"382833965","full_name":"blaugold/widget_mask","owner":"blaugold","description":"Use a widget to mask and blend another widget, for example to imprint text onto surfaces.","archived":false,"fork":false,"pushed_at":"2022-06-12T23:30:27.000Z","size":3094,"stargazers_count":15,"open_issues_count":4,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T18:02:11.260Z","etag":null,"topics":["blend","flutter","mask","ui","widget"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/widget_mask","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/blaugold.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"blaugold"}},"created_at":"2021-07-04T11:25:06.000Z","updated_at":"2024-12-13T07:19:06.000Z","dependencies_parsed_at":"2022-08-24T10:01:05.013Z","dependency_job_id":null,"html_url":"https://github.com/blaugold/widget_mask","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blaugold%2Fwidget_mask","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blaugold%2Fwidget_mask/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blaugold%2Fwidget_mask/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blaugold%2Fwidget_mask/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blaugold","download_url":"https://codeload.github.com/blaugold/widget_mask/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250306638,"owners_count":21408926,"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":["blend","flutter","mask","ui","widget"],"created_at":"2024-10-02T07:23:40.608Z","updated_at":"2025-04-22T19:11:19.371Z","avatar_url":"https://github.com/blaugold.png","language":"Dart","funding_links":["https://github.com/sponsors/blaugold"],"categories":[],"sub_categories":[],"readme":"[![pub.dev package page](https://badgen.net/pub/v/widget_mask)](https://pub.dev/packages/widget_mask)\n[![GitHub Actions CI](https://github.com/blaugold/widget_mask/actions/workflows/CI.yaml/badge.svg)](https://github.com/blaugold/widget_mask/actions/workflows/ci.yml)\n[![GitHub Stars](https://badgen.net/github/stars/blaugold/widget_mask)](https://github.com/blaugold/widget_mask/stargazers)\n\nUse a widget to mask and blend another widget, for example to imprint text onto\nsurfaces.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg width=\"500\" src=\"https://raw.githubusercontent.com/blaugold/widget_mask/main/docs/images/example_screenshot.jpg?v=1\"\u003e\n\u003c/p\u003e\n\n---\n\nIf you're looking for a **database solution**, check out\n[`cbl`](https://pub.dev/packages/cbl), another project of mine. It brings\nCouchbase Lite to **standalone Dart** and **Flutter**, with support for:\n\n- **Full-Text Search**,\n- **Expressive Queries**,\n- **Data Sync**,\n- **Change Notifications**\n\nand more.\n\n---\n\n# Limitations\n\nWidgets that are used as children of `WidgetMask` or `SaveLayer` must not need\ncompositing, or contain widgets which need compositing, such as\n`RepaintBoundary`.\n\nThis is because this package makes use of save layers, which cannot encompass\ncompositing layers.\n\n# Masks and blending\n\nA mask is an image, which is positioned in front of another image and affects\nthis images in some way, where it is not empty.\n\nBlending is a process which takes two images and produces a new image by\napplying a mathematical function to each pair of pixels from the input images.\nFor some of these functions, the order of the arguments matters. That's why the\ninput images are labeled with `src` and `dst`. A mask is usually the image\nlabeled with `src`.\n\n# Getting started\n\nThe example below paints some text onto an image. The text is filled with the\nnegative of the image.\n\n```dart\nWidgetMask(\n  // `BlendMode.difference` results in the negative of `dst` where `src`\n  // is fully white. That is why the text is white.\n  blendMode: BlendMode.difference,\n  mask: Center(\n    child: Text(\n      'Negative',\n      style: TextStyle(\n        fontSize: 50,\n        color: Colors.white,\n      ),\n    ),\n  ),\n  child: Image.asset('images/my_image.jpg'),\n);\n```\n\n`WidgetMask` delegates to `child` to lay itself out. It always has the same size\nas `child`. `mask` is forced to adopt the same size as `child` and positioned on\ntop it.\n\nDuring hit testing `mask` is positioned over `child`.\n\nThe different `BlendMode`s use `src` and `dst` to describe how the colors of two\nimages are blended with each other. In the context of `WidgetMask` `mask` is the\n`src` and `child` the `dst`.\n\n# Examples\n\nThe `NegativeMaskedImageDemo` widget, in the\n[example app](https://pub.dev/packages/widget_mask/example), implements the\nimage at the top.\n\n# `SaveLayer`\n\nThis widget paints its child into a save layer and allows you to fully specify\nthe `Paint` to use with the save layer. If you need to use a custom `Paint` or\nrequire a different layout of the widgets, you can use `SaveLayer`.\n\n`WidgetMask` is implement using two `SaveLayer`s to blend the `mask` and\n`child`:\n\n```dart\n@override\nWidget build(BuildContext context) {\n  Widget child = Stack(\n    textDirection: TextDirection.ltr,\n    fit: StackFit.passthrough,\n    children: [\n      this.child,\n      Positioned.fill(\n        child: SaveLayer(\n          paint: Paint()..blendMode = blendMode,\n          child: mask,\n        ),\n      ),\n    ],\n  );\n\n  if (childSaveLayer) {\n    child = SaveLayer(\n      child: child,\n    );\n  }\n\n  return child;\n}\n```\n\n---\n\n**Gabriel Terwesten** \u0026bullet; **GitHub**\n**[@blaugold](https://github.com/blaugold)** \u0026bullet; **Twitter**\n**[@GTerwesten](https://twitter.com/GTerwesten)** \u0026bullet; **Medium**\n**[@gabriel.terwesten](https://medium.com/@gabriel.terwesten)**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblaugold%2Fwidget_mask","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblaugold%2Fwidget_mask","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblaugold%2Fwidget_mask/lists"}