How to get the content of another page/handler in Dart

Today I spent quite a long time on this, about 2 hours. I kept trying the static methods of the dart:html.HttpRequest class, but no matter what I did, I just couldn’t get the content of the page or handler, whether I tried the asStream or getString methods followed by then() or other methods – everything was asynchronous, which is what I hate the most. So in the end I looked into my existing Dart programs and found this code there:

DART
String response = "";
html.HttpRequest request = new html.HttpRequest();
request.open("GET", uri, async: false);
request.send();
response = request.responseText;

And that saved me. Maybe it’s because Dart isn’t yet second nature to me the way C#/.NET is, and I’m used to something completely different, but Dart seems totally chaotic and confusing to me. But that will get better with time.

Categories

Leave a Reply