Sdk: Platform.isLinux and company should be const

Created on 18 Jan 2019  路  6Comments  路  Source: dart-lang/sdk

We'd like to have code that does something like this:

// these are giant maps
const Map mac = {...};
const Map windows = {...};
const Map linux = {...};

convert(foo) {
  if (Platform.isMac)
    return mac[foo];
  if (Platform.isLinux)
    return linux[foo];
  if (Platform.isWindows)
    return windows[foo];
  return null;
}

We only want to ship the maps that apply to the current platform; we'd like the others to tree-shake out.

P2 area-library library-io type-enhancement

Most helpful comment

Hi. I'm the new maintainer of dart:io. I actually ran into this issue the other day, I agree it would be nice for them to be const.

All 6 comments

cc @gspencergoog

Hi. I'm the new maintainer of dart:io. I actually ran into this issue the other day, I agree it would be nice for them to be const.

Seems to be related to #31969

Any idea on where this issue is in the priorities for the SDK? This would be pretty useful, especially now that flutter is expanding to more platforms.

Hi Greg. I'm hoping to do some work on this issue this quarter so flutter for web is better supported. I'm writing up a plan and will be sharing it.

@sortie Please re-evaluate this and do one of the following:

  1. Add it to a milestone if it is still P1
  2. Change priority label and add milestone if no longer P1
  3. Close, if this issue is no longer needed
Was this page helpful?
0 / 5 - 0 ratings