Skip to content

Add example of using HtmlElementView.fromTagName to flutter.dev #140100

@srujzs

Description

@srujzs

HtmlElementView.fromTagName currently has the following example in its dartdoc:

 import 'package:flutter/widgets.dart';
 import 'package:web/web.dart' as web;

 // ...

 class MyWidget extends StatelessWidget {
  const MyWidget({super.key});

  @override
  Widget build(BuildContext context) {
    return HtmlElementView.fromTagName(
     tagName: 'div',
     onElementCreated: (Object element) {
        element as web.HTMLElement;
       element.style
           ..backgroundColor = 'blue'
            ..border = '1px solid red';
     },
    );
  }
}

/// Creates a platform view that creates a DOM element specified by [tagName].

#139696 is planning on removing the dependency to package:web in Flutter, so while the above code example is valid, it does not pass analysis as Flutter no longer depends on package:web. This example should now instead move to flutter.dev once that PR removes it from the dartdoc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listd: api docsIssues with https://api.flutter.dev/frameworkflutter/packages/flutter repository. See also f: labels.team-webOwned by Web platform teamtriaged-webTriaged by Web platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions