i'm trying to use html parsing with dart in a Flutter App:
Future getSomething() async {
http.Response response = await http.get('https://news.ycombinator.com/');
Document document = parser.parse(response.body);
document.getElementsByTagName('a').forEach((Element element){
print(element.text);
});
}
But i have an error in (Element element) :
Compiler message: lib/main.dart:7:1: Error: 'Element' is imported from both 'package:flutter/src/widgets/framework.dart' and 'package:html/dom.dart'.
You can hide Element from the flutter import:
import 'package:flutter/widgets.dart' hide Element;
You can also use alias:
import 'package:flutter/widgets.dart' as widgets;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With