Skip to content

Conversation

@gspencergoog
Copy link
Contributor

@gspencergoog gspencergoog commented May 4, 2018

Before this change, if you specified a non-null textTheme, but the theme you specified didn't have a body2 defined, then creating a ChipTheme would assert (which means creating a ThemeData would fail).

This adds handling for this corner case to default to reasonable values in that case. The slider had the same problem, but for accentTextTheme, so I fixed that too.

While I had the patient open, Hans and I noticed that TextTheme.merge wasn't doing the right thing in the case where some members were null either, so I fixed that, and added some examples, since merge/copyWith are common operations that are not always well understood.

Fixes #17251

@gspencergoog gspencergoog requested a review from HansMuller May 4, 2018 21:31
@gspencergoog gspencergoog force-pushed the chip_body2 branch 3 times, most recently from afc10a1 to 51c644f Compare May 4, 2018 23:53
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.

Just a few requests to improve the docs

Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than reusing the theme var, maybe make it final and

return new Theme(
  child: child,
  data: theme.copyWith(
    ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. Done.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would help to qualify "incomplete", like: is incomplete because it only specifies one text style. Because it is incomplete, just replacing ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

Choose a reason for hiding this comment

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

This statement isn't as helpful as it should be. Since we have both copyWith and merge, we should provide some rule of thumb here. The see also comment appears to be headed in the right direction...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I reworked those both into descriptive See Also entries.

Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as the one about "Using [merge]"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@gspencergoog gspencergoog merged commit a365c41 into flutter:master May 10, 2018
srawlins added a commit to srawlins/flutter that referenced this pull request May 11, 2018
* master:
  Add a golden image test for centered text (flutter#17517)
  Gallery a11y fix: give the categories and demos pages "route" scope (flutter#17516)
  Stop Gallery the logo to back-button cross fade shaking (flutter#17513)
  Correct a typo in InputDecorator, affects computeMinIntrinsicHeight() (flutter#17512)
  don't fail a test when there are issues deleting a temp dir (flutter#17498)
  Roll engine to 9ae10ef (flutter#17503)
  Roll engine to b856303 (flutter#17499)
  Rebase after package:isolate fixes. (flutter#17289)
  Add more unit tests for AOT snapshotting (flutter#17493)
  Update a TODO with issue number (flutter#17494)
  Fix backdrop demo margin for iPhone X (flutter#17480)
  Post libtxt/post iOS 11 fidelity fine tuning (flutter#17366)
  Add onChangeStart and onChangeEnd to slider. (flutter#17298)
  Use deprecated I/O constants (flutter#17491)
  Augment `flutter screenshot` with all supported screenshot types (flutter#17478)
  Roll engine to fade83c (flutter#17488)
  Fix handling of null body2 text style for chip and slider (flutter#17311)
  Roll engine to 37e20af (flutter#17481)
  Mark test as flaky (flutter#17486)
DaveShuckerow pushed a commit to DaveShuckerow/flutter that referenced this pull request May 14, 2018
)

Before this change, if you specified a non-null textTheme, but the theme you specified didn't have a body2 defined, then creating a ChipTheme would assert (which means creating a ThemeData would fail).

This adds handling for this corner case to default to reasonable values in that case. The slider had the same problem, but for accentTextTheme, so I fixed that too.

While I had the patient open, Hans and I noticed that TextTheme.merge wasn't doing the right thing in the case where some members were null either, so I fixed that, and added some examples, since merge/copyWith are common operations that are not always well understood.

Fixes flutter#17251
@gspencergoog gspencergoog deleted the chip_body2 branch May 30, 2018 21:16
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

labelStyle != null assertion Fails in flutter/src/material/chip_theme.dart

3 participants