mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[Size CupertinoTextSelectionToolbar to children](https://github.com/flutter/flutter/pull/133386) made a slight mistake when calculating if the toolbar should be above or below the text field. Doubling the toolbar arrow height in the `_isAbove `calculation added a buffer of its height (7.0) within which the toolbar would be positioned below the text but have its arrow still pointing downwards. This is why [I was only able to reproduce the bug within a 7.0 height range](https://github.com/flutter/flutter/issues/154812#issuecomment-2774094819). | Before | After | | --- | --- | | <img width="377" alt="toolbar pos before" src="https://github.com/user-attachments/assets/11f63cf3-f352-4232-8230-f04da89b0b4c" /> | <img width="377" alt="toolbar pos after" src="https://github.com/user-attachments/assets/4a48c3bd-158e-468e-9c67-af125c7856a7" /> | <details> <summary>Sample code</summary> ```dart import 'package:flutter/cupertino.dart'; void main() => runApp(const TextSelectionToolbarApp()); class TextSelectionToolbarApp extends StatelessWidget { const TextSelectionToolbarApp({super.key}); @override Widget build(BuildContext context) { return CupertinoApp( home: const CupertinoPageScaffold( child: SafeArea( child: ColoredBox( color: Color(0x11ff0000), child: Padding( padding: EdgeInsets.symmetric(vertical: 56.0, horizontal: 8.0), child: Column( children: [ CupertinoTextField(), ], ), ), ), ), ), ); } } ``` </details> Fixes [Cupertino Text Selection Toolbar has wrong position](https://github.com/flutter/flutter/issues/154812)