fix a throw due to double precison (#92486)
This commit is contained in:
@@ -577,7 +577,7 @@ class _DropdownRoute<T> extends PopupRoute<_DropdownRouteResult<T>> {
|
||||
scrollOffset = math.min(scrollOffset, preferredMenuHeight - menuHeight);
|
||||
}
|
||||
|
||||
assert(menuHeight == menuBottom - menuTop);
|
||||
assert((menuBottom - menuTop - menuHeight).abs() < precisionErrorTolerance);
|
||||
return _MenuLimits(menuTop, menuBottom, menuHeight, scrollOffset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3595,4 +3595,39 @@ void main() {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/issues/92438
|
||||
testWidgets('Do not throw due to the double precision', (WidgetTester tester) async {
|
||||
const String value = 'One';
|
||||
const double itemHeight = 77.701;
|
||||
final List<DropdownMenuItem<String>> menuItems = <String>[
|
||||
value,
|
||||
'Two',
|
||||
'Free',
|
||||
].map<DropdownMenuItem<String>>((String value) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: value,
|
||||
child: Text(value),
|
||||
);
|
||||
}).toList();
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: DropdownButton<String>(
|
||||
value: value,
|
||||
itemHeight: itemHeight,
|
||||
onChanged: (_) {},
|
||||
items: menuItems,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.tap(find.text(value));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(tester.takeException(), null);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user