I have the same problem, I fixed like that:
Fist, I make a class and write all of function I use:
// /src/common/utils/web_alternative.dart
void usePathUrlStrategy() {}
dynamic get window => null;
After that, I use it to import:
// When I want to use html
import 'package:vinh/src/common/utils/web_alternative.dart' if (dart.library.html) 'dart:html' as html;
// When I want to use usePathUrlStrategy
import 'package:vinh/src/common/utils/web_alternative.dart' if (dart.library.html) 'package:flutter_web_plugins/flutter_web_plugins.dart' show usePathUrlStrategy;
I can use that like it:
if (kIsWeb) {
usePathUrlStrategy();
html.window;
}