flutter_shell 0.0.2
flutter_shell: ^0.0.2 copied to clipboard
A cross-platform utility to execute shell commands in Dart/Flutter apps.
Flutter Shell #
A cross-platform utility for executing shell commands in Dart/Flutter apps.
🔧 Features #
- Supports Windows (
powershell/cmd.exe) - Supports macOS/Linux (
zsh,bash,sh) - Gracefully rejects execution on Android/iOS with a clear message
- Executes multiple commands sequentially with
&&chaining - Returns trimmed standard output or detailed error messages
- Simple static method API for quick integration
🚀 Usage #
import 'package:flutter_shell/flutter_shell.dart';
void main() async {
final result = await ShellExecutor.executeCommands([
'echo Hello',
'echo World',
]);
print(result);
}
🧩 API Reference #
ShellExecutor.executeCommands #
static Future<String> executeCommands(List<String> commands)
-
Executes the provided list of shell commands sequentially in a platform-appropriate shell.
-
Returns a
Future<String>which is:- The trimmed standard output (
stdout) on success. - An error message string prefixed with ❌ on failure.
- A platform-specific unsupported message on mobile platforms.
- The trimmed standard output (
🛠️ Installation #
Add the package to your pubspec.yaml:
dependencies:
flutter_shell: ^0.0.1
Then run:
flutter pub get
📂 Example #
Example CLI usage in bin/main.dart:
import 'package:flutter_shell/flutter_shell.dart';
Future<void> main() async {
print('🚀 Running ShellExecutor from terminal...\n');
final result = await ShellExecutor.executeCommands([
'echo Hello',
'echo from flutter_shell!',
]);
print('🔧 Command output:\n$result');
}
⚠️ Supported Platforms #
- Windows, macOS, Linux
- Not supported: Android and iOS (returns an error message)
💰 Support #
If you find this project helpful, consider sponsoring me on GitHub 💖
🤝 Contributing #
Contributions and suggestions are welcome! Feel free to open issues or submit pull requests.
📄 License #
MIT License © 2025 Your Name