Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve code_metrics and address warnings #17

Merged
merged 5 commits into from
Apr 3, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ analyzer:
- dart_code_metrics

dart_code_metrics:
metrics:
cyclomatic-complexity: 20
number-of-parameters: 4
maximum-nesting-level: 5
metrics-exclude:
- test/**
- example/test/**
Expand Down
40 changes: 20 additions & 20 deletions lib/src/layout/scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,46 +21,46 @@ class Scaffold extends StatelessWidget {
}) : assert(splitOffset > 0.0 && splitOffset < 1.0),
super(key: key);

/// Background color for the [body].
final Color? backgroundColor;

/// Main content area.
final Widget body;

/// Defines an area to which [sidebar] cannot be expanded or shrunk past on
/// the left and right.
final double resizeBoundary;

/// Secondary content area.
final Widget? sidebar;

/// Background color for the [body].
final Color? backgroundColor;

/// Background color for the [sidebar]
final Color? sidebarBackgroundColor;

/// The color of the body/sidebar splitter
final Color? sidebarGripColor;

/// Determines where the split between [body] and [sidebar] occurs.
/// Defines a breakpoint for showing and hiding the [sidebar].
///
/// If specified, it must be a value greater than 0.0 and less than 1.0.
/// If the window is resized along its width to a value below this one, the
/// sidebar will be hidden. If resized back above this value, the sidebar
/// will be shown again.
///
/// Defaults to `0.25`, which is 1/4 of the available space from the left.
final double splitOffset;
/// Defaults to `0.0`, which means the sidebar will always be shown.
final double sidebarBreakpoint;

/// The color of the body/sidebar splitter
final Color? sidebarGripColor;

/// The width of the split between [body] and [sidebar].
///
/// Defaults to 0.80, which seems to be the default in Apple's macOS apps
/// (I eyeballed this so it's not perfect but it's very close).
final double sidebarGripSize;

/// Defines an area to which [sidebar] cannot be expanded or shrunk past on
/// the left and right.
final double resizeBoundary;

/// Defines a breakpoint for showing and hiding the [sidebar].
/// Determines where the split between [body] and [sidebar] occurs.
///
/// If the window is resized along its width to a value below this one, the
/// sidebar will be hidden. If resized back above this value, the sidebar
/// will be shown again.
/// If specified, it must be a value greater than 0.0 and less than 1.0.
///
/// Defaults to `0.0`, which means the sidebar will always be shown.
final double sidebarBreakpoint;
/// Defaults to `0.25`, which is 1/4 of the available space from the left.
final double splitOffset;

@override
Widget build(BuildContext context) {
Expand Down
72 changes: 36 additions & 36 deletions lib/src/macos_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,79 +86,79 @@ class MacosApp extends StatefulWidget {
initialRoute = null,
super(key: key);

final Style? style;

final Style? darkStyle;
final Map<Type, Action<Intent>>? actions;

final ThemeMode? themeMode;
final BackButtonDispatcher? backButtonDispatcher;

final GlobalKey<NavigatorState>? navigatorKey;
final TransitionBuilder? builder;

final RouteFactory? onGenerateRoute;
final bool checkerboardOffscreenLayers;

final InitialRouteListFactory? onGenerateInitialRoutes;
final bool checkerboardRasterCacheImages;

final PageRouteFactory? pageRouteBuilder;
final Style? darkStyle;

final RouteInformationParser<Object>? routeInformationParser;
static bool debugAllowBannerOverride = true;

final RouterDelegate<Object>? routerDelegate;
final bool debugShowCheckedModeBanner;

final BackButtonDispatcher? backButtonDispatcher;
final bool debugShowWidgetInspector;

final RouteInformationProvider? routeInformationProvider;
static bool debugShowWidgetInspectorOverride = false;

final Widget? home;

final Map<String, WidgetBuilder>? routes;

final RouteFactory? onUnknownRoute;

final String? initialRoute;

final List<NavigatorObserver>? navigatorObservers;
final InspectorSelectButtonBuilder? inspectorSelectButtonBuilder;

final TransitionBuilder? builder;
final Locale? locale;

final String title;
final LocaleListResolutionCallback? localeListResolutionCallback;

final GenerateAppTitle? onGenerateTitle;
final LocaleResolutionCallback? localeResolutionCallback;

final Color? primaryColor;
final Iterable<LocalizationsDelegate<dynamic>>? localizationsDelegates;

final Locale? locale;
final GlobalKey<NavigatorState>? navigatorKey;

final Iterable<LocalizationsDelegate<dynamic>>? localizationsDelegates;
final List<NavigatorObserver>? navigatorObservers;

final LocaleListResolutionCallback? localeListResolutionCallback;
final InitialRouteListFactory? onGenerateInitialRoutes;

final LocaleResolutionCallback? localeResolutionCallback;
final RouteFactory? onGenerateRoute;

final Iterable<Locale> supportedLocales;
final GenerateAppTitle? onGenerateTitle;

final bool showPerformanceOverlay;
final RouteFactory? onUnknownRoute;

final bool checkerboardRasterCacheImages;
final PageRouteFactory? pageRouteBuilder;

final bool checkerboardOffscreenLayers;
final Color? primaryColor;

final bool showSemanticsDebugger;
final RouteInformationParser<Object>? routeInformationParser;

final bool debugShowWidgetInspector;
final RouteInformationProvider? routeInformationProvider;

final InspectorSelectButtonBuilder? inspectorSelectButtonBuilder;
final RouterDelegate<Object>? routerDelegate;

final bool debugShowCheckedModeBanner;
final Map<String, WidgetBuilder>? routes;

final Map<LogicalKeySet, Intent>? shortcuts;

final Map<Type, Action<Intent>>? actions;
final bool showPerformanceOverlay;

static bool showPerformanceOverlayOverride = false;

static bool debugShowWidgetInspectorOverride = false;
final bool showSemanticsDebugger;

static bool debugAllowBannerOverride = true;
final Style? style;

final Iterable<Locale> supportedLocales;

final ThemeMode? themeMode;

final String title;

@override
_MacosAppState createState() => _MacosAppState();
Expand Down
10 changes: 5 additions & 5 deletions lib/src/styles/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class MacosTheme extends InheritedWidget {
required this.child,
}) : super(key: key, child: child);

final Style style;
final Widget child;
final Style style;

static Style of(BuildContext context) {
return context
Expand Down Expand Up @@ -53,16 +53,16 @@ class Style with Diagnosticable {
this.mediumAnimationDuration,
});

final Typography? typography;

final Brightness? brightness;

final CupertinoDynamicColor? accentColor;

final Curve? animationCurve;

final Brightness? brightness;

final Duration? mediumAnimationDuration;

final Typography? typography;

Style build() {
final brightness = this.brightness ?? Brightness.light;
final defaultStyle = Style(
Expand Down
40 changes: 20 additions & 20 deletions lib/src/styles/typography.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,38 @@ class Typography with Diagnosticable {
this.caption2,
});

/// Style used for large titles.
final TextStyle? largeTitle;
/// Style used for body text.
final TextStyle? body;

/// Style used for first-level hierarchical headings.
final TextStyle? title1;
/// Style used for callouts.
final TextStyle? callout;

/// Style used for second-level hierarchical headings.
final TextStyle? title2;
/// Style used for standard captions.
final TextStyle? caption1;

/// Style used for third-level hierarchical headings.
final TextStyle? title3;
/// Style used for alternate captions.
final TextStyle? caption2;

/// Style used in footnotes
final TextStyle? footnote;

/// Style used for headings.
final TextStyle? headline;

/// Style used for large titles.
final TextStyle? largeTitle;

/// Style used for subheadings.
final TextStyle? subheadline;

/// Style used for body text.
final TextStyle? body;

/// Style used for callouts.
final TextStyle? callout;

/// Style used in footnotes
final TextStyle? footnote;
/// Style used for first-level hierarchical headings.
final TextStyle? title1;

/// Style used for standard captions.
final TextStyle? caption1;
/// Style used for second-level hierarchical headings.
final TextStyle? title2;

/// Style used for alternate captions.
final TextStyle? caption2;
/// Style used for third-level hierarchical headings.
final TextStyle? title3;

/// Provides the default macOS Typography.
///
Expand Down