Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
add a const runtimes key
  • Loading branch information
rxlabz committed Oct 29, 2020
commit 0b90df3ed45cf43bef842f962e43e450af840a2a
16 changes: 8 additions & 8 deletions dart/lib/src/protocol/contexts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Contexts extends MapView {
}) : super({
Device.type: device,
OperatingSystem.type: operatingSystem,
'runtimes': runtimes ?? [],
runtimesType: runtimes ?? [],
App.type: app,
Browser.type: browser,
Gpu.type: gpu,
Expand All @@ -47,11 +47,11 @@ class Contexts extends MapView {
/// Describes a list of runtimes in more detail
/// (for instance if you have a Flutter application running
/// on top of Android).
List<Runtime> get runtimes => List.unmodifiable(this['runtimes']);
List<Runtime> get runtimes => List.unmodifiable(this[runtimesType]);

void addRuntime(Runtime runtime) => this['runtimes'].add(runtime);
void addRuntime(Runtime runtime) => this[runtimesType].add(runtime);

void removeRuntime(Runtime runtime) => this['runtimes'].remove(runtime);
void removeRuntime(Runtime runtime) => this[runtimesType].remove(runtime);

/// App context describes the application.
///
Expand Down Expand Up @@ -116,12 +116,12 @@ class Contexts extends MapView {
}
break;

case 'runtimes':
case runtimesType:
if (runtimes != null) {
if (runtimes.length == 1) {
final runtime = runtimes[0];
if (runtime != null) {
final key = runtime.key ?? 'runtime';
final key = runtime.key ?? Runtime.type;
json[key] = runtime.toJson();
}
} else if (runtimes.length > 1) {
Expand All @@ -138,7 +138,7 @@ class Contexts extends MapView {
}

json[key] = runtime.toJson()
..addAll(<String, String>{'type': 'runtime'});
..addAll(<String, String>{'type': Runtime.type});
}
}
}
Expand Down Expand Up @@ -174,7 +174,7 @@ class Contexts extends MapView {
App.type,
Device.type,
OperatingSystem.type,
'runtimes',
runtimesType,
Runtime.type,
Gpu.type,
Browser.type,
Expand Down
2 changes: 2 additions & 0 deletions dart/lib/src/protocol/runtime.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const runtimesType = 'runtimes';

/// Describes a runtime in more detail.
///
/// Typically this context is used multiple times if multiple runtimes
Expand Down