flutter_package_info_viewer 1.0.1
flutter_package_info_viewer: ^1.0.1 copied to clipboard
A robust Flutter package to display app version, device info, and build metadata (Git commit, branch, author). Perfect for debug menus.
Flutter Package Info Viewer 🚀 #
A robust Flutter package to display application version, dependencies, build information (Git commit, branch, author), dynamic configuration values, and Device Information. Perfect for debug menus, QA testing, and "About App" screens.
Features 🚀 #
- 📦 App Info: Displays Version, Build Number, Package ID, and Name.
- 📱 Device Info: Shows Model, OS Version, Battery Level, and IP Address.
- 🏗 Build Metadata: Shows Git Commit Hash, Branch, Author, and Build Date.
- 🔧 Config Viewer: Safely displays environment variables or config keys (masks sensitive keys automatically).
- 🧩 Dependency List: Automatically lists
dependenciesanddev_dependenciesfrom yourpubspec.yaml. - 🎨 Fully Customizable: Change colors to match your app's theme.
- 📤 Share/Copy: Share all debug info as a formatted JSON or copy individual values.
- 🐞 Debug Button: A handy floating/inline button to trigger the info screen.
Installation 💿 #
Add this to your pubspec.yaml:
dependencies:
flutter_package_info_viewer: ^1.0.0
Then run:
flutter pub get
Setup (Crucial Step for Metadata) ⚡ #
To see accurate Git Commit, Build Date, and Dependency versions, you must generate a build-info.json file.
- Create an
assetsfolder in your project root if it doesn't exist. - Run the generation script from your project root:
dart run flutter_package_info_viewer:generate_build_info
- Add the generated file to your
pubspec.yaml:
flutter:
assets:
- assets/build-info.json
Usage 🛠 #
1. The Info Screen (PackageInfo) #
Since loading assets is asynchronous, it is recommended to use a FutureBuilder to load the build-info.json.
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_package_info_viewer/flutter_package_info_viewer.dart';
// ... inside your widget ...
@override
Widget build(BuildContext context) {
return FutureBuilder<String>(
future: rootBundle.loadString('assets/build-info.json'),
builder: (context, snapshot) {
BuildInfo? buildInfo;
if (snapshot.hasData) {
try {
buildInfo = BuildInfo.fromJson(json.decode(snapshot.data!));
} catch (e) {
debugPrint("Build info error: $e");
}
}
return PackageInfo(
buildInfo: buildInfo,
environmentName: 'STAGING',
configValues: {
'API_URL': 'https://api.dev.com',
'STRIPE_KEY': 'sk_test_51Mz...',
},
// Theme Customization
primaryColor: Colors.deepPurple,
backgroundColor: Colors.white,
);
},
);
}
2. The Debug Button (DebugButton) #
A pre-styled button to easily navigate to your Info Screen.
DebugButton(
visible: kDebugMode, // Only show in debug mode
onPress: () => Navigator.push(
context,
MaterialPageRoute(builder: (context) => const PackageInfoScreen()),
),
)
Props 📚 #
PackageInfo #
| Prop Name | Type | Default | Description |
|---|---|---|---|
buildInfo |
BuildInfo? |
null |
Contains commit info and dependency list. |
pubspec |
Map? |
null |
Fallback map for dependencies if buildInfo is not used. |
configValues |
Map<String, String>? |
{} |
Key-value pairs (Env vars) to display. |
environmentName |
String |
'UNKNOWN' |
Shows at the top of the Config section. |
primaryColor |
Color? |
Theme primary |
Color for buttons and headers. |
backgroundColor |
Color? |
Theme scaffold |
Main screen background color. |
cardBackgroundColor |
Color? |
Theme card |
Background color for info cards. |
textColor |
Color? |
Theme body |
Main text color. |
secondaryTextColor |
Color? |
Grey |
Secondary/Label text color. |
License: MIT