pwa
pwa copied to clipboard
dart:html causing problems for mobile app
My situation
I was making a mock app to see if I could make the same code generate a web, android and iOS app(actually don't care much about iOS).
I wanted to try and make web installable as in PWA conventions and that's how I came to this plugin.
Problem
My web app compiled normally, but my android app didn't. (though I didn't set much up so maybe I just didn't bump into some trouble like caching urls).
Service_Worker package (in pwa package) uses dart:html which Flutter couldn't find and it crashes before the build process.
Compiler message:
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:3:8: Error: Not found: 'dart:html'
import 'dart:html'
^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:35:1: Error: Not found: 'dart:html'
export 'dart:html' show ErrorEvent, Event, MessageEvent;
^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:16:8: Error: Not found: 'dart:indexed_db'
import 'dart:indexed_db';
^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_facade/service_worker_api.dart:4:8: Error: Not found: 'dart:html'
import 'dart:html' show Event, Blob, MessagePort, MessageEvent, ErrorEvent;
^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_facade/service_worker_api.dart:12:1: Error: Not found: 'dart:html'
export 'dart:html' show MessageEvent, ErrorEvent;
^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/js-0.6.1+1/lib/js.dart:8:1: Error: Not found: 'dart:js'
export 'dart:js' show allowInterop, allowInteropCaptureThis;
^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/js-0.6.1+1/lib/js_util.dart:8:1: Error: Not found: 'dart:js_util'
export 'dart:js_util';
^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_facade/isomorphic_fetch.dart:4:8: Error: Not found: 'dart:html'
import 'dart:html' show Blob, FormData;
^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/window.dart:49:8: Error: Type 'Event' not found.
Stream<Event> get onControllerChange => _self.onControllerChange;
^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/window.dart:53:8: Error: Type 'ErrorEvent' not found.
Stream<ErrorEvent> get onError => _self.onError;
^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/window.dart:58:8: Error: Type 'MessageEvent' not found.
Stream<MessageEvent> get onMessage => _self.onMessage;
^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:161:3: Error: Type 'IdbFactory' not found.
IdbFactory get indexedDB => _getProperty(_delegate, 'indexedDB');
^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:179:10: Error: Type 'Event' not found.
Stream<Event> _onControllerChange;
^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:180:10: Error: Type 'ErrorEvent' not found.
Stream<ErrorEvent> _onError;
^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:181:10: Error: Type 'MessageEvent' not found.
Stream<MessageEvent> _onMessage;
^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:204:10: Error: Type 'Event' not found.
Stream<Event> get onControllerChange => _onControllerChange ??=
^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:209:10: Error: Type 'ErrorEvent' not found.
Stream<ErrorEvent> get onError => _onError ??=
^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:215:10: Error: Type 'MessageEvent' not found.
Stream<MessageEvent> get onMessage => _onMessage ??=
^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:438:44: Error: Type 'EventTarget' not found.
class ServiceWorkerRegistration implements EventTarget {
^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:496:38: Error: Type 'EventListener' not found.
void addEventListener(String type, EventListener listener,
^^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:503:22: Error: Type 'Event' not found.
bool dispatchEvent(Event event) =>
^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:507:3: Error: Type 'Events' not found.
Events get on => _getProperty(_delegate, 'on');
^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:510:41: Error: Type 'EventListener' not found.
void removeEventListener(String type, EventListener listener,
^^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:602:34: Error: Type 'Event' not found.
class ExtendableEvent implements Event {
^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:615:3: Error: Type 'EventTarget' not found.
EventTarget get target => _getProperty(_delegate, 'target');
^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:630:3: Error: Type 'EventTarget' not found.
EventTarget get currentTarget => _getProperty(_delegate, 'currentTarget');
^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:642:3: Error: Type 'Element' not found.
Element get matchingTarget => _getProperty(_delegate, 'matchingTarget');
^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:645:8: Error: Type 'EventTarget' not found.
List<EventTarget> get path => _getProperty(_delegate, 'path');
^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:661:8: Error: Type 'EventTarget' not found.
List<EventTarget> composedPath() =>
^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:671:29: Error: Type 'Event' not found.
class FetchEvent implements Event {
^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:701:3: Error: Type 'EventTarget' not found.
EventTarget get target => _getProperty(_delegate, 'target');
^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:716:3: Error: Type 'EventTarget' not found.
EventTarget get currentTarget => _getProperty(_delegate, 'currentTarget');
^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:728:3: Error: Type 'Element' not found.
Element get matchingTarget => _getProperty(_delegate, 'matchingTarget');
^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:731:8: Error: Type 'EventTarget' not found.
List<EventTarget> get path => _getProperty(_delegate, 'path');
^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:747:8: Error: Type 'EventTarget' not found.
List<EventTarget> composedPath() =>
^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:768:32: Error: Type 'Worker' not found.
class ServiceWorker implements Worker {
^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:771:10: Error: Type 'Event' not found.
Stream<Event> _onStateChange;
^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:772:10: Error: Type 'ErrorEvent' not found.
Stream<ErrorEvent> _onError;
^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:773:10: Error: Type 'MessageEvent' not found.
Stream<MessageEvent> _onMessage;
^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:794:10: Error: Type 'Event' not found.
Stream<Event> get onStateChange => _onStateChange ??=
^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:798:38: Error: Type 'EventListener' not found.
void addEventListener(String type, EventListener listener,
^^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:805:22: Error: Type 'Event' not found.
bool dispatchEvent(Event event) =>
^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:809:3: Error: Type 'Events' not found.
Events get on => _getProperty(_delegate, 'on');
^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:814:10: Error: Type 'ErrorEvent' not found.
Stream<ErrorEvent> get onError => _onError ??=
^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:821:10: Error: Type 'MessageEvent' not found.
Stream<MessageEvent> get onMessage => _onMessage ??=
^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:832:41: Error: Type 'EventListener' not found.
void removeEventListener(String type, EventListener listener,
^^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:865:8: Error: Type 'MessagePort' not found.
List<MessagePort> get ports => _getProperty(_delegate, 'ports');
^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:912:3: Error: Type 'Blob' not found.
Blob blob() => _callMethod(_delegate, 'blob', []);
^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:934:10: Error: Type 'Blob' not found.
Future<Blob> blob() => promiseToFuture(_callMethod(_delegate, 'blob', []));
^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:936:10: Error: Type 'FormData' not found.
Future<FormData> formData() =>
^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_facade/service_worker_api.dart:223:23: Error: Type 'Event' not found.
external CallbackFn<Event> get onstatechange;
^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_facade/service_worker_api.dart:224:41: Error: Type 'Event' not found.
external set onstatechange(CallbackFn<Event> v);
^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_facade/service_worker_api.dart:236:12: Error: Type 'Blob' not found.
external Blob blob();
^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_facade/service_worker_api.dart:373:17: Error: Type 'MessagePort' not found.
external List<MessagePort> get ports;
^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_facade/service_worker_api.dart:374:27: Error: Type 'MessagePort' not found.
external set ports(List<MessagePort> v);
^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_facade/service_worker_api.dart:706:23: Error: Type 'Event' not found.
external CallbackFn<Event> get oncontrollerchange;
^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_facade/service_worker_api.dart:707:46: Error: Type 'Event' not found.
external set oncontrollerchange(CallbackFn<Event> v);
^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_facade/service_worker_api.dart:711:23: Error: Type 'ErrorEvent' not found.
external CallbackFn<ErrorEvent> get onerror;
^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_facade/service_worker_api.dart:712:35: Error: Type 'ErrorEvent' not found.
external set onerror(CallbackFn<ErrorEvent> v);
^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_facade/service_worker_api.dart:717:23: Error: Type 'MessageEvent' not found.
external CallbackFn<MessageEvent> get onmessage;
^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_facade/service_worker_api.dart:718:37: Error: Type 'MessageEvent' not found.
external set onmessage(CallbackFn<MessageEvent> v);
^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_facade/service_worker_api.dart:786:23: Error: Type 'MessageEvent' not found.
external CallbackFn<MessageEvent> get onmessage;
^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_facade/service_worker_api.dart:787:37: Error: Type 'MessageEvent' not found.
external set onmessage(CallbackFn<MessageEvent> v);
^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_facade/isomorphic_fetch.dart:92:20: Error: Type 'Blob' not found.
external Promise<Blob> blob();
^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_facade/isomorphic_fetch.dart:93:20: Error: Type 'FormData' not found.
external Promise<FormData> formData();
^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_facade/isomorphic_fetch.dart:105:20: Error: Type 'Blob' not found.
external Promise<Blob> blob();
^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_facade/isomorphic_fetch.dart:106:20: Error: Type 'FormData' not found.
external Promise<FormData> formData();
^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:147:18: Error: Method not found: 'allowInterop'.
[type, allowInterop(listener), useCapture]);
^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:147:18: Error: The method 'allowInterop' isn't defined for the class 'ServiceWorkerGlobalScope'.
- 'ServiceWorkerGlobalScope' is from 'package:service_worker/src/service_worker_api.dart' ('/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
[type, allowInterop(listener), useCapture]);
^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:179:10: Error: 'Event' isn't a type.
Stream<Event> _onControllerChange;
^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:180:10: Error: 'ErrorEvent' isn't a type.
Stream<ErrorEvent> _onError;
^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:181:10: Error: 'MessageEvent' isn't a type.
Stream<MessageEvent> _onMessage;
^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:205:69: Error: 'Event' isn't a type.
callbackToStream(_delegate, 'oncontrollerchange', (j) => j as Event);
^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:210:58: Error: 'ErrorEvent' isn't a type.
callbackToStream(_delegate, 'onerror', (j) => j as ErrorEvent);
^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:216:60: Error: 'MessageEvent' isn't a type.
callbackToStream(_delegate, 'onmessage', (j) => j as MessageEvent);
^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:249:16: Error: Method not found: 'allowInterop'.
[type, allowInterop(listener), useCapture]);
^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:249:16: Error: The method 'allowInterop' isn't defined for the class 'ServiceWorkerContainer'.
- 'ServiceWorkerContainer' is from 'package:service_worker/src/service_worker_api.dart' ('/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
[type, allowInterop(listener), useCapture]);
^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:496:38: Error: 'EventListener' isn't a type.
void addEventListener(String type, EventListener listener,
^^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:499:16: Error: Method not found: 'allowInterop'.
[type, allowInterop(listener), useCapture]);
^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:499:16: Error: The method 'allowInterop' isn't defined for the class 'ServiceWorkerRegistration'.
- 'ServiceWorkerRegistration' is from 'package:service_worker/src/service_worker_api.dart' ('/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
[type, allowInterop(listener), useCapture]);
^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:503:22: Error: 'Event' isn't a type.
bool dispatchEvent(Event event) =>
^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:510:41: Error: 'EventListener' isn't a type.
void removeEventListener(String type, EventListener listener,
^^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:662:65: Error: 'EventTarget' isn't a type.
(_callMethod(_delegate, 'composedPath', []) as List).cast<EventTarget>();
^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:748:65: Error: 'EventTarget' isn't a type.
(_callMethod(_delegate, 'composedPath', []) as List).cast<EventTarget>();
^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:771:10: Error: 'Event' isn't a type.
Stream<Event> _onStateChange;
^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:772:10: Error: 'ErrorEvent' isn't a type.
Stream<ErrorEvent> _onError;
^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:773:10: Error: 'MessageEvent' isn't a type.
Stream<MessageEvent> _onMessage;
^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:795:64: Error: 'Event' isn't a type.
callbackToStream(_delegate, 'onstatechange', (j) => j as Event);
^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:798:38: Error: 'EventListener' isn't a type.
void addEventListener(String type, EventListener listener,
^^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:801:16: Error: Method not found: 'allowInterop'.
[type, allowInterop(listener), useCapture]);
^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:801:16: Error: The method 'allowInterop' isn't defined for the class 'ServiceWorker'.
- 'ServiceWorker' is from 'package:service_worker/src/service_worker_api.dart' ('/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
[type, allowInterop(listener), useCapture]);
^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:805:22: Error: 'Event' isn't a type.
bool dispatchEvent(Event event) =>
^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:815:58: Error: 'ErrorEvent' isn't a type.
callbackToStream(_delegate, 'onerror', (j) => j as ErrorEvent);
^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:822:60: Error: 'MessageEvent' isn't a type.
callbackToStream(_delegate, 'onmessage', (j) => j as MessageEvent);
^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:832:41: Error: 'EventListener' isn't a type.
void removeEventListener(String type, EventListener listener,
^^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:1093:5: Error: Method not found: 'callMethod'.
js_util.callMethod(object, method, args) as T;
^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/service_worker_api.dart:1097:5: Error: Method not found: 'getProperty'.
js_util.getProperty(object, name) as T;
^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_adapter.dart:15:37: Error: Method not found: 'allowInterop'.
js_util.setProperty(object, name, allowInterop((J event) {
^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_adapter.dart:15:3: Error: Method not found: 'setProperty'.
js_util.setProperty(object, name, allowInterop((J event) {
^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_adapter.dart:25:16: Error: Method not found: 'allowInterop'.
promise.then(allowInterop((value) {
^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_adapter.dart:33:7: Error: Method not found: 'allowInterop'.
}), allowInterop((error) {
^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_adapter.dart:41:5: Error: Method not found: 'allowInterop'.
allowInterop(
^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_adapter.dart:72:17: Error: Method not found: 'callMethod'.
dynamic m = js_util.callMethod(_object, 'next', []);
^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_adapter.dart:73:21: Error: Method not found: 'getProperty'.
bool hasValue = js_util.getProperty(m, 'done') == false;
^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_adapter.dart:74:27: Error: Method not found: 'getProperty'.
_current = hasValue ? js_util.getProperty(m, 'value') as R : null;
^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_facade/service_worker_api.dart:224:41: Error: 'Event' isn't a type.
external set onstatechange(CallbackFn<Event> v);
^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_facade/service_worker_api.dart:374:27: Error: 'MessagePort' isn't a type.
external set ports(List<MessagePort> v);
^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_facade/service_worker_api.dart:707:46: Error: 'Event' isn't a type.
external set oncontrollerchange(CallbackFn<Event> v);
^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_facade/service_worker_api.dart:712:35: Error: 'ErrorEvent' isn't a type.
external set onerror(CallbackFn<ErrorEvent> v);
^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_facade/service_worker_api.dart:718:37: Error: 'MessageEvent' isn't a type.
external set onmessage(CallbackFn<MessageEvent> v);
^^^^^^^^^^^^
/C:/Users/Lucas.Nantes/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/service_worker-0.2.3/lib/src/js_facade/service_worker_api.dart:787:37: Error: 'MessageEvent' isn't a type.
external set onmessage(CallbackFn<MessageEvent> v);
^^^^^^^^^^^^
/c:/Programas/flutter/packages/flutter/lib/src/painting/_network_image_web.dart:56:12: Error: Method not found: 'webOnlyInstantiateImageCodecFromUrl'.
return ui.webOnlyInstantiateImageCodecFromUrl(resolved); // ignore: undefined_function
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
U
nhandled exception:
FileSystemExceptio
n(uri=org-dartlang-untranslatable-uri:dart%3Ahtml; message=StandardFileSystem only supports file:* and data:
* URIs)
#0 StandardFileSystem.entityForUri (package:front_e
nd/src/api_prototype/standard_file_system.dart:33:7)
#1 as
FileUri (package:vm/kernel_front_end.dart:520:37)
<asynchronous suspe
nsion>
[38;5;248m#2 writeDepfile ( (package:vm/kernel_front_end.dart:697:21)[39;49m
)
<asynchronous suspension>
#3 FrontendCompiler.compile (package
:vm/frontend_server.dart:407:15)
<asynchronous suspension>
#4
_FlutterFrontendCompiler.compile (package:frontend_server/server.dart:
29:22)
<asynchronous suspension>
#5 starter (package:frontend_se
rver/server.dart:127:27)
<asynchronous suspension>
#6 main
(file:///C:/b/s/w/ir/k/src/flutter/frontend_server/bin/starter.dart:8:
30)
<asynchronous suspension>
#7 _startIsolate.<anonymous clo
sure> (dart:isolate-patch/isolate_patch.dart:303:32)
#8 _RawRe
ceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:17
2:12)
FAILURE: Build failed with an exception.
My Flutter Settings
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel dev, v1.10.3, on Microsoft Windows [versão 10.0.16299.1087], locale pt-BR)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
[√] Chrome - develop for the web
[!] Android Studio (version 3.5)
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[√] VS Code (version 1.38.1)
[√] Connected device (3 available)
! Doctor found issues in 1 category.
For some reason this only happens when building for android. If I should be doing something for this to work than please also add this to the readme file.
There are platform limitations of certain packages:
-
dart:html
,dart:svg
can only be used on web, and won't work on Flutter or on console apps -
dart:ui
can only be used on Flutter, and won't work on web or on console apps -
dart:io
can only be used on console and Flutter, and won't work on web
You can't use these in every part of your app, you need to separate them somewhat. E.g. package:http
can be used in all of these platforms, but for web you'll need to import package:http/browser_client.dart
. Once you have good abstractions, only a few platform-specific part remain in each separate package you'll have.
@isoos I tried to make it call pwa.Client()
only if it's running in web platform, but when running on Android it crashes as it can't compile that part.
I published this issue in hopes pwa package could make it work in a "lazy" way, so that dart:html is not included in files to compile in an android build.
If Flutter doesn't incorporate this kind of thing I'd question the Flutter's team then for this feature, then I could apply it myself.
I'm not sure what do you mean by "running in web platform, but on Android". Did you compiled the app with dart2js and running on Chrome (on Android)?
Something like that. I was testing if it was possible to have the same code be compiled to both web and android already. It was working fine, so I went one step further and tried to make the web version installable. Though I didn't get to finish that, when I tried building the android version again, it started crashing.
This is just my humble opinion, but I think Flutter's idea is to have our code be "compilable" to whatever platform we want. Of course, each platform has its own uses and limitations so the code might need some working around for specific platforms. But currently, just by adding pwa import causes a crash to Android build (haven't tested on ios, but should be the same).
So if there was a lazy loader for that, it would be useful so I don't have to "remove some lines of code" to make my app working in android again.
To achieve that you'll need the following separate libraries (the names are made up):
lib/shared_code.dart
: all the shared code and the abstract interfaces.
lib/my_flutter_app.dart
: the flutter-specific code and the implementation of the interfaces. (import 'shared_code.dart';
)
lib/my_pwa_app.dart
: the web-app-specific code and the implementation of the interfaces. (import 'shared_code.dart';
)
That way you will be able to reuse most of your code, and neither dart2js nor Flutter will complain about the conflicting platform libraries. I'd probably put them into separate packages too, for better dependency management, then the imports are of course fully qualified package:...
urls.
I'm not in a hurry to implement PWA as Flutter's still in tech preview for web. Though, is this something useful enough to be added inside the PWA package? Like a long milestone or something like that?
To achieve that you'll need the following separate libraries (the names are made up):
lib/shared_code.dart
: all the shared code and the abstract interfaces.
lib/my_flutter_app.dart
: the flutter-specific code and the implementation of the interfaces. (import 'shared_code.dart';
)
lib/my_pwa_app.dart
: the web-app-specific code and the implementation of the interfaces. (import 'shared_code.dart';
)That way you will be able to reuse most of your code, and neither dart2js nor Flutter will complain about the conflicting platform libraries. I'd probably put them into separate packages too, for better dependency management, then the imports are of course fully qualified
package:...
urls.
Can you explain this in more detailed way or maybe a small sample app with one lib made only for web and the other one only for Mobile clients.
#38