Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ class ResidentWebRunner extends ResidentRunner {
Completer<void> appStartedCompleter,
bool allowExistingDdsInstance = false,
bool enableDevTools = false, // ignored, we don't yet support devtools for web
bool needsFullRestart = true,
}) async {
if (_chromiumLauncher != null) {
final Chromium chrome = await _chromiumLauncher.connectedInstance;
Expand Down
5 changes: 5 additions & 0 deletions packages/flutter_tools/lib/src/resident_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1178,11 +1178,16 @@ abstract class ResidentRunner extends ResidentHandlers {
String route,
});

/// Connect to a flutter application.
///
/// [needsFullRestart] defaults to `true`, and controls if the frontend server should
/// compile a full dill. This should be set to `false` if this is called in [ResidentRunner.run], since that method already perfoms an initial compilation.
Future<int> attach({
Completer<DebugConnectionInfo> connectionInfoCompleter,
Completer<void> appStartedCompleter,
bool allowExistingDdsInstance = false,
bool enableDevTools = false,
bool needsFullRestart = true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a doc comment on what needsFullRestart is for?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doc comments should go on the method itself. Look at the flutter framework for examples of how parameters are documented. Usually something like:

/// One sentence summary about what foo does
///
/// [bar] is blah blah.
void foo(String bar);
```

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was following this particular example which apparently to have more than one line is acceptable. About going in the method agree I should move this up. https://dart.dev/guides/language/effective-dart/documentation#avoid-redundancy-with-the-surrounding-context

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats fine, but it needs to go on the method itself and not the parameter

});

@override
Expand Down
1 change: 1 addition & 0 deletions packages/flutter_tools/lib/src/run_cold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ class ColdRunner extends ResidentRunner {
Completer<void> appStartedCompleter,
bool allowExistingDdsInstance = false,
bool enableDevTools = false,
bool needsFullRestart = true,
}) async {
_didAttach = true;
try {
Expand Down
4 changes: 3 additions & 1 deletion packages/flutter_tools/lib/src/run_hot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ class HotRunner extends ResidentRunner {
Completer<void> appStartedCompleter,
bool allowExistingDdsInstance = false,
bool enableDevTools = false,
bool needsFullRestart = true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding it here, I would add it to the ResidentRunner base class and document it. While its technically allowed to add new named parameters to overriden methods on subclasses, I think you should generally avoid that practice. It occasionally leads to surprises when a developer can't autocomplete a parameter due to the static type of a variable.

}) async {
_didAttach = true;
try {
Expand Down Expand Up @@ -276,7 +277,7 @@ class HotRunner extends ResidentRunner {
}

final Stopwatch initialUpdateDevFSsTimer = Stopwatch()..start();
final UpdateFSReport devfsResult = await _updateDevFS(fullRestart: true);
final UpdateFSReport devfsResult = await _updateDevFS(fullRestart: needsFullRestart);
_addBenchmarkData(
'hotReloadInitialDevFSSyncMilliseconds',
initialUpdateDevFSsTimer.elapsed.inMilliseconds,
Expand Down Expand Up @@ -436,6 +437,7 @@ class HotRunner extends ResidentRunner {
connectionInfoCompleter: connectionInfoCompleter,
appStartedCompleter: appStartedCompleter,
enableDevTools: enableDevTools,
needsFullRestart: false,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ class FakeHotRunner extends Fake implements HotRunner {
Completer<void> appStartedCompleter,
bool allowExistingDdsInstance = false,
bool enableDevTools = false,
bool needsFullRestart = true,
}) {
return onAttach(connectionInfoCompleter, appStartedCompleter, allowExistingDdsInstance, enableDevTools);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter_tools/test/general.shard/hot_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ void main() {
final int exitCode = await HotRunner(devices,
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
target: 'main.dart',
).attach();
).attach(needsFullRestart: false);
expect(exitCode, 2);
}, overrides: <Type, Generator>{
HotRunnerConfig: () => TestHotRunnerConfig(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1482,6 +1482,7 @@ class TestRunner extends Fake implements ResidentRunner {
Completer<void> appStartedCompleter,
bool allowExistingDdsInstance = false,
bool enableDevTools = false,
bool needsFullRestart = true,
}) async => null;
}

Expand Down