Skip to content

SystemUiOverlayStyle should be a Diagnosticable subclass #169248

@huycozy

Description

@huycozy

Use case

While working on #169130, adding a DiagnosticsProperty for SystemUiOverlayStyle requires declaring a very long description, to pass the test for implements debugFillProperties:

https://github.com/flutter/flutter/pull/169130/files#diff-05d6650782d071fca6c2bd8e02381b8748b13ca70af9f189c2e4789690b0ab42R587-R595:

properties.add(
      DiagnosticsProperty<SystemUiOverlayStyle>(
        'systemOverlayStyle',
        systemOverlayStyle,
        defaultValue: null,
        description:
            systemOverlayStyle == null
                ? null
                : 'SystemUiOverlayStyle(${<String>[if (systemOverlayStyle?.systemNavigationBarColor != null) 'systemNavigationBarColor: ${systemOverlayStyle?.systemNavigationBarColor}', if (systemOverlayStyle?.systemNavigationBarDividerColor != null) 'systemNavigationBarDividerColor: ${systemOverlayStyle?.systemNavigationBarDividerColor}', if (systemOverlayStyle?.systemNavigationBarIconBrightness != null) 'systemNavigationBarIconBrightness: ${systemOverlayStyle?.systemNavigationBarIconBrightness}', if (systemOverlayStyle?.statusBarColor != null) 'statusBarColor: ${systemOverlayStyle?.statusBarColor}', if (systemOverlayStyle?.statusBarBrightness != null) 'statusBarBrightness: ${systemOverlayStyle?.statusBarBrightness}', if (systemOverlayStyle?.statusBarIconBrightness != null) 'statusBarIconBrightness: ${systemOverlayStyle?.statusBarIconBrightness}', if (systemOverlayStyle?.systemStatusBarContrastEnforced != null) 'systemStatusBarContrastEnforced: ${systemOverlayStyle?.systemStatusBarContrastEnforced}', if (systemOverlayStyle?.systemNavigationBarContrastEnforced != null) 'systemNavigationBarContrastEnforced: ${systemOverlayStyle?.systemNavigationBarContrastEnforced}'].where((s) => s.isNotEmpty).join(', ')})',
      ),

https://github.com/flutter/flutter/pull/169130/files#diff-309c2663b436860c5e1be1ed6ecd3b8bb5194960ec5b45366e35041a25dc007dR1168-R1217:

    final List<String> description =
        builder.properties
            .where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info))
            .map((DiagnosticsNode node) => node.toString())
            .toList();

    expect(
      description,
      equalsIgnoringHashCodes(<String>[
        'backgroundColor: ${const Color(0xff000000)}',
        'foregroundColor: ${const Color(0xff000001)}',
        'elevation: 8.0',
        'scrolledUnderElevation: 3.0',
        'shadowColor: ${const Color(0xff000002)}',
        'surfaceTintColor: ${const Color(0xff000003)}',
        'shape: StadiumBorder(BorderSide(width: 0.0, style: none))',
        'iconTheme: IconThemeData#00000(color: ${const Color(0xff000004)})',
        'actionsIconTheme: IconThemeData#00000(color: ${const Color(0xff000004)})',
        'centerTitle: true',
        'titleSpacing: 40.0',
        'leadingWidth: 96.0',
        'toolbarHeight: 96.0',
        'toolbarTextStyle: TextStyle(inherit: true, color: ${const Color(0xff000005)})',
        'titleTextStyle: TextStyle(inherit: true, color: ${const Color(0xff000006)})',
        'systemOverlayStyle: SystemUiOverlayStyle#00000(systemNavigationBarColor: ${const Color(0xff000007)})',
        'actionsPadding: EdgeInsets(8.0, 0.0, 8.0, 0.0)',
      ]),
    );

Proposal

SystemUIOverlayStyle should implement Diagnosticable and provide its own debugFillProperties, similar to some other styles, like AnimationStyle:

class AnimationStyle with Diagnosticable {

or TextStyle:

class TextStyle with Diagnosticable {

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listc: proposalA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions