Skip to content

Commit

Permalink
Update supernova; fix new linter complaints
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasWanke committed Nov 7, 2023
1 parent f10e0e0 commit 2df7aaf
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 33 deletions.
18 changes: 10 additions & 8 deletions lib/src/debug_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@ class DebugHelper extends StatelessWidget {
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(children: [
Expanded(
child: DefaultTextStyle(
style: context.textTheme.titleMedium!,
child: title,
child: Row(
children: [
Expanded(
child: DefaultTextStyle(
style: context.textTheme.titleMedium!,
child: title,
),
),
),
...actions,
]),
...actions,
],
),
),
const SizedBox(height: 8),
Padding(padding: contentPadding, child: child),
Expand Down
10 changes: 6 additions & 4 deletions lib/src/debug_overlay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,12 @@ class DebugOverlayState extends State<DebugOverlay> {
_isVisible && (_isInDebugMode || !widget.enableOnlyInDebugMode)
? _buildBottomSheet()
: null;
return Stack(children: [
if (widget.child != null) widget.child!,
if (bottomSheet != null) Positioned.fill(child: bottomSheet),
]);
return Stack(
children: [
if (widget.child != null) widget.child!,
if (bottomSheet != null) Positioned.fill(child: bottomSheet),
],
);
}

double _extent = 0;
Expand Down
46 changes: 31 additions & 15 deletions lib/src/helpers/logs/widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,18 @@ class LogEntryWidget extends StatelessWidget {

final textStyle = TextStyle(color: color);
final title = Text.rich(
TextSpan(children: [
TextSpan(
text: formattedTimestamp,
style: context.textTheme.bodySmall!.copyWith(
color: color.withOpacity(0.6),
fontFeatures: [const FontFeature.tabularFigures()],
TextSpan(
children: [
TextSpan(
text: formattedTimestamp,
style: context.textTheme.bodySmall!.copyWith(
color: color.withOpacity(0.6),
fontFeatures: [const FontFeature.tabularFigures()],
),
),
),
TextSpan(text: ' ${log.message}'),
]),
TextSpan(text: ' ${log.message}'),
],
),
style: textStyle,
);

Expand Down Expand Up @@ -226,24 +228,29 @@ class LogEntryWidget extends StatelessWidget {
if (object is DiagnosticsNode) return object.toStringDeep();

try {
// ignore: avoid_dynamic_calls
(object as dynamic).toJson();
// It supports `toJson()`.

dynamic toEncodable(dynamic object) {
try {
// ignore: avoid_dynamic_calls
return object.toJson();
} catch (_) {}
try {
return '$object';
// ignore: avoid_catches_without_on_clauses
} catch (_) {}
return describeIdentity(object);
}

return JsonEncoder.withIndent(' ', toEncodable).convert(object);
// ignore: avoid_catches_without_on_clauses
} catch (_) {}

try {
return '$object'.trim();
// ignore: avoid_catches_without_on_clauses
} catch (_) {}
return describeIdentity(object);
}
Expand All @@ -263,8 +270,10 @@ class LogEntryWidget extends StatelessWidget {
}

try {
// ignore: avoid_dynamic_calls
(object as dynamic).toJson();
return true;
// ignore: avoid_catches_without_on_clauses
} catch (_) {}
return false;
}
Expand All @@ -273,7 +282,9 @@ class LogEntryWidget extends StatelessWidget {
if (object is List || object is Map) return isJson(object);

try {
// ignore: avoid_dynamic_calls
return isJsonListOrMap((object as dynamic).toJson());
// ignore: avoid_catches_without_on_clauses
} catch (_) {}
return false;
}
Expand All @@ -298,10 +309,13 @@ class LogEntryWidget extends StatelessWidget {
}

try {
// ignore: avoid_dynamic_calls
return toJson((object as dynamic).toJson());
// ignore: avoid_catches_without_on_clauses
} catch (_) {}
try {
return '$object';
// ignore: avoid_catches_without_on_clauses
} catch (_) {}
return describeIdentity(object);
}
Expand Down Expand Up @@ -449,12 +463,14 @@ class _ExpansionTileState extends State<_ExpansionTile>
if (_isExpanded) {
_animationController.forward();
} else {
unawaited(_animationController.reverse().then<void>((value) {
if (!mounted) return;
setState(() {
// Rebuild without widget.children.
});
}));
unawaited(
_animationController.reverse().then<void>((value) {
if (!mounted) return;
setState(() {
// Rebuild without widget.children.
});
}),
);
}
PageStorage.maybeOf(context)?.writeState(context, _isExpanded);
});
Expand Down
12 changes: 7 additions & 5 deletions lib/src/helpers/media_override.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ class _MediaOverrideDebugHelperState extends State<MediaOverrideDebugHelper> {
builder: (context, currentState, _) => DebugHelper(
title: const Text('Media Overrides'),
contentPadding: EdgeInsets.zero,
child: Column(children: [
_buildThemeModeOverride(currentState),
if (widget.supportedLocales != null)
_buildLocaleOverride(currentState),
]),
child: Column(
children: [
_buildThemeModeOverride(currentState),
if (widget.supportedLocales != null)
_buildLocaleOverride(currentState),
],
),
),
);
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ dev_dependencies:
git:
url: https://github.com/JonasWanke/supernova.git
path: supernova_flutter
ref: 281f167123facb724d112ffc84349cf39d8f691f
ref: b84d859caf3402b7b30099ac3f67c74fcc071cc6

0 comments on commit 2df7aaf

Please sign in to comment.