getFlutterPiArgs function
Returns the argument list of the running flutter-pi program by reading the /proc/PID/cmdline data. For a non flutter-pi environment an empty list will be returned.
Implementation
List<String> getFlutterPiArgs() {
if (!isFlutterPiEnv()) {
return const <String>[];
}
if (_flutterPiArgs.isEmpty) {
var cmd = File('/proc/${getPID()}/cmdline').readAsBytesSync();
var index = 0;
for (var i = 0; i < cmd.length; ++i) {
if (cmd[i] == 0) {
_flutterPiArgs
.add(String.fromCharCodes(Uint8List.sublistView(cmd, index, i)));
index = i + 1;
}
}
}
return List.unmodifiable(_flutterPiArgs);
}