File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 13
13
// limitations under the License.
14
14
15
15
import 'detected_runtime_stub.dart'
16
- if (dart.library.html ) 'detected_runtime_html .dart' ;
16
+ if (dart.library.js_interop ) 'detected_runtime_js_interop .dart' ;
17
17
18
18
export 'detected_runtime_stub.dart'
19
- if (dart.library.html) 'detected_runtime_html.dart' show detectedRuntime;
19
+ if (dart.library.js_interop) 'detected_runtime_js_interop.dart'
20
+ show detectedRuntime;
20
21
21
22
/// Return `null` instead of [value] on Firefox.
22
23
///
Original file line number Diff line number Diff line change 12
12
// See the License for the specific language governing permissions and
13
13
// limitations under the License.
14
14
15
- // ignore: avoid_web_libraries_in_flutter
16
- import 'dart:html' show window;
15
+ import 'dart:js_interop' ;
16
+
17
+ @JS ('window.navigator.userAgent' )
18
+ external String get userAgent;
17
19
18
20
/// Detected runtime based on [rendering engine][1] , this is one of:
19
21
/// * `'firefox'` (if rendering engine is `'gecko'` ),
@@ -32,7 +34,7 @@ import 'dart:html' show window;
32
34
///
33
35
/// [1] : https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent
34
36
final String detectedRuntime = () {
35
- final ua = window.navigator. userAgent;
37
+ final ua = userAgent;
36
38
37
39
if (ua.contains ('Gecko/' )) {
38
40
return 'firefox' ;
You can’t perform that action at this time.
0 commit comments