搜尋套件、儲存庫與 APP 分類

套件詳情v2.2.1

build_version

一個用於將套件版本提取到程式碼中的建構器。

AndroidiOSmacOSWindowsLinux
近 30 天下載
13.9萬
喜歡數
33
Pub 分數
150

安裝套件

flutter pub add build_version

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

build_version 是一個 Flutter/Dart 套件,在建構過程中產生包含目前套件版本的 Dart 檔案。它從 pubspec.yaml 提取版本資訊,並作為常數提供給應用程式程式碼,讓執行時期能無需手動更新即可存取版本細節。這對於除錯、記錄或在 UI 中顯示版本號碼特別有用。此套件與 build_runner 完全整合,並支援 Android、iOS、macOS、Windows 及 Linux 等多個平台。

適用情境

  • 在設定中顯示應用版本
  • 記錄版本資訊以用於除錯
  • 自動化程式碼中的版本注入
  • 在建構中追蹤發行版本
  • 在應用邏輯中啟用版本檢查

主要特色

  • 自動產生版本常數
  • 從 pubspec.yaml 提取版本
  • 支援多個平台
  • 與 build_runner 集成
  • 所需設定最少

適合對象

  • 需要執行時間版本存取權限的應用
  • 希望實現自動化版本管理的團隊
  • 使用 build_runner 工作流程的專案
  • 尋求最小樣板程式碼的開發者
  • 需要版本元資料的 CI/CD 流水線

使用建議

  • 需要設定 build_runner
  • 版本在建構後為靜態
  • 不適用於動態版本變更
  • 在版本更新時可能需要重新建構
  • 僅限 pubspec.yaml 中的 version 欄位

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

CI Pub Package package publisher

Include the version of your package in our source code.

  1. Add build_version to pubspec.yaml. Also make sure there is a version field.

    name: my_pkg
    version: 1.2.3
    dev_dependencies:
      build_runner: ^1.0.0
      build_version: ^2.0.0
    
  2. Run a build.

    > dart run build_runner build
    

    lib/src/version.dart will be generated with content:

    // Generated code. Do not modify.
    const packageVersion = '1.2.3';
    

To change the path of the generated file, create a build.yaml in the root of your package. By changing the output option of this builder, the path can be customized:

targets:
  $default:
    builders:
      build_version:
        options:
          output: lib/src/custom/path/to/version.dart

所屬分類

依賴

依賴清單 4 項

原始碼儲存庫

使用此套件的專案