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 scoped name slot support for Flutter Widget Element. #88

Open
andycall opened this issue Oct 21, 2022 · 0 comments
Open

Add scoped name slot support for Flutter Widget Element. #88

andycall opened this issue Oct 21, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@andycall
Copy link
Member

andycall commented Oct 21, 2022

For Flutter widget elements, we can add any HTML elements as children of widget elements:

Exp:

<flutter-button>
    <div>helloworld</div>
</flutter-button>
@override
  Widget build(BuildContext context, List<Widget> children) {
    return ConstrainedBox(
      constraints:
          BoxConstraints.tightFor(width: renderStyle.width.computedValue, height: renderStyle.height.computedValue),
      child: RoundedLoadingButton(
        borderRadius: 4,
          controller: controller, onPressed: () {
            _isLoading = true;
            dispatchEvent(MouseEvent(EVENT_CLICK, detail: 1, view: ownerDocument.defaultView));
      }, child: children.isNotEmpty ? children[0] : const SizedBox.shrink()),
    );
  }

But we can only put these HTML childrens in one place in our widget tree.

Now if we wants to implement a tab bar element with Flutter widgets, and we wants to use HTML tags to implement tab bar's header and body. We needs pass two chunk of HTML tags in to element, but we only have one place.

The WebComponent standard defined named slot can solve these problems: https://javascript.info/slots-composition#named-slots

And we can use for reference it to solve this problems.

Alternatives and Workarounds
No response

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