We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
StreamBuilder( stream: bloc.channel?.stream, builder: (context, snapshot) { String? aa; if (snapshot.data != null) { Uint8List fileBytes = Uint8List.fromList(snapshot.data); aa = utf8.decode(fileBytes); } bloc.snapshot(aa); return Expanded( child: TerminalView( bloc.terminal, controller: bloc.terminalController, padding: const EdgeInsets.all(8), theme: TerminalThemes.defaultTheme, autofocus: true, backgroundOpacity: 1, onSecondaryTapDown: (details, offset) async { final selection = bloc.terminalController.selection; if (selection != null) { final text = bloc.terminal.buffer .getText(selection); bloc.terminalController.clearSelection(); await Clipboard.setData( ClipboardData(text: text)); } else { final data = await Clipboard.getData('text/plain'); final text = data?.text; if (text != null) { bloc.terminal.paste(text); } } }, ), ); }, ), 不知道为啥我输入一个它就会发送消息, 业务代码 final terminal = Terminal( maxLines: 10000, platform: TerminalTargetPlatform.web, inputHandler: defaultInputHandler, ); void sendMessage(String name) async { Uint8List by = Uint8List.fromList(utf8.encode(name)); terminal.write(name); if (wsTEC.text.isNotEmpty) { channel?.sink.add(by); } await onInit(); pagesScope.update(); }
@OverRide Future onInit() async { channel = WebSocketChannel.connect( Uri.parse("${RequestConfig.wshost}/terminals?hostId=$hostId"), ); terminal.onOutput = (data) { Uint8List by = Uint8List.fromList(utf8.encode(data)); if (data.isNotEmpty) { channel?.sink.add(by); } sendMessage(data); }; return "1"; }
void snapshot(String? value) { if (value == null) { terminal.write("链接失败!!!"); } { terminal.write('\r$value'); } }
The text was updated successfully, but these errors were encountered:
每次输入都是触发terminal.output
Sorry, something went wrong.
为啥要用websocket?
旁边的输入都是触发terminal.output
我想输入完成后回车发送,不知道应该怎么去解决
为啥用websocket?
我只有一个ws的地址,所以选择了websocket。最重要的是开发的是flutter web
@itzhoujun 大佬你看看这啥问题啊,以前用得好好得啊,今天不行了
No branches or pull requests
StreamBuilder(
stream: bloc.channel?.stream,
builder: (context, snapshot) {
String? aa;
if (snapshot.data != null) {
Uint8List fileBytes =
Uint8List.fromList(snapshot.data);
aa = utf8.decode(fileBytes);
}
bloc.snapshot(aa);
return Expanded(
child: TerminalView(
bloc.terminal,
controller: bloc.terminalController,
padding: const EdgeInsets.all(8),
theme: TerminalThemes.defaultTheme,
autofocus: true,
backgroundOpacity: 1,
onSecondaryTapDown: (details, offset) async {
final selection =
bloc.terminalController.selection;
if (selection != null) {
final text = bloc.terminal.buffer
.getText(selection);
bloc.terminalController.clearSelection();
await Clipboard.setData(
ClipboardData(text: text));
} else {
final data =
await Clipboard.getData('text/plain');
final text = data?.text;
if (text != null) {
bloc.terminal.paste(text);
}
}
},
),
);
},
),
不知道为啥我输入一个它就会发送消息,
业务代码
final terminal = Terminal(
maxLines: 10000,
platform: TerminalTargetPlatform.web,
inputHandler: defaultInputHandler,
);
void sendMessage(String name) async {
Uint8List by = Uint8List.fromList(utf8.encode(name));
terminal.write(name);
if (wsTEC.text.isNotEmpty) {
channel?.sink.add(by);
}
await onInit();
pagesScope.update();
}
@OverRide
Future onInit() async {
channel = WebSocketChannel.connect(
Uri.parse("${RequestConfig.wshost}/terminals?hostId=$hostId"),
);
terminal.onOutput = (data) {
Uint8List by = Uint8List.fromList(utf8.encode(data));
if (data.isNotEmpty) {
channel?.sink.add(by);
}
sendMessage(data);
};
return "1";
}
void snapshot(String? value) {
if (value == null) {
terminal.write("链接失败!!!");
}
{
terminal.write('\r$value');
}
}
The text was updated successfully, but these errors were encountered: