Skip to content

Conversation

@LongCatIsLooong
Copy link
Contributor

@LongCatIsLooong LongCatIsLooong commented Nov 7, 2019

Description

This PR is an attempt at making the CupertinoDynamicColor more debuggable.

  • If a CupertinoDynamicColor is used to paint before being resolved, it should throw Not feasible because that will break people that are currently using CupertinoColors.activeBlue as a concrete color. But this assert (now removed) did catch a few unresolved color usages in the framework and tests.
  • Added an optional debugLabel field to CupertinoDynamicColor.
  • Added "last resolved" information.

Screenshots

Inspecting a dynamic color in the widget inspector.

Clicking on "last resolved" will link you to that element, thanks to the dev tool.
2019-11-06-171826_381x759_scrot

Enhanced CupertinoTheme display

2019-11-06-171705_1679x759_scrot

Related Issues

#35541

Tests

I added the following tests:

  • CupertinoTheme diagnostics

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (Please read Handling breaking changes). Replace this with a link to the e-mail where you asked for input on this proposed change.
  • No, this is not a breaking change.

@fluttergithubbot fluttergithubbot added a: tests "flutter test", flutter_test, or one of our tests d: examples Sample code and demos f: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels. c: contributor-productivity Team-specific productivity, code health, technical debt. customer: gallery Relating to flutter/gallery repository. Please transfer non-framework issues there. labels Nov 7, 2019
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
const CupertinoTextThemeData defaultData = CupertinoTextThemeData();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting error • Evaluation of this constant expression throws an exception • packages/flutter/lib/src/cupertino/text_theme.dart:255:48 • const_eval_throws_exception but the analyzer won't let me change to final either.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

primaryColor has a default value CupertinoColors.systemBlue. The weird thing is I'm able to compile apps and they run without throwing, despite this analyzer error.

Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

properties.add(DiagnosticsProperty<Element>('last resolved', _debugResolveContext));
}

/// Asserts that the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks unfinished

Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Pretty cool, I didn't realize how to set up debug things like that.

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
const CupertinoTextThemeData defaultData = CupertinoTextThemeData();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@LongCatIsLooong LongCatIsLooong merged commit 62db22d into flutter:master Nov 7, 2019
@LongCatIsLooong LongCatIsLooong deleted the dynamic-color-improvements branch November 7, 2019 21:14
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

a: tests "flutter test", flutter_test, or one of our tests c: contributor-productivity Team-specific productivity, code health, technical debt. customer: gallery Relating to flutter/gallery repository. Please transfer non-framework issues there. d: examples Sample code and demos f: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants