Packaging an application
Learning objectives
- You know how to package a Flutter application for web deployment.
This example briefly outlines building a Flutter application for web deployment. For the example, we start with a new Flutter project, created with the flutter create
command.
flutter create deployment_demo
cd deployment_demo
When inside the root folder of the project (the folder that holds the pubspec.yaml
), we run the flutter build web
command with a set of arguments. Using --web-rendered
, we choose html
as the web-renderer, which creates a bit smaller application in terms of filesize. Using --base-href
, we set the base folder of the application to be /deploy-demo/
. Now, when we deploy the application, the application expects that it is in a path deploy-demo
of the server.
The
deploy-demo
relates to a path to which we'll later deploy the application.
flutter build web --web-renderer html --base-href "/deploy-demo/"
After the command has been run, there is a folder build
, which holds a folder web
.
flutter build web --web-renderer html --base-href "/deploy-demo/"
tree --dirsfirst -L 2
.
├── ...
├── build
│ └── web
├── ...
├── pubspec.yaml
└── README.md
The folder web
has the files that we wish to deploy online.
cd build/web/
ls
assets/ favicon.png flutter_service_worker.js index.html manifest.json
canvaskit/ flutter.js icons/ main.dart.js version.json