text stringlengths 1 474 |
|---|
<topic_start>Web support for Flutter |
Flutter’s web support delivers the same experiences on the web as on mobile. |
Building on the portability of Dart, the power of the web platform and the |
flexibility of the Flutter framework, you can now build apps for iOS, Android, |
and the browser from the same codebase. You can compile existing Flutter code |
written in Dart into a web experience because it is exactly the same Flutter |
framework and web is just another device target for your app.Adding web support to Flutter involved implementing Flutter’s |
core drawing layer on top of standard browser APIs, in addition |
to compiling Dart to JavaScript, instead of the ARM machine code that |
is used for mobile applications. Using a combination of DOM, Canvas, |
and WebAssembly, Flutter can provide a portable, high-quality, |
and performant user experience across modern browsers. |
We implemented the core drawing layer completely in Dart |
and used Dart’s optimized JavaScript compiler to compile the |
Flutter core and framework along with your application |
into a single, minified source file that can be deployed to |
any web server.While you can do a lot on the web, |
Flutter’s web support is most valuable in the |
following scenarios:Not every HTML scenario is ideally suited for Flutter at this time. |
For example, text-rich, flow-based, static content such as blog articles |
benefit from the document-centric model that the web is built around, |
rather than the app-centric services that a UI framework like Flutter |
can deliver. However, you can use Flutter to embed interactive |
experiences into these websites.For a glimpse into how to migrate your mobile app to web, see |
the following video:<topic_end> |
<topic_start> |
Resources |
The following resources can help you get started: |
<topic_end> |
<topic_start>Add Web devtools for Flutter |
To choose the guide to add Web devtools to your Flutter configuration, |
click the Getting Started path you followed. |
<topic_end> |
<topic_start>Building a web application with Flutter |
This page covers the following steps for getting started with web support:<topic_end> |
<topic_start> |
Requirements |
To create a Flutter app with web support, |
you need the following software:For more information, see the web FAQ.<topic_end> |
<topic_start> |
Create a new project with web support |
You can use the following steps |
to create a new project with web support.<topic_end> |
<topic_start> |
Set up |
Run the following commands to use the latest version of the Flutter SDK:warning Warning |
Running flutter channel stable replaces your current version of Flutter |
with the stable version and can take time if your connection is slow. |
After this, running flutter upgrade upgrades your install to the latest |
stable. Returning to another channel (beta or master) requires calling |
flutter channel <channel> explicitly.If Chrome is installed, |
the flutter devices command outputs a Chrome device |
that opens the Chrome browser with your app running, |
and a Web Server that provides the URL serving the app.In your IDE, you should see Chrome (web) in the device pulldown.<topic_end> |
<topic_start> |
Create and run |
Creating a new project with web support is no different |
than creating a new Flutter project for other platforms.<topic_end> |
<topic_start>IDE |
Create a new app in your IDE and it automatically |
creates iOS, Android, desktop, and web versions of your app. |
From the device pulldown, select Chrome (web) |
and run your app to see it launch in Chrome.<topic_end> |
<topic_start>Command line |
To create a new app that includes web support |
(in addition to mobile support), run the following commands, |
substituting my_app with the name of your project:To serve your app from localhost in Chrome, |
enter the following from the top of the package:info Note |
If there aren’t any other connected devices, |
the -d chrome is optional.The flutter run command launches the application using the |
development compiler in a Chrome browser.warning Warning |
Hot reload is not supported in a web browser |
Currently, Flutter supports hot restart, |
but not hot reload in a web browser.<topic_end> |
<topic_start> |
Build |
Run the following command to generate a release build:If you receive a not supported error, run the following command:A release build uses dart2js |
(instead of the development compiler) |
to produce a single JavaScript file main.dart.js. |
You can create a release build using release mode |
(flutter run --release) or by using flutter build web. |
This populates a build/web directory |
with built files, including an assets directory, |
which need to be served together.You can also include --web-renderer html or --web-renderer canvaskit to |
select between the HTML or CanvasKit renderers, respectively. For more |
information, see Web renderers.To learn more, see |
Build and release a web app.<topic_end> |
<topic_start> |
Add web support to an existing app |
To add web support to an existing project |
created using a previous version of Flutter, |
run the following command |
from your project’s top-level directory:If you receive a not supported error, run the following command: |
<topic_end> |
<topic_start>Web FAQ |
<topic_end> |
<topic_start> |
What scenarios are ideal for Flutter on the web? |
Not every web page makes sense in Flutter, but we think Flutter is particularly |
suited for app-centric experiences:At this time, Flutter is not suitable for static websites with text-rich |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.