fix: Fix cascading and fallback propagation of text styles #3129
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fix cascading and fallback propagation of text styles.
While using text nodes and flame_markdown, I noticed that basic propagating of styles was not working.
For example, if you create a standard document, it will have some margins by default. Even when setting it to zero, it was still overwritten by the default style.
I noticed that there was no consistency in the methods
copyWith
andmerge
of which parameter/receiver should be the master and which should be the fallback. Both the implementations and the callers would use it either way indiscriminately.This consolidates the definition and adds comments to the methods enforcing the priority order.
In order to fully test this, I had to expose a few internal details of text elements; I think this is fine since Dart supports the
@visibleForTesting
annotation, and it makes the tests cleaner.Checklist
docs
and added dartdoc comments with///
.examples
ordocs
.Breaking Change?