xterm.dart
xterm.dart copied to clipboard
Does not work on Flutter / Android
On Flutter / Android write a Widget with the terminal, in the app i see a gray rectangle, but when write "id" from the keyboard and press enter does not show any results.
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Terminal'),
),
body: TerminalView(Terminal())
);
}
flutter doctor --verbose
[✓] Flutter (Channel stable, 3.19.3, on Freedesktop SDK 23.08 (Flatpak runtime) 6.5.0-25-generic, locale es_CL.UTF-8)
• Flutter version 3.19.3 on channel stable at /home/.../snap/flutter/common/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ba39319843 (hace 3 semanas), 2024-03-07 15:22:21 -0600
• Engine revision 2e4ba9c6fb
• Dart version 3.3.1
• DevTools version 2.31.1
[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /home/.../Android/Sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: /app/extra/android-studio/jbr/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Linux toolchain - develop for Linux desktop
• clang version 10.0.0-4ubuntu1
• cmake version 3.16.3
• ninja version 1.10.0
• pkg-config version 0.29.1
[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
[✓] Connected device (2 available)
• sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 14 (API 34) (emulator)
• Linux (desktop) • linux • linux-x64 • Freedesktop SDK 23.08 (Flatpak runtime) 6.5.0-25-generic
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 3 categories.
Process finished with exit code 0
I use Android Studio from Flatpak, Flutter from snap & Ubuntu 22.04.4 LTS.
It needs a backend shell to work. Xterm is just a front-end framework. Use the flutter_pty package to connect Xterm with the Android shell.
Otherwise, you need to bundle an arm64 cross-compiled bash binary with your app using jniLibs. Then, use flutter_pty to connect with your custom bash. It isn't very easy, so the first method is recommended.