以下のように dart:html は Windows では使わないのにビルドするとエラーになります。
import 'dart:html' as html;
function() {
if (!Platform.isWindows) {
String hostname = html.window.location.hostname;
}
}
エラー文
Dart library 'dart:html' is not available on this platform.
対処法
ダミーのファイル (win_html.dart) を作ります。
win_html.dart
class window {
static Map<String, String> sessionStorage = {};
static _location location = _location();
}
class _location {
String hostname = '';
}
Windowsのときだけダミーファイルをimportします。これでビルドができるようになります。
import 'win_html.dart' if (dart.library.html) 'dart:html' as html;
function() {
if (!Platform.isWindows) {
String hostname = html.window.location.hostname;
}
}
ios,androidのシミュレーターって重いですよね。Windowsでやると動作テストが楽です。