useStorageEmulator method
Changes this instance to point to a Storage emulator running locally.
Set the host
of the local emulator, such as "localhost"
Set the port
of the local emulator, such as "9199" (port 9199 is default for storage package)
Note: Must be called immediately, prior to accessing storage methods. Do not use with production credentials as emulator traffic is not encrypted.
Implementation
Future<void> useStorageEmulator(String host, int port) async {
assert(host.isNotEmpty);
assert(!port.isNegative);
String mappedHost = host;
// Android considers localhost as 10.0.2.2 - automatically handle this for users.
if (defaultTargetPlatform == TargetPlatform.android && !kIsWeb) {
if (mappedHost == 'localhost' || mappedHost == '127.0.0.1') {
// ignore: avoid_print
print('Mapping Storage Emulator host "$mappedHost" to "10.0.2.2".');
mappedHost = '10.0.2.2';
}
}
await _delegate.useStorageEmulator(mappedHost, port);
}