1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 13:58:47 +00:00
Files
samples/web_embedding/ng-flutter
dependabot[bot] c7a493665c Bump @angular/common from 19.2.14 to 20.1.4 in /web_embedding/ng-flutter (#2702)
Bumps [@angular/common](https://github.com/angular/angular/tree/HEAD/packages/common) from 19.2.14 to 20.1.4.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/angular/angular/releases"><code>@​angular/common</code>'s releases</a>.</em></p>
<blockquote>
<h2>20.1.4</h2>
<h3>compiler</h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="db3c5826ee"><img src="https://img.shields.io/badge/db3c5826ee-fix-green" alt="fix - db3c5826ee" /></a></td>
<td>exclude more safe reads expression from 2way-binding (<a href="https://github.com/angular/angular/tree/HEAD/packages/common/issues/62852">#62852</a>)</td>
</tr>
</tbody>
</table>
<h3>core</h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="c633b63e56"><img src="https://img.shields.io/badge/c633b63e56-fix-green" alt="fix - c633b63e56" /></a></td>
<td>update symbols for new signals api (<a href="https://github.com/angular/angular/tree/HEAD/packages/common/issues/62284">#62284</a>)</td>
</tr>
</tbody>
</table>
<h3>http</h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="ab6033979a"><img src="https://img.shields.io/badge/ab6033979a-fix-green" alt="fix - ab6033979a" /></a></td>
<td>add missing http options allowed in fetch API (<a href="https://github.com/angular/angular/tree/HEAD/packages/common/issues/62881">#62881</a>)</td>
</tr>
<tr>
<td><a href="15670d8417"><img src="https://img.shields.io/badge/15670d8417-fix-green" alt="fix - 15670d8417" /></a></td>
<td>propagate plain errors when parsing fails (<a href="https://github.com/angular/angular/tree/HEAD/packages/common/issues/62765">#62765</a>)</td>
</tr>
</tbody>
</table>
<h2>20.1.3</h2>
<h3>core</h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="2c522efbe5"><img src="https://img.shields.io/badge/2c522efbe5-fix-green" alt="fix - 2c522efbe5" /></a></td>
<td>fix change tracking for Resource#hasValue (<a href="https://github.com/angular/angular/tree/HEAD/packages/common/issues/62595">#62595</a>)</td>
</tr>
</tbody>
</table>
<h3>platform-browser</h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="2fd1f7beb5"><img src="https://img.shields.io/badge/2fd1f7beb5-fix-green" alt="fix - 2fd1f7beb5" /></a></td>
<td>resolve component resources before bootstrapping in JIT mode (<a href="https://github.com/angular/angular/tree/HEAD/packages/common/issues/62758">#62758</a>)</td>
</tr>
</tbody>
</table>
<h2>20.1.2</h2>
<h3>compiler</h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="8ad10fd63b"><img src="https://img.shields.io/badge/8ad10fd63b-fix-green" alt="fix - 8ad10fd63b" /></a></td>
<td>fix detection of directive deps in JIT (<a href="https://github.com/angular/angular/tree/HEAD/packages/common/issues/62666">#62666</a>)</td>
</tr>
</tbody>
</table>
<h2>20.1.1</h2>
<h3>compiler</h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="75d2a349b4"><img src="https://img.shields.io/badge/75d2a349b4-fix-green" alt="fix - 75d2a349b4" /></a></td>
<td>incorrect spans for left side of binary operation (<a href="https://github.com/angular/angular/tree/HEAD/packages/common/issues/62641">#62641</a>)</td>
</tr>
<tr>
<td><a href="70c8780c54"><img src="https://img.shields.io/badge/70c8780c54-fix-green" alt="fix - 70c8780c54" /></a></td>
<td>more permissive parsing of @ characters (<a href="https://github.com/angular/angular/tree/HEAD/packages/common/issues/62644">#62644</a>)</td>
</tr>
</tbody>
</table>
<h3>compiler-cli</h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="9506cdfaad"><img src="https://img.shields.io/badge/9506cdfaad-fix-green" alt="fix - 9506cdfaad" /></a></td>
<td>infer type of event target for void elements (<a href="https://github.com/angular/angular/tree/HEAD/packages/common/issues/62648">#62648</a>)</td>
</tr>
</tbody>
</table>
<h3>core</h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="26ade4a337"><img src="https://img.shields.io/badge/26ade4a337-fix-green" alt="fix - 26ade4a337" /></a></td>
<td>Ensure application remains unstable during bootstrap (<a href="https://github.com/angular/angular/tree/HEAD/packages/common/issues/62631">#62631</a>)</td>
</tr>
<tr>
<td><a href="a81f0faa1a"><img src="https://img.shields.io/badge/a81f0faa1a-fix-green" alt="fix - a81f0faa1a" /></a></td>
<td>InputBinding marks component a dirty. (<a href="https://github.com/angular/angular/tree/HEAD/packages/common/issues/62613">#62613</a>)</td>
</tr>
</tbody>
</table>
<h3>http</h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="276836ee73"><img src="https://img.shields.io/badge/276836ee73-fix-green" alt="fix - 276836ee73" /></a></td>
<td>do not display warnings <code>Angular detected that a </code>HttpClient<code>request with the</code>keepalive<code> option was sent using XHR</code> when option is not true (<a href="https://github.com/angular/angular/tree/HEAD/packages/common/issues/62536">#62536</a>)</td>
</tr>
</tbody>
</table>
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/angular/angular/blob/main/CHANGELOG.md"><code>@​angular/common</code>'s changelog</a>.</em></p>
<blockquote>
<h1>20.1.4 (2025-07-31)</h1>
<h3>compiler</h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="db3c5826ee">db3c5826ee</a></td>
<td>fix</td>
<td>exclude more safe reads expression from 2way-binding (<a href="https://redirect.github.com/angular/angular/pull/62852">#62852</a>)</td>
</tr>
</tbody>
</table>
<h3>core</h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="c633b63e56">c633b63e56</a></td>
<td>fix</td>
<td>update symbols for new signals api (<a href="https://redirect.github.com/angular/angular/pull/62284">#62284</a>)</td>
</tr>
</tbody>
</table>
<h3>http</h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="ab6033979a">ab6033979a</a></td>
<td>fix</td>
<td>add missing http options allowed in fetch API (<a href="https://redirect.github.com/angular/angular/pull/62881">#62881</a>)</td>
</tr>
<tr>
<td><a href="15670d8417">15670d8417</a></td>
<td>fix</td>
<td>propagate plain errors when parsing fails (<a href="https://redirect.github.com/angular/angular/pull/62765">#62765</a>)</td>
</tr>
</tbody>
</table>
<h1>20.2.0-next.2 (2025-07-23)</h1>
<h3>compiler</h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="7767aa640c">7767aa640c</a></td>
<td>fix</td>
<td>allow more characters in square-bracketed attribute names (<a href="https://redirect.github.com/angular/angular/pull/62742">#62742</a>)</td>
</tr>
<tr>
<td><a href="3171d01452">3171d01452</a></td>
<td>fix</td>
<td>fix detection of directive deps in JIT (<a href="https://redirect.github.com/angular/angular/pull/62666">#62666</a>)</td>
</tr>
</tbody>
</table>
<h3>compiler-cli</h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="5abfe4a899">5abfe4a899</a></td>
<td>feat</td>
<td>add diagnostic for uninvoked functions in text interpolation (<a href="https://redirect.github.com/angular/angular/pull/59191">#59191</a>)</td>
</tr>
</tbody>
</table>
<h3>core</h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="6b1f4b9e8b">6b1f4b9e8b</a></td>
<td>feat</td>
<td>add enter and leave animation instructions (<a href="https://redirect.github.com/angular/angular/pull/62682">#62682</a>)</td>
</tr>
<tr>
<td><a href="cec91c0035">cec91c0035</a></td>
<td>feat</td>
<td>add option to infer the tag names of components in tests (<a href="https://redirect.github.com/angular/angular/pull/62283">#62283</a>)</td>
</tr>
<tr>
<td><a href="4138aca91f">4138aca91f</a></td>
<td>feat</td>
<td>render ARIA property bindings as attributes (<a href="https://redirect.github.com/angular/angular/pull/62630">#62630</a>)</td>
</tr>
<tr>
<td><a href="593cc8a368">593cc8a368</a></td>
<td>fix</td>
<td>checks if body exists before continuing (<a href="https://redirect.github.com/angular/angular/pull/62768">#62768</a>)</td>
</tr>
<tr>
<td><a href="b8e415a717">b8e415a717</a></td>
<td>fix</td>
<td>fix change tracking for Resource#hasValue (<a href="https://redirect.github.com/angular/angular/pull/62595">#62595</a>)</td>
</tr>
<tr>
<td><a href="063b5e166f">063b5e166f</a></td>
<td>fix</td>
<td>switch check to documentElement with chaining (<a href="https://redirect.github.com/angular/angular/pull/62773">#62773</a>)</td>
</tr>
</tbody>
</table>
<h3>platform-browser</h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="74d99ed379">74d99ed379</a></td>
<td>fix</td>
<td>resolve component resources before bootstrapping in JIT mode (<a href="https://redirect.github.com/angular/angular/pull/62758">#62758</a>)</td>
</tr>
</tbody>
</table>
<h3>service-worker</h3>
<table>
<thead>
<tr>
<th>Commit</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="4ac6171b09">4ac6171b09</a></td>
<td>feat</td>
<td>Adds support for updateViaCache in provideServiceWorker (<a href="https://redirect.github.com/angular/angular/pull/62721">#62721</a>)</td>
</tr>
</tbody>
</table>
<h1>20.1.3 (2025-07-23)</h1>
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="82fcc9c136"><code>82fcc9c</code></a> Revert &quot;fix(http): add missing http options allowed in fetch API (<a href="https://github.com/angular/angular/tree/HEAD/packages/common/issues/62881">#62881</a>)&quot; (#...</li>
<li><a href="ab6033979a"><code>ab60339</code></a> fix(http): add missing http options allowed in fetch API (<a href="https://github.com/angular/angular/tree/HEAD/packages/common/issues/62881">#62881</a>)</li>
<li><a href="ea1afec1e4"><code>ea1afec</code></a> build: move http_server and generate_api_docs into defaults2.bzl (<a href="https://github.com/angular/angular/tree/HEAD/packages/common/issues/62878">#62878</a>)</li>
<li><a href="f0fca612ee"><code>f0fca61</code></a> refactor(common): replace aio links to adev (<a href="https://github.com/angular/angular/tree/HEAD/packages/common/issues/62839">#62839</a>)</li>
<li><a href="622e10881f"><code>622e108</code></a> build: standardize usage of js_binary (<a href="https://github.com/angular/angular/tree/HEAD/packages/common/issues/62860">#62860</a>)</li>
<li><a href="2b0f3fc7cb"><code>2b0f3fc</code></a> build: remove all usages of <code>@​bazel/runfiles</code> (<a href="https://github.com/angular/angular/tree/HEAD/packages/common/issues/62805">#62805</a>)</li>
<li><a href="15670d8417"><code>15670d8</code></a> fix(http): propagate plain errors when parsing fails (<a href="https://github.com/angular/angular/tree/HEAD/packages/common/issues/62765">#62765</a>)</li>
<li><a href="b388f1e518"><code>b388f1e</code></a> build: remove all usages of the interop_deps attr for ts_project and ng_proje...</li>
<li><a href="1e9bfe54b1"><code>1e9bfe5</code></a> build: migrate to new toolchain usage for api goldens (<a href="https://github.com/angular/angular/tree/HEAD/packages/common/issues/62688">#62688</a>)</li>
<li><a href="276836ee73"><code>276836e</code></a> fix(http): do not display warnings <code>Angular detected that a </code>HttpClient` requ...</li>
<li>Additional commits viewable in <a href="https://github.com/angular/angular/commits/20.1.4/packages/common">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=@angular/common&package-manager=npm_and_yarn&previous-version=19.2.14&new-version=20.1.4)](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 merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@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>
2025-08-04 08:53:45 +00:00
..
2025-02-12 18:08:01 -05: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!