Commit c0a71e34 authored by Dragoș Tiselice's avatar Dragoș Tiselice Committed by GitHub

Added global keys to Material slices. (#5386)

Because parent structure changes when slices gets separated and
merged, children widgets can be rebuilt redundantly. This commit
adds a global key to each child so that the framework always knows
its children apart.
parent abeb5c73
......@@ -506,6 +506,10 @@ class _MergeableMaterialState extends State<MergeableMaterial> {
slices.add(
new Material(
// Since slices live in different Material widgets, the parent
// hierarchy can change and lead to the slice being rebuilt. Using
// a global key solves the issue.
key: new _MergeableMaterialSliceKey(_children[i].key),
type: MaterialType.transparency,
child: slice.child
)
......@@ -539,6 +543,23 @@ class _MergeableMaterialState extends State<MergeableMaterial> {
}
}
class _MergeableMaterialSliceKey extends GlobalKey {
const _MergeableMaterialSliceKey(this.value) : super.constructor();
final LocalKey value;
@override
bool operator ==(dynamic other) {
if (other is! _MergeableMaterialSliceKey)
return false;
final _MergeableMaterialSliceKey typedOther = other;
return value == typedOther.value;
}
@override
int get hashCode => value.hashCode;
}
class _MergeableMaterialBlockBody extends BlockBody {
_MergeableMaterialBlockBody({
List<Widget> children,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment