feat: added util in choreographer to response to pasting in the input… (#2021)
* feat: added util in choreographer to response to pasting in the input barpull/1688/head
parent
50c5fac8dc
commit
c9dbbe73b8
@ -0,0 +1,24 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/choreographer/enums/edit_type.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/widgets/igc/pangea_text_controller.dart';
|
||||
|
||||
class InputPasteListener {
|
||||
final PangeaTextController controller;
|
||||
final VoidCallback onPaste;
|
||||
|
||||
String _currentText = '';
|
||||
|
||||
InputPasteListener(
|
||||
this.controller,
|
||||
this.onPaste,
|
||||
) {
|
||||
controller.addListener(() {
|
||||
if (controller.editType != EditType.keyboard) return;
|
||||
final difference =
|
||||
controller.text.characters.length - _currentText.characters.length;
|
||||
if (difference.abs() > 1) onPaste();
|
||||
_currentText = controller.text;
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue