bindInstance function
void
bindInstance(
- SuperuserInterface? suInterface
Attach specified suInterface as data source of superuser
property.
If suInterface is null, it binds platform specified
SuperuserInterface automatically.
When this invoked in neither Windows, macOS or Linux platform, it throws UnsupportedError.
Implementation
void bindInstance(SuperuserInterface? suInterface) {
if (!Platform.isWindows && !Platform.isMacOS && !Platform.isLinux) {
throw UnsupportedError("Unknown platform");
}
late SuperuserInterface newInst;
if (suInterface == null) {
// Denote null interface as uses default implementation.
if (Platform.isWindows) {
newInst = WindowsSuperuser();
} else if (Platform.isMacOS || Platform.isLinux) {
newInst = UnixSuperuser();
}
} else {
newInst = suInterface;
}
SuperuserInstance._instance = newInst;
}