Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom tag callback #2

Closed
Sub6Resources opened this issue Aug 15, 2018 · 4 comments
Closed

Add custom tag callback #2

Sub6Resources opened this issue Aug 15, 2018 · 4 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@Sub6Resources
Copy link
Owner

Some use cases may require custom tags to be rendered. Add a callback to the main Html widget that is called every time an unknown element is encountered. The programmer can then return their own widget for their custom elements.

@Sub6Resources Sub6Resources added the enhancement New feature or request label Aug 15, 2018
@Sub6Resources Sub6Resources added this to the 1.0.0 milestone Aug 15, 2018
@Sub6Resources Sub6Resources self-assigned this Aug 15, 2018
@Sub6Resources
Copy link
Owner Author

Here is an example of what the callback might look like:

Html(
  data: myHtmlWithCustomTags,
  customTagCallback: ((element) {
    switch(element.localName) {
      case "my-custom-tag":
        return MyWidget(
          text: "Lorem ipsum dolor sit amet",
          onPressed: (() {
            //...
          }),
        );
    }
    return Container();
  }),
)

@Sub6Resources
Copy link
Owner Author

Also, the callback would be able to override a tag and add its own implementation (as in #21 ):

Html(
  data: myHtml,
  customTagCallback: ((element) {
    switch(element.localName) {
      case "code":
        return MyCustomCodeWidget(
          code: element.innerHTML,
        );
    }
    return Container();
  }),
)

@Sub6Resources
Copy link
Owner Author

This is currently being added in #23 and will likely be added as version 0.7.2

@Sub6Resources
Copy link
Owner Author

Added in version 0.8.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant