since dart:html cannot be used in the backend and several use cases for this package, to analyze html files to obtain certain text, web crawler, Generating HTML etc
Example
import 'package:html/parser.dart' as parser;
import 'package:html/dom.dart';
void main() {
// Example HTML string
String htmlString = '''
<html>
<body>
<div>Inscrição Estadual: 123456789</div>
<div>Other content</div>
</body>
</html>
''';
// Parse the HTML string
Document document = parser.parse(htmlString);
// Find the tag containing 'Inscrição Estadual'
Element? tag = document.querySelector('body')?.children.firstWhere(
(element) => element.text.contains('Inscrição Estadual'),
);
// Print the found tag or a message if not found
if (tag != null) {
print('Found tag: ${tag.outerHtml}');
} else {
print('Tag with "Inscrição Estadual" not found.');
}
}
Add support for package html https://pub.dev/packages/html
since dart:html cannot be used in the backend and several use cases for this package, to analyze html files to obtain certain text, web crawler, Generating HTML etc
Example