You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
fluffychat/lib/pangea/widgets/chat/message_text_selection.dart

35 lines
897 B
Dart

import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class MessageTextSelection {
String? selectedText;
String messageText = "";
void setMessageText(String text) {
messageText = text;
}
void onTextSelection(TextSelection selection) => selection.isCollapsed == true
? clearTextSelection()
: setTextSelection(selection);
void setTextSelection(TextSelection selection) {
selectedText = selection.textInside(messageText);
if (BrowserContextMenu.enabled && kIsWeb) {
BrowserContextMenu.disableContextMenu();
}
// selectionStream.add(selectedText);
}
void clearTextSelection() {
selectedText = null;
if (kIsWeb && !BrowserContextMenu.enabled) {
BrowserContextMenu.enableContextMenu();
}
// selectionStream.add(selectedText);
}
}