flutter_bin 1.1.3

SDKflutter
Platformwindowsmacos

A Flutter plugin to retrieve metadata from binary files (executable files) on desktop platforms. Currently supports retrieving file version and other metadata on Windows.

Flutter Binary File Metadata Plugin

pub package

A Flutter plugin to retrieve metadata from binary files (executable files) on desktop platforms. Currently supports Windows and macOS platforms.

Features

  • Retrieve file version information from binary files
  • Extract comprehensive metadata including:
    • Version
    • Product name
    • File description
    • Legal copyright
    • Original filename
    • Company name
  • Easy integration with file pickers

Getting Started

Add the package to your pubspec.yaml:

dependencies:
  flutter_bin: ^1.1.3

Usage

Basic Version Retrieval

import 'package:flutter_bin/flutter_bin.dart';

// Create an instance of the plugin
final flutterBin = FlutterBin();

// Get the version information
final String? version = await flutterBin.getBinaryFileVersion('C:\\path\\to\\file.exe');
print('File version: $version');

// On macOS
final String? macVersion = await flutterBin.getBinaryFileVersion('/Applications/Example.app');
print('macOS app version: $macVersion');

Full Metadata Retrieval

import 'package:flutter_bin/flutter_bin.dart';

// Create an instance of the plugin
final flutterBin = FlutterBin();

// Get comprehensive metadata (Windows)
final metadata = await flutterBin.getBinaryFileMetadata('C:\\path\\to\\file.exe');

// Or for macOS
final macMetadata = await flutterBin.getBinaryFileMetadata('/Applications/Example.app');

// Access specific properties
print('File version: ${metadata.version}');
print('Product name: ${metadata.productName}');
print('File description: ${metadata.fileDescription}');
print('Copyright: ${metadata.legalCopyright}');
print('Original filename: ${metadata.originalFilename}');
print('Company name: ${metadata.companyName}');

With FilePicker

import 'package:flutter_bin/flutter_bin.dart';
import 'package:file_picker/file_picker.dart';

// Create an instance of the plugin
final flutterBin = FlutterBin();

// Let the user select a file
FilePickerResult? result = await FilePicker.platform.pickFiles(
  type: FileType.any,
  allowMultiple: false,
);

if (result != null && result.files.single.path != null) {
  final filePath = result.files.single.path!;
  
  // Get metadata for the selected file
  final metadata = await flutterBin.getBinaryFileMetadata(filePath);
  print('File version: ${metadata.version}');
}

Metadata Fields

The plugin extracts the following metadata from binary files:

FieldDescriptionWindows SourcemacOS Source
versionFile version (e.g., 1.2.3.4)FileVersionCFBundleShortVersionString
productNameThe product nameProductNameCFBundleName
fileDescriptionDescription of the fileFileDescriptionCFBundleGetInfoString
legalCopyrightCopyright informationLegalCopyrightNSHumanReadableCopyright
originalFilenameOriginal name of the fileOriginalFilenameCFBundleExecutable
companyNameCompany or developer nameCompanyNameNot typically available

Platform Support

PlatformStatus
Windows✅ Supported
macOS✅ Supported
Linux❌ Planned

File Path Formats

Windows

Use standard Windows paths with double backslashes or forward slashes:

C:\\Program Files\\Application\\app.exe

or

C:/Program Files/Application/app.exe

macOS

For macOS applications (.app bundles):

/Applications/Example.app

or specific binaries within the bundle:

/Applications/Example.app/Contents/MacOS/Example

Example

The package includes a full example showcasing all features. To run the example:

cd example
flutter run

License

This project is licensed under the MIT License - see the LICENSE file for details.