mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Always select a diagonal for ArcTween even if begin and end rects are equal (#5151)
Fixes https://github.com/flutter/flutter/issues/5086
This commit is contained in:
parent
f59d04bfab
commit
2b3099c814
@ -243,3 +243,21 @@ class _LazyListIterator<E> implements Iterator<E> {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// COLLECTION UTILITIES
|
||||
|
||||
typedef dynamic KeyFunc<T>(T input);
|
||||
|
||||
/// Select the element for which the key function returns the maximum value.
|
||||
dynamic/*=T*/ maxBy/*<T>*/(Iterable<dynamic/*=T*/> input, KeyFunc/*<T>*/ keyFunc) {
|
||||
dynamic/*=T*/ maxValue;
|
||||
dynamic maxKey;
|
||||
for (dynamic/*=T*/ value in input) {
|
||||
dynamic key = keyFunc(value);
|
||||
if (maxKey == null || key > maxKey) {
|
||||
maxValue = value;
|
||||
maxKey = key;
|
||||
}
|
||||
}
|
||||
return maxValue;
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
import 'dart:math' as math;
|
||||
import 'dart:ui' show hashValues, lerpDouble;
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
@ -165,14 +166,7 @@ class MaterialRectArcTween extends RectTween {
|
||||
@required Rect end
|
||||
}) : super(begin: begin, end: end) {
|
||||
final Offset centersVector = end.center - begin.center;
|
||||
double maxSupport = 0.0;
|
||||
for (_Diagonal diagonal in _allDiagonals) {
|
||||
final double support = _diagonalSupport(centersVector, diagonal);
|
||||
if (support > maxSupport) {
|
||||
_diagonal = diagonal;
|
||||
maxSupport = support;
|
||||
}
|
||||
}
|
||||
_diagonal = maxBy(_allDiagonals, (_Diagonal d) => _diagonalSupport(centersVector, d));
|
||||
_beginArc = new MaterialPointArcTween(
|
||||
begin: _cornerFor(begin, _diagonal.beginId),
|
||||
end: _cornerFor(end, _diagonal.beginId)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user