In JavaScript, I can use "in" operator to check a variable exists or not. So, maybe this code works correctly.
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Using in operator</title>
</head>
<body>
<div id="div1">hello</div>
<script>
document.someValue = "testValue";
if( 'someValue' in document ) {
document.getElementById('div1').innerHTML = document.someValue;
}else{
document.getElementById('div1').innerHTML = "not found";
}
</script>
</body>
</html>
As a result, The final content of div1 will be "testValue". However, Dart doesn't have "in" operator. In Dart, it is true that HtmlDocument class has contains() method. But, the argument type of the method is Node, not String. I also tried this code.
print( js.context['document'] );
print( js.context['document']['someValue'] );
" js.context['document'] " works well and returns instance of HtmlDocument object. However, " js.context['document']['someValue'] " totally does NOT work. This returns nothing or no error.
Is there any means to check variable existence in Dart? :-(
Thank you for reading!
document? If so, why? What's your real goal? - Ian