Skip to content
play

GitHub Action

flutter-unused-files

v1.0.12 Latest version

flutter-unused-files

play

flutter-unused-files

Check for unused files and assets in a Flutter project

Installation

Copy and paste the following snippet into your .yml file.

              

- name: flutter-unused-files

uses: ZimboPro/[email protected]

Learn more about this action in ZimboPro/flutter-unused-files

Choose a version

flutter-unused-files

Check for unused files and assets in a Flutter project

How it works

It will take the asset and/or file name and search all the files to see if it is referenced. If it is not, it is seen as an unused asset or file.

Inputs

  • dir - Optional - Relative path to the Flutter app/package that needs to checked for unused assets or files. It will expect a lib folder to be present at the path e.g. dir: packages/my-package. Default: .
  • warning - Optional - Instead of exiting with an error, just list the unused assets/files as a warning. Default: false
  • assets - Optional - Whether the assets checks should be ignored. Needs to be considered if app has displays the asset based off of a API response. Default: false

Example

Normal App

name: Check for unused files
on:
  pull_request:
    types: [opened, edited, synchronize]

jobs:
  check_files:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: ZimboPro/[email protected]

Ignore Assets

name: Check for unused files
on:
  pull_request:
    types: [opened, edited, synchronize]

jobs:
  check_files:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: ZimboPro/[email protected]
        with:
            assets: true

Specific package

name: Check for unused files
on:
  pull_request:
    types: [opened, edited, synchronize]

jobs:
  check_files:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: ZimboPro/[email protected]
        with:
            dir: packages/my-package

Output warnings instead of an error

name: Check for unused files
on:
  pull_request:
    types: [opened, edited, synchronize]

jobs:
  check_files:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: ZimboPro/[email protected]
        with:
            warning: true