useEmulator method

  1. @Deprecated('Will be removed in future release. ' 'Use useStorageEmulator().')
Future<void> useEmulator({
  1. required String host,
  2. required int port,
})
inherited

Changes this instance to point to a Storage emulator running locally.

Set the host (ex: localhost) and port (ex: 9199) of the local emulator.

Note: Must be called immediately, prior to accessing storage methods. Do not use with production credentials as emulator traffic is not encrypted.

Implementation

@Deprecated(
  'Will be removed in future release. '
  'Use useStorageEmulator().',
)
Future<void> useEmulator({required String host, required 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 useStorageEmulator(host, port);
}