Skip to content

[ Widget Preview ] Report an error if a Chromium device isn't present #173960

@bkonyi

Description

@bkonyi

If flutter widget-preview start is run on 3.35.{0,1} without a discoverable Chromium browser installed (i.e., Chrome or Edge), the tool will crash:

Thread 0 main threadStateError: Bad state: No element
at List.first(growable_array.dart:352)
at WidgetPreviewStartCommand.runPreviewEnvironment(widget_preview.dart:372)
at <asynchronous gap>(async)
at WidgetPreviewStartCommand.runCommand(widget_preview.dart:312)
at <asynchronous gap>(async)
at FlutterCommand.run.<anonymous closure>(flutter_command.dart:1581)
at <asynchronous gap>(async)
at AppContext.run.<anonymous closure>(context.dart:154)
at <asynchronous gap>(async)
at CommandRunner.runCommand(command_runner.dart:212)
at <asynchronous gap>(async)
at FlutterCommandRunner.runCommand.<anonymous closure>(flutter_command_runner.dart:503)
at <asynchronous gap>(async)
at AppContext.run.<anonymous closure>(context.dart:154)
at <asynchronous gap>(async)
at FlutterCommandRunner.runCommand(flutter_command_runner.dart:438)
at <asynchronous gap>(async)
at run.<anonymous closure>.<anonymous closure>(runner.dart:98)
at <asynchronous gap>(async)
at AppContext.run.<anonymous closure>(context.dart:154)
at <asynchronous gap>(async)
at main(executable.dart:101)
at <asynchronous gap>(async)

Instead of crashing, we should be printing an error and throwing ToolExit informing users that they must have Chrome installed (or, in future releases with --web-server support, that they should launch via the web server device).

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work lista: widget previewsIssues related to the Widget Previewer toolingfound in release: 3.35Found to occur in 3.35team-toolOwned by Flutter Tool teamtriaged-toolTriaged by Flutter Tool team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions