Unverified Commit b025e38e authored by xubaolin's avatar xubaolin Committed by GitHub

fix a throw due to double precison (#92486)

parent 9afb45a4
......@@ -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);
});
}
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