matanlurey matanlurey -4 years ago 154
Dart Question

Resolve a version from stable/dev channel of the Dart SDK

Is there some shared/simple logic to implement something like:

Future<Version> getLatestStable();

Future<Version> getLatestDev();

Just curious. I'd rather not parse the download page. I guess another option would be releasing either a feed.json or feed.xml as part of the website to make it easier for tools.

Answer Source

In Dart Code I pull the version from

I think I took this from the source of the Dart downloads page and it's been stable since I implemented it, so should be good to use!

Here's my (TypeScript) code that pulls it:

export function getLatestSdkVersion(): PromiseLike<string> {
    return new Promise<string>((resolve, reject) => {
        const options: https.RequestOptions = {
            hostname: "",
            port: 443,
            path: "/dart-archive/channels/stable/release/latest/VERSION",
            method: "GET",

        let req = https.request(options, resp => {
            if (resp.statusCode < 200 || resp.statusCode > 300) {
                reject({ message: `Failed to get Dart SDK Version ${resp.statusCode}: ${resp.statusMessage}` });
            } else {
                resp.on('data', (d) => {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download