Skip to content

Commit 81512c6

Browse files
authored
Update Angular embedding sample (#2147)
- Replace `package:js` usage with `dart:js_interop` - Remove and ignore `package-lock.json` since it keeps causing security warnings: https://github.com/flutter/samples/security/dependabot. It's not necessary for this sample and the constraints already present in the `package.json`. - Update to Angular 17.1
1 parent 7dcea5e commit 81512c6

File tree

7 files changed

+25
-13791
lines changed

7 files changed

+25
-13791
lines changed

web_embedding/ng-flutter/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/bazel-out
88

99
# Node
10+
package-lock.json
1011
/node_modules
1112
npm-debug.log
1213
yarn-error.log
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/// Exposes useful functions to interop with JS from our Flutter app.
2-
library example_js_interop;
2+
library;
33

44
export 'js_interop/counter_state_manager.dart';
55
export 'js_interop/helper.dart' show broadcastAppEvent;
66

7-
export 'package:js/js_util.dart' show createDartExport;
7+
// Replace with createJSInteropWrapper when updating to Dart 3.3.
8+
export 'dart:js_util' show createDartExport;

web_embedding/ng-flutter/flutter/lib/src/js_interop/counter_state_manager.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import 'dart:js_interop';
2+
13
import 'package:flutter/foundation.dart';
2-
import 'package:js/js.dart';
34

45
enum DemoScreen {
56
counter('counter'),

web_embedding/ng-flutter/flutter/lib/src/js_interop/dom.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import 'dart:js_interop';
2-
import 'package:js/js.dart';
3-
import 'package:js/js_util.dart' as js_util;
4-
51
/// This is a little bit of JS-interop code so this Flutter app can dispatch
62
/// a custom JS event (to be deprecated by package:web)
3+
library;
4+
5+
import 'dart:js_interop';
76

87
@JS('CustomEvent')
98
@staticInterop
@@ -12,8 +11,7 @@ class DomCustomEvent {
1211
external factory DomCustomEvent.withOptions(JSString type, JSAny options);
1312
factory DomCustomEvent._(String type, [Object? options]) {
1413
if (options != null) {
15-
return DomCustomEvent.withOptions(
16-
type.toJS, js_util.jsify(options) as JSAny);
14+
return DomCustomEvent.withOptions(type.toJS, options.jsify()!);
1715
}
1816
return DomCustomEvent.withType(type.toJS);
1917
}

web_embedding/ng-flutter/flutter/pubspec.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ environment:
77
sdk: ^3.2.0
88

99
dependencies:
10-
cupertino_icons: ^1.0.2
1110
flutter:
1211
sdk: flutter
13-
js: ^0.7.0
1412

1513
dev_dependencies:
1614
flutter_test:

0 commit comments

Comments
 (0)