clean_all_flutter_build 1.0.1

  • Readme
  • Changelog
  • Installing
  • 43

用于批量清理 flutter 下的所有构建文件

使用方法 #

在使用前你必须保证自己将 dart 和 pub 配置到了环境变量中,否则无法使用

  1. $ pub get

  2. $ dart bin/clean_flutter_build_file.dart ~/code/flutter //这里的第三个就是你要清理的 flutter 目录

使用 pub global #

$ pub global activate clean_all_flutter_build

$ clean_flutter_build_file ${flutter_project_path}

说明 #

我这里随着进入 flutter 开发的领域越来越长,硬盘中积攒了大量的 demo,所以不可避免的占用了大量的磁盘空间(我这里清理前大概在 20G 左右)

所以简单写了一个 dart 脚本工具用于清理,清理后占用空间缩小到不到 1G,这还是有公司项目的大量资源文件的情况下,以前每个 demo 大概需要 100M 左右,主要来自于 iOS 的库文件


1. flutter clean #

使用 flutter clean 删除 flutter 生成的构建文件,这部分包含 build 目录和 .dart_tool 目录

实际的开发项目中会包含很多自动生成的文件,这些文件只需要再次运行 flutter packages get 或 flutter run 就会自动生成,所以一般不会进入版本控制工具

2. iOS 的大文件 #

这里删除了 iOS 中一些较大的文件,主要包括

  • /ios/Flutter/Flutter.framework
  • /ios/Flutter/App.framework
  • /ios/Flutter/flutter_assets

如果还需要删除其他的文件,可以考虑你项目生成时的 .gitignore 文件,其中包括了所有可以自动生成的文件,这里没有一一加入

1.0.0 #

  • Initial version, created by Stagehand

Use this package as an executable

1. Install it

You can install the package from the command line:

$ pub global activate clean_all_flutter_build

2. Use it

The package has the following executables:

$ clean_flutter_build_file

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  clean_all_flutter_build: ^1.0.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:clean_all_flutter_build/clean_all_flutter_build.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4

Health issues and suggestions

Document public APIs. (-1 points)

4 out of 4 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/clean_all_flutter_build.dart. (-1.49 points)

Analysis of lib/clean_all_flutter_build.dart reported 3 hints:

line 15 col 21: Avoid empty catch blocks.

line 22 col 15: Unnecessary new keyword.

line 25 col 3: Future results in async function bodies must be awaited or marked unawaited using package:pedantic.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and clean_all_flutter_build.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
shell ^1.0.1 1.0.1
Transitive dependencies
file 5.1.0
intl 0.16.1
meta 1.1.8
path 1.6.4
platform 2.2.1
process 3.0.12
Dev dependencies
test ^1.0.0