LiveShell.forProject constructor

LiveShell.forProject({
  1. required LiveOptions options,
  2. required LiveShellDispatch dispatch,
  3. required List<LiveShellCommand> commands,
})

A shell for the Flutter project in the current directory.

Throws a LiveCommandException outside a Flutter project.

Implementation

factory LiveShell.forProject({
  required LiveOptions options,
  required LiveShellDispatch dispatch,
  required List<LiveShellCommand> commands,
}) {
  final LiveRunner runner = LiveRunner();
  final String root = runner.project.root;
  final String? address = options.uri;
  final Uri? uri = address == null
      ? null
      : LiveDiscovery.normalizeVmServiceUri(address);
  if (address != null && uri == null) {
    throw LiveCommandException('Not a VM service address: $address');
  }
  final LiveSession session = LiveSession(
    runner,
    timeout: options.timeout,
    uri: uri,
  );
  runner.session = session;
  return LiveShell(
    runner: runner,
    session: session,
    dispatch: dispatch,
    commands: commands,
    options: options,
    appCommands: LiveManifest.load(),
    input: stdin,
    output: stdout,
    historyPath: '$root/.dart_tool/nylo/live_history',
    interrupts: _sigint(),
  );
}