Skip to content

Commit

Permalink
Only show debug prints in debug mode (#573)
Browse files Browse the repository at this point in the history
  • Loading branch information
MahanRahmati authored May 1, 2024
1 parent 4a38837 commit 735d55f
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions packages/dynamic_color/lib/src/dynamic_color_builder.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:material_color_utilities/material_color_utilities.dart';
Expand Down Expand Up @@ -63,15 +64,19 @@ class DynamicColorBuilderState extends State<DynamicColorBuilder> {
if (!mounted) return;

if (corePalette != null) {
debugPrint('dynamic_color: Core palette detected.');
if (kDebugMode) {
debugPrint('dynamic_color: Core palette detected.');
}
setState(() {
_light = corePalette.toColorScheme();
_dark = corePalette.toColorScheme(brightness: Brightness.dark);
});
return;
}
} on PlatformException {
debugPrint('dynamic_color: Failed to obtain core palette.');
if (kDebugMode) {
debugPrint('dynamic_color: Failed to obtain core palette.');
}
}

try {
Expand All @@ -81,7 +86,9 @@ class DynamicColorBuilderState extends State<DynamicColorBuilder> {
if (!mounted) return;

if (accentColor != null) {
debugPrint('dynamic_color: Accent color detected.');
if (kDebugMode) {
debugPrint('dynamic_color: Accent color detected.');
}
setState(() {
_light = ColorScheme.fromSeed(
seedColor: accentColor,
Expand All @@ -95,10 +102,13 @@ class DynamicColorBuilderState extends State<DynamicColorBuilder> {
return;
}
} on PlatformException {
debugPrint('dynamic_color: Failed to obtain accent color.');
if (kDebugMode) {
debugPrint('dynamic_color: Failed to obtain accent color.');
}
}
if (kDebugMode) {
debugPrint('dynamic_color: Dynamic color not detected on this device.');
}

debugPrint('dynamic_color: Dynamic color not detected on this device.');
}

@override
Expand Down

0 comments on commit 735d55f

Please sign in to comment.