Skip to content

Commit

Permalink
make LeakTrackingConfiguration to const (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
chyiiiiiiiiiiii committed Jun 22, 2023
1 parent 2149e5c commit c75b0a7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkgs/leak_tracker/lib/src/leak_tracking/leak_tracker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void enableLeakTracking({
bool resetIfAlreadyEnabled = false,
}) {
assert(() {
final theConfig = config ??= LeakTrackingConfiguration();
final theConfig = config ??= const LeakTrackingConfiguration();
if (_objectTracker.value != null) {
if (!resetIfAlreadyEnabled) {
throw StateError('Leak tracking is already enabled.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class LeakDiagnosticConfig {
}

class LeakTrackingConfiguration {
LeakTrackingConfiguration({
const LeakTrackingConfiguration({
this.stdoutLeaks = true,
this.notifyDevTools = true,
this.onLeaks,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ class _SummaryValues {
LeakType.notGCed: 3,
});

static final nonZeroCopy =
LeakSummary(<LeakType, int>{}..addAll(nonZero.totals));
static final nonZeroCopy = LeakSummary(<LeakType, int>{}..addAll(nonZero.totals));
}

void main() {
Expand Down Expand Up @@ -71,7 +70,7 @@ void main() {
);

// Mock defaults match real configuration defaults.
final config = LeakTrackingConfiguration();
const config = LeakTrackingConfiguration();
final checker = defaultLeakChecker();
expect(config.notifyDevTools, checker.devToolsSink != null);
expect(config.stdoutLeaks, checker.stdoutSink != null);
Expand Down

0 comments on commit c75b0a7

Please sign in to comment.