1
0
mirror of https://github.com/flutter/samples.git synced 2026-06-25 23:58:44 +00:00
Files
samples/web_embedding/ng-flutter
dependabot[bot] cd36ddc330 Bump @angular/cli from 21.1.5 to 22.0.2 in /web_embedding/ng-flutter (#2862)
Bumps [@angular/cli](https://github.com/angular/angular-cli) from 21.1.5 to 22.0.2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/angular/angular-cli/releases">@​angular/cli's releases</a>.</em></p>
<blockquote>
<h2>22.0.2</h2>
<h3><code>@​angular/cli</code></h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="136fc27149"><img src="https://img.shields.io/badge/136fc2714-fix-green" alt="fix - 136fc2714" /></a></td>
<td>support registry metadata fetching under bun package manager</td>
</tr>
<tr>
<td><a href="2653dd5c7d"><img src="https://img.shields.io/badge/2653dd5c7-perf-orange" alt="perf - 2653dd5c7" /></a></td>
<td>implement semaphore backpressure throttling in PackageManager</td>
</tr>
</tbody>
</table>
<h3><code>@​angular/build</code></h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="0b4a48add9"><img src="https://img.shields.io/badge/0b4a48add-perf-orange" alt="perf - 0b4a48add" /></a></td>
<td>implement semaphore backpressure throttling in JavaScriptTransformer</td>
</tr>
</tbody>
</table>
<h3><code>@​angular/ssr</code></h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="d996a27e97"><img src="https://img.shields.io/badge/d996a27e9-fix-green" alt="fix - d996a27e9" /></a></td>
<td>avoid caching non-SSG page lookups</td>
</tr>
<tr>
<td><a href="285a34e42f"><img src="https://img.shields.io/badge/285a34e42-fix-green" alt="fix - 285a34e42" /></a></td>
<td>correct grammar in console warning for redirected location headers</td>
</tr>
<tr>
<td><a href="c8088a536c"><img src="https://img.shields.io/badge/c8088a536-fix-green" alt="fix - c8088a536" /></a></td>
<td>prioritize options over environment variables in AngularNodeAppEngine</td>
</tr>
</tbody>
</table>
<h2>22.0.1</h2>
<h3><code>@​schematics/angular</code></h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="c800122945"><img src="https://img.shields.io/badge/c80012294-fix-green" alt="fix - c80012294" /></a></td>
<td>fix browserMode option mapping in refactor-jasmine-vitest</td>
</tr>
<tr>
<td><a href="a9b6bd9042"><img src="https://img.shields.io/badge/a9b6bd904-fix-green" alt="fix - a9b6bd904" /></a></td>
<td>safely comment out multiline statements in refactor-jasmine-vitest</td>
</tr>
<tr>
<td><a href="12199df00f"><img src="https://img.shields.io/badge/12199df00-fix-green" alt="fix - 12199df00" /></a></td>
<td>use null objects and callbacks in karma-to-vitest migration</td>
</tr>
</tbody>
</table>
<h3><code>@​angular/cli</code></h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="b54e9a549d"><img src="https://img.shields.io/badge/b54e9a549-fix-green" alt="fix - b54e9a549" /></a></td>
<td>do not sort migrations of the same version alphabetically</td>
</tr>
<tr>
<td><a href="d333116123"><img src="https://img.shields.io/badge/d33311612-fix-green" alt="fix - d33311612" /></a></td>
<td>fallback to local package.json for schematic detection on first run</td>
</tr>
<tr>
<td><a href="918102a937"><img src="https://img.shields.io/badge/918102a93-fix-green" alt="fix - 918102a93" /></a></td>
<td>isolate temporary package installation from parent pnpm workspace</td>
</tr>
<tr>
<td><a href="b048b5f4a8"><img src="https://img.shields.io/badge/b048b5f4a-fix-green" alt="fix - b048b5f4a" /></a></td>
<td>remove forceAuth and unscoped credential parsing</td>
</tr>
<tr>
<td><a href="2779340351"><img src="https://img.shields.io/badge/277934035-fix-green" alt="fix - 277934035" /></a></td>
<td>validate registry option is a valid URL in ng add</td>
</tr>
<tr>
<td><a href="4510dae021"><img src="https://img.shields.io/badge/4510dae02-perf-orange" alt="perf - 4510dae02" /></a></td>
<td>optimize update schematic registry query counts by fetching package metadata lazily</td>
</tr>
</tbody>
</table>
<h3><code>@​angular/build</code></h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="89d1be979f"><img src="https://img.shields.io/badge/89d1be979-fix-green" alt="fix - 89d1be979" /></a></td>
<td>allow disabling Vitest isolation from builder</td>
</tr>
<tr>
<td><a href="d45b84be9a"><img src="https://img.shields.io/badge/d45b84be9-fix-green" alt="fix - d45b84be9" /></a></td>
<td>exclude JSON imports from Vite dependency optimization</td>
</tr>
<tr>
<td><a href="e3cab4ddda"><img src="https://img.shields.io/badge/e3cab4ddd-fix-green" alt="fix - e3cab4ddd" /></a></td>
<td>prevent concurrent stylesheet bundling esbuild context leaks</td>
</tr>
<tr>
<td><a href="bd413b0eb1"><img src="https://img.shields.io/badge/bd413b0eb-fix-green" alt="fix - bd413b0eb" /></a></td>
<td>restrict application builder output paths to output directory</td>
</tr>
</tbody>
</table>
<h2>22.0.0</h2>
<h3><code>@​schematics/angular</code></h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="be60a63b7b"><img src="https://img.shields.io/badge/be60a63b7-feat-blue" alt="feat - be60a63b7" /></a></td>
<td>add migrate-karma-to-vitest update migration</td>
</tr>
<tr>
<td><a href="43505066e2"><img src="https://img.shields.io/badge/43505066e-feat-blue" alt="feat - 43505066e" /></a></td>
<td>add migration to add istanbul-lib-instrument</td>
</tr>
<tr>
<td><a href="b2f7a038b4"><img src="https://img.shields.io/badge/b2f7a038b-feat-blue" alt="feat - b2f7a038b" /></a></td>
<td>conditionally install istanbul coverage provider for Vitest migration</td>
</tr>
<tr>
<td><a href="d227e6985e"><img src="https://img.shields.io/badge/d227e6985-feat-blue" alt="feat - d227e6985" /></a></td>
<td>migrate fake async to Vitest fake timers</td>
</tr>
<tr>
<td><a href="d2aa9ede55"><img src="https://img.shields.io/badge/d2aa9ede5-feat-blue" alt="feat - d2aa9ede5" /></a></td>
<td>migrate fakeAsync's flush behavior when used in beforeEach</td>
</tr>
</tbody>
</table>
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/angular/angular-cli/blob/main/CHANGELOG.md">@​angular/cli's changelog</a>.</em></p>
<blockquote>
<h1>22.0.2 (2026-06-17)</h1>
<h3><code>@​angular/cli</code></h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="136fc27149">136fc2714</a></td>
<td>fix</td>
<td>support registry metadata fetching under bun package manager</td>
</tr>
<tr>
<td><a href="2653dd5c7d">2653dd5c7</a></td>
<td>perf</td>
<td>implement semaphore backpressure throttling in PackageManager</td>
</tr>
</tbody>
</table>
<h3><code>@​angular/build</code></h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="0b4a48add9">0b4a48add</a></td>
<td>perf</td>
<td>implement semaphore backpressure throttling in JavaScriptTransformer</td>
</tr>
</tbody>
</table>
<h3><code>@​angular/ssr</code></h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="d996a27e97">d996a27e9</a></td>
<td>fix</td>
<td>avoid caching non-SSG page lookups</td>
</tr>
<tr>
<td><a href="285a34e42f">285a34e42</a></td>
<td>fix</td>
<td>correct grammar in console warning for redirected location headers</td>
</tr>
<tr>
<td><a href="c8088a536c">c8088a536</a></td>
<td>fix</td>
<td>prioritize options over environment variables in AngularNodeAppEngine</td>
</tr>
</tbody>
</table>
<h1>22.1.0-next.0 (2026-06-11)</h1>
<h2>Deprecations</h2>
<h3><code>@​angular-devkit/core</code></h3>
<ul>
<li>
<p><code>stringToFileBuffer</code> and <code>fileBufferToString</code> are deprecated. Use standard Web APIs (<code>TextEncoder</code> and <code>TextDecoder</code>) instead.</p>
<p>Internal usages within the repository have been removed and replaced with standard Web APIs. The public API golden file for <code>@angular-devkit/core</code> has been updated to reflect the deprecations.</p>
</li>
</ul>
<h3><code>@​schematics/angular</code></h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="89d7f59cd7">89d7f59cd</a></td>
<td>feat</td>
<td>update ai-config to include Angular MCP server config</td>
</tr>
</tbody>
</table>
<h3><code>@​angular/cli</code></h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="7932caaf98">7932caaf9</a></td>
<td>fix</td>
<td>robustly parse npm manifest from array</td>
</tr>
</tbody>
</table>
<h3><code>@​angular-devkit/core</code></h3>
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="aab6c10b94"><code>aab6c10</code></a> release: cut the v22.0.2 release</li>
<li><a href="376e4dce42"><code>376e4dc</code></a> build: update cross-repo angular dependencies</li>
<li><a href="d996a27e97"><code>d996a27</code></a> fix(<code>@​angular/ssr</code>): avoid caching non-SSG page lookups</li>
<li><a href="5714bfcbe1"><code>5714bfc</code></a> build: update pnpm to v10.34.3</li>
<li><a href="f26011ae7a"><code>f26011a</code></a> build: lock file maintenance</li>
<li><a href="2879ed9bef"><code>2879ed9</code></a> build: update bazel dependencies</li>
<li><a href="092bb2e083"><code>092bb2e</code></a> build: update dependency pacote to v21.5.1</li>
<li><a href="d3e8951120"><code>d3e8951</code></a> build: update dependency esbuild-wasm to v0.28.1</li>
<li><a href="0f777a84ed"><code>0f777a8</code></a> build: update dependency esbuild to v0.28.1</li>
<li><a href="385909c9af"><code>385909c</code></a> refactor: move eslint disable comment to top of file</li>
<li>Additional commits viewable in <a href="https://github.com/angular/angular-cli/compare/v21.1.5...v22.0.2">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=@angular/cli&package-manager=npm_and_yarn&previous-version=21.1.5&new-version=22.0.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

</details>
2026-06-18 06:40:46 +00:00
..
2023-05-06 10:53:17 +10:00

ng-flutter

This Angular project is a simple example of how Angular and Flutter web apps could be integrated, and have them interop.

Points of Interest

Angular

This repository is a quite standard Angular app. The following changes were made to be able to use (and interop) with a Flutter web application:

  • package.json has a custom prebuild script that builds the Flutter web app, so Angular can find it later.
  • flutter.js is added as a "scripts" entry in angular.json. Angular takes care of minimizing and injecting it as any other script.
  • The rest of the flutter app flutter/build/web/ is registered as an "assets" entry in angular.json, and moved to /flutter.
  • The ng-flutter component takes care of embedding Flutter web, and yielding control to Angular through an appLoaded EventEmitter. The object yielded by this emitter is a state controller exposed by flutter via a JS custom event!

Flutter

The embedded Flutter application lives in the flutter directory of this repo. That application is a standard web app, that doesn't need to be aware that it's going to be embedded in another framework.

  • Flutter uses new @staticInterop methods to allow certain Dart functions to be called from JavaScript.
  • Look at how createDartExport and broadcastAppEvent work together to make the _state controller of the Flutter app available to Angular!

How to build the app

Requirements

If you want to build and run this demo on your machine, you'll need a moderately recent version of Angular:

$ ng version

Angular CLI: 17.0.0
Node: 20.9.0
Package Manager: npm 10.1.0
OS: linux x64

And Flutter:

$ flutter --version

Flutter 3.13.9 • channel stable
Framework • revision d211f42860 (2 weeks ago) • 2023-10-25 13:42:25 -0700
Engine • revision 0545f8705d
Tools • Dart 3.1.5 • DevTools 2.25.0

Ensure npm, ng and flutter are present in your $PATH.

Building the app

This repository is a moderately standard Angular app. It integrates Flutter web by making it part of the Angular assets.

In order to build this app, first fetch its npm dependencies:

$ npm install

added 963 packages, and audited 964 packages in 17s

93 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

Then run the build script. It'll take care of building Flutter automatically:

$ npm run build

> ng-flutter@0.0.0 prebuild

... Flutter web build output ...

Compiling lib/main.dart for the Web...

> ng-flutter@0.0.0 build
> ng build

... Angular build output ...

✔ Browser application bundle generation complete.
✔ Copying assets complete.
✔ Index html generation complete.

Local Angular development

Once you've reached this point, you should be able to work with your Angular application normally, for example to run a local web server:

$ npm run start

> ng-flutter@0.0.0 start
> ng serve

✔ Browser application bundle generation complete.

Initial Chunk Files   | Names         |  Raw Size
vendor.js             | vendor        |   4.38 MB | 

... Angular build output...

** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **


✔ Compiled successfully.

Navigate to http://localhost:4200/. The application will automatically reload if you change any of its Angular source files.

Local Flutter web development

The Flutter app lives inside the flutter directory, and can be developed independently. Just do any changes on Flutter web as you'd normally do. It even includes a small web/index.html so you can see changes to your app without running the whole Angular setup.

Note

For now, Angular does not auto-detect changes to your Flutter web app, so once you're happy with your Flutter web app, make sure to call npm run build so everything rebuilds and gets placed into its correct location.

Deploying the app

After npm run build, you should have a deployable Angular + Flutter web app in the dist directory of this Angular project.

Your built app can can be deployed anywhere, but do check Firebase hosting for a super-easy deployment experience!

Troubleshooting

Flutter

Ensure your flutter app is properly rebuilt after any changes.

  • Run npm run build to re-build the Flutter app.

If you encounter error messages like:

Error: Can't resolve 'flutter/build/web/flutter.js' in '/my/checkout/of/ng-flutter'

You definitely need to run npm run build!

Reach out to the team(s)!

Have you had any problem not covered in this README? Do you want to see other embedding examples?

Let us know by creating an issue or opening a new pull request.

Thanks!