A command-line application provide an load optimization solution for flutter web

Overview

一个命令行工具,针对flutter web加载慢和缓存问题提供了一套解决方案。

功能

  • 通过大文件分片和资源文件cdn化方式,优化flutter web页面加载慢问题。
  • 通过资源文件hash化,解决浏览器强缓存导致功能无法更新问题。

开始

局部安装

dev_dependencies:
  flutter_web_optimizer: ^1.0.0

全局安装

启用

flutter pub global activate flutter_web_optimizer

停用

flutter pub global deactivate flutter_web_optimizer

用法

app_web_optimizer

在项目的根目录下执行plugin命令和optimize命令

plugin 命令

plugin命令实现自动生成插件模板文件,可以在插件里面实现将资源文件上传至文件服务器上,例如腾讯的cos、阿里的oss;

flutter pub run flutter_web_optimizer plugin --path scripts/test_plugin.dart
or
flutter_web_optimizer plugin --path scripts/test_plugin.dart
  • path参数必传,指自定义plugin文件的位置。

optimize 命令

optimize命令针对flutter build web的打包产物作了大文件分片下载、资源文件hash化和资源文件cdn化三个优化。

flutter pub run flutter_web_optimizer optimize --asset-base http://192.168.101.93:9091/app/ --plugin scripts/test_plugin.dart
or 
flutter_web_optimizer optimize --asset-base http://192.168.101.93:9091/app/ --plugin scripts/test_plugin.dart
  • asset-base参数必传,一般是文件服务器上存储对应资源文件的地址,地址必须是/结尾
  • web-output参数非必传,指flutter web build的打包产物的文件夹位置,以当前命令行窗口为根路径,默认是build/web
  • plugin参数非必传,指插件文件位置,若需要将资源文件上传至服务器,则必传。cos_upload_plugin.dart文件已经实现了一套将资源文件上传至腾讯的cos的功能,可以参考。
You might also like...

Scaff is a simple command-line utility for generating Dart and Flutter components from template files.

Introduction Scaffold Generator for Dart and Flutter. scaff is a simple command-line utility for generating Dart and Flutter components from template

Jul 17, 2022

Command Line Interface (CLI) for Lucifer

Lucy Command Line Interface (CLI) for Lucifer. Installation Activate command line from your terminal with this command. pub global activate lucy Usage

Dec 16, 2021

A Nerolab Command Line Interface for Dart created by Nerolab

A Nerolab Command Line Interface for Dart created by Nerolab

Nerolab CLI Nerolab Command Line Interface for Dart. Special thanks to GroovinChip with groovin_cli and very_good_cli. Installing dart pub global acti

Jan 19, 2022

☄ Anime/Manga command-line interface backed up by Tenka.

☄ Anime/Manga command-line interface backed up by Tenka.

Yukimi ☄ Anime/Manga command-line interface backed up by Tenka. By using this project, you agree to the usage policy. Installation Pre-built binaries

Jan 6, 2023

Interactive command line interface Couchbase Lite REPL utility built with the Dart

Interactive command line interface Couchbase Lite REPL utility built with the Dart

Couchbase Lite Dart CLI Interactive command line interface Couchbase Lite REPL utility built with the Dart programming language. This code uses the cb

Jul 20, 2022

This is a simple Gantt chart generator written as Dart command line tool.

This is a simple Gantt chart generator written as Dart command line tool.

Gantt Chart Generator This is a simple Gantt chart generator written as Dart command line tool. Currently the tool generates an HTML/CSS Gantt chart.

Apr 26, 2022

A font loader to download, cache and load web fonts in flutter with support for Firebase Cloud Storage.

A font loader to download, cache and load web fonts in flutter with support for Firebase Cloud Storage.

Dynamic Cached Fonts A simple, easy to use yet customizable font loader to use web fonts. Demo: https://sidrao2006.github.io/dynamic_cached_fonts 👋 I

Dec 21, 2022

A flutter widget that provides pull-down refresh and pull-up load.

A flutter widget that provides pull-down refresh and pull-up load.

flutter_easyrefresh English | 中文 正如名字一样,EasyRefresh很容易就能在Flutter应用上实现下拉刷新以及上拉加载操作,它支持几乎所有的Flutter控件。它的功能与Android的SmartRefreshLayout很相似,同样也吸取了很多三方库的优点。

Jan 8, 2023

A small library support load infinite for ListView - GridView on Flutter.

A small library support load infinite for ListView - GridView on Flutter.

Paging A Flutter package that supports pagination(load infinite) for ListView, GridView Demo DataSource PageKeyedDataSource To create a PagingListView

Dec 4, 2022
Comments
  • 不支持Flutter 3.3.10:Can't load Kernel binary: Invalid SDK hash.

    不支持Flutter 3.3.10:Can't load Kernel binary: Invalid SDK hash.

    [✓] Flutter (Channel stable, 3.3.10, on macOS 13.0 22A380 darwin-arm (Rosetta),
        locale zh-Hans-CN)
    environment:
      sdk: '>=2.18.5 <3.0.0'
    
    Can't load Kernel binary: Invalid SDK hash.
    No active package flutter_web_optimizer.
    

    现在是不是不支持 Flutter 3.3.10 ? 怎么跳过SDK版本检查,不然的话以后flutter版本有更新插件没有更新就不能用了吧?

    opened by sunjianan9900 7
  • 为什么使用后没有加载分包后的main.dart.js

    为什么使用后没有加载分包后的main.dart.js

    命令成功运行了,因为没有上传OSS,我就把上传OSS的脚本取消了,只把文件生成到本地

    flutter_web_optimizer optimize --asset-base http://127.0.0.1:8882/ --plugin scripts/upload.dart

    但是我看 flutter_service_worker.js 里面也没有修改文件名 然后我运行完分割脚本,用python在 build/web/ 目录下启动 python -m http.server 8882 结果打不开,错误是找不到 main.dart.js ,是哪一步有问题呢?不应该是去找main.dart.js 吧?

    image image

    求指教,我先不想自动上传,先手动上传也可以

    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel stable, 3.3.9, on macOS 13.0 22A380 darwin-arm (Rosetta),
        locale zh-Hans-CN)
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    [✓] Xcode - develop for iOS and macOS (Xcode 14.0)
    [✓] Chrome - develop for the web
    [✓] Android Studio (version 2021.3)
    [✓] IntelliJ IDEA Ultimate Edition (version 2018.1.5)
    [✓] IntelliJ IDEA Ultimate Edition (version 2021.1.3)
    [✓] VS Code (version 1.73.0)
    
    
    opened by sunjianan9900 6
Owner
Barry
Barry
A new flutter plugin to disable battery optimization on android.

android_battery_optimization Battery Optimization can only be disabled by the user so this plugin can check whether it's disabled and open the setting

jinyus 1 Jan 12, 2022
Imgix package for Dart. Imgix is a CDN service with support for realtime image processing and optimization.

Imgix package for Dart. Imgix is a CDN service with support for realtime image processing and optimization.

Nikkei Inc. 3 Jan 24, 2022
Listen to remote Flutter GTK application instances' command-line arguments and file open requests.

gtk_application This package allows the primary Flutter GTK application instance to listen to remote application instances' command-line arguments and

null 12 Dec 15, 2022
changelog.dart provides a library and a command-line application to manage in the correct way the git metadata to build the changelog between two release

changelog.dart ?? changelog.dart: a collection of tools to manages in a fashion way a repository as maintainer. ?? Project Homepage Table of Content I

Vincenzo Palazzo 7 Dec 18, 2022
Package your Flutter app into OS-specific bundles (.dmg, .exe, etc.) via Dart or the command line.

flutter_distributor Package your Flutter app into OS-specific bundles (.dmg, .exe, etc.) via Dart or the command line. The flutter_distributor source

LeanFlutter 416 Dec 24, 2022
Screenshots - A command line utility and package for capturing screenshots for Flutter

A screenshot image with overlaid status bar placed in a device frame. For an example of images generated with Screenshots on a live app in both stores

Maurice McCabe 258 Nov 22, 2022
An incredible command line interface for Flutter.

Fast CLI An incredible command line interface for Flutter. It allows you to create your own CLI without coding a line. With this CLI, you can create y

Pedro Bissonho 41 Jul 12, 2022
shared_versions is a command line tool that allow share the versions for multiple packages in Flutter

shared_versions shared_versions is a CLI tool that allow share the versions for multiple packages in Flutter. Usage shared_versions will match the pac

Littlegnal 6 Sep 20, 2022
This is a command-line app written on dart language for flutter applications that will help you to generate some boilerplate code

dart-generator Manual installation: 1- generate a platform executable from code dart compile exe main.dart -o generator this will generate a new gene

One Studio 11 Oct 26, 2022
Icons Launcher - A command-line tool that simplifies the task of updating your Flutter app's launcher icon.

Icons Launcher - A command-line tool that simplifies the task of updating your Flutter app's launcher icon. Full flexibility allows you to only update the launcher icon for specific platforms as needed.

Mrr Hak 48 Nov 17, 2022