git_info_plus 0.0.5 copy "git_info_plus: ^0.0.5" to clipboard
git_info_plus: ^0.0.5 copied to clipboard

Get git information from within the Flutter application

git_info_plus #

pub package

Get git information from within the Flutter application.

screenshot-android screenshot-ios

Usage #

Dart #

final String branchName = await GitInfo.branchName;
final DateTime lastCommitDate = await GitInfo.lastCommitDate;
final String lastCommitHash = await GitInfo.lastCommitHash;
final String lastCommitHashShort = await GitInfo.lastCommitHashShort;
final String lastCommitMessage = await GitInfo.lastCommitMessage;

Setup #

Android #

You do not need to set this up.

Optional

  • Read environment valus if git command is null

iOS #

In order to use this library on IOS, you have to do some settings.

1. Add values in your info.plist

Key Type Value
GitBranchName String undefined
GitCommitDate String undefined
GitCommitHash String undefined
GitCommitHashShort String undefined
GitCommitMessage String undefined

You can also copy and paste these lines.

<key>GitBranchName</key>
<string>undefined</string>
<key>GitCommitDate</key>
<string>undefined</string>
<key>GitCommitHash</key>
<string>undefined</string>
<key>GitCommitHashShort</key>
<string>undefined</string>
<key>GitCommitMessage</key>
<string>undefined</string>

setup-ios-1

2. Enable Processes Info.plist File

BuildSettings > Processes Info.plist File
Change to YES

setup-ios-2

3-A. Add Run Script

BuildPhase >

Add new Run Script and paste these lines.

plistBuddy="/usr/libexec/PlistBuddy"
infoPlistFile="${TEMP_DIR}/Preprocessed-Info.plist"

branchName=$(git branch --show-current)
commitDate=$(git --no-pager log -1 --format="%ai")
commitHash=$(git rev-parse HEAD)
commitHashShort=$(git rev-parse --short HEAD)
commitMessage=$(git log -1 --pretty=%s)

$plistBuddy -c "Set :GitBranchName $branchName" $infoPlistFile
$plistBuddy -c "Set :GitCommitDate $commitDate" $infoPlistFile
$plistBuddy -c "Set :GitCommitHash $commitHash" $infoPlistFile
$plistBuddy -c "Set :GitCommitHashShort $commitHashShort" $infoPlistFile
$plistBuddy -c "Set :GitCommitMessage $commitMessage" $infoPlistFile

setup-ios-3

3-B. Add Input Files.

${TEMP_DIR}/Preprocessed-Info.plist

1
likes
120
pub points
42%
popularity

Publisher

unverified uploader

Get git information from within the Flutter application

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on git_info_plus