从flutter版本3.10.0中'DragSelectionUpdateCallback'已从text_selection.dart中删除此函数的替代方案是什么?
wooyq4lh1#
您可以使用新的TextSelectionGestureDetector类来处理文本选择手势,而不是DragSelectionUpdateCallback。
import 'package:flutter/material.dart'; class MyTextSelectionGestureDetector extends StatelessWidget { final TextEditingController controller; final Function(TextSelection) onSelectionChanged; MyTextSelectionGestureDetector({required this.controller, required this.onSelectionChanged}); @override Widget build(BuildContext context) { return TextSelectionGestureDetector( behavior: HitTestBehavior.translucent, onTapDown: (_) => controller.selection = TextSelection.collapsed(offset: controller.text.length), onSelectionChanged: onSelectionChanged, child: TextField( controller: controller, ), ); } }
1条答案
按热度按时间wooyq4lh1#
您可以使用新的TextSelectionGestureDetector类来处理文本选择手势,而不是DragSelectionUpdateCallback。