Flutter launchUrl не запускается, несмотря на то, что canLaunchUrl возвращает true в приложении Linux Ubuntu 20.04Linux

Ответить Пред. темаСлед. тема
Anonymous
 Flutter launchUrl не запускается, несмотря на то, что canLaunchUrl возвращает true в приложении Linux Ubuntu 20.04

Сообщение Anonymous »

Я пытаюсь запустить URL-адрес с помощью кнопки на Flutter (стабильный канал, 3.16.4, в Ubuntu 20.04.6 LTS 5.15.0-122-generic, локаль en_US.UTF-8) для приложения Linux. Проверка canLaunchUrl проходит, но URL-адрес в моем браузере фактически не запускается.
Я пробовал переустановить vscode, flutter SDK, изменить сети и переключиться на устаревшие функции запуска и canLaunch. В настоящий момент я пытаюсь жестко закодировать Google в качестве URL-адреса.
Пример функции и распечатки для отображения потока кода
вывод flutter Doctor -vv :
[✓] Flutter (Channel stable, 3.16.4, on Ubuntu 20.04.6 LTS 5.15.0-122-generic, locale en_US.UTF-8)
• Flutter version 3.16.4 on channel stable at /home/uei-sm-test/snap/flutter/common/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 2e9cb0aa71 (10 months ago), 2023-12-11 14:35:13 -0700
• Engine revision 54a7145303
• Dart version 3.2.3
• DevTools version 2.28.4

[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/in ... roid-setup for detailed instructions).
If the Android SDK has been installed to a custom location, please use
`flutter config --android-sdk` to update to that location.

[✓] Chrome - develop for the web
• Chrome at google-chrome

[✓] 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/in ... roid-setup for detailed instructions).

[✓] VS Code (version 1.93.1)
• VS Code at /usr/share/code
• Flutter extension version 3.98.0

[✓] Connected device (2 available)
• Linux (desktop) • linux • linux-x64 • Ubuntu 20.04.6 LTS 5.15.0-122-generic
• Chrome (web) • chrome • web-javascript • Google Chrome 127.0.6533.88

[✓] Network resources
• All expected network resources are available.

! Doctor found issues in 2 categories.
uei-sm-test@uei-sm-test-ThinkPad-X1-Carbon-7th:~/src/qse_sample_app-qsra/modules/image_display/src$ flutter doctor -vv
[ +36 ms] Unable to locate an Android SDK.
[ +9 ms] executing: uname -m
[ +13 ms] Exit code 0 from: uname -m
[ ] x86_64
[ +96 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[ ] Artifact Instance of 'LegacyCanvasKitRemover' is not required, skipping update.
[ +3 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +113 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[ +1 ms] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[ ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[ ] Artifact Instance of 'LegacyCanvasKitRemover' is not required, skipping update.
[ ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[ ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ +20 ms] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ +5 ms] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ +2 ms] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ +1 ms] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[ +1 ms] Artifact Instance of 'PubDependencies' is not required, skipping update.
[ +283 ms] executing: [/home/uei-sm-test/snap/flutter/common/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%ar
[ +7 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%ar
[ ] 10 months ago
[ +101 ms] [✓] Flutter (Channel stable, 3.16.4, on Ubuntu 20.04.6 LTS 5.15.0-122-generic, locale en_US.UTF-8)
[ +2 ms] • Flutter version 3.16.4 on channel stable at /home/uei-sm-test/snap/flutter/common/flutter
[ ] • Upstream repository https://github.com/flutter/flutter.git
[ ] • Framework revision 2e9cb0aa71 (10 months ago), 2023-12-11 14:35:13 -0700
[ ] • Engine revision 54a7145303
[ ] • Dart version 3.2.3
[ ] • DevTools version 2.28.4
[ +17 ms] [✗] Android toolchain - develop for Android devices
[ ] ✗ Unable to locate Android SDK.
[ ] Install Android Studio from: https://developer.android.com/studio/index.html
[ ] On first launch it will assist you in installing the Android SDK components.
[ ] (or visit https://flutter.dev/docs/get-started/in ... roid-setup for detailed instructions).
[ ] If the Android SDK has been installed to a custom location, please use
[ ] `flutter config --android-sdk` to update to that location.
[ +11 ms] [✓] Chrome - develop for the web
[ ] • Chrome at google-chrome
[ +402 ms] [✓] Linux toolchain - develop for Linux desktop
[ ] • clang version 10.0.0-4ubuntu1
[ +21 ms] • cmake version 3.16.3
[ +8 ms] • ninja version 1.10.0
[ ] • pkg-config version 0.29.1
[ +3 ms] [!] 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/in ... roid-setup for detailed instructions).
[ +4 ms] [✓] VS Code (version 1.93.1)
[ ] • VS Code at /usr/share/code
[ ] • Flutter extension version 3.98.0
[ +2 ms] [✓] Connected device (2 available)
[ ] • Linux (desktop) • linux • linux-x64 • Ubuntu 20.04.6 LTS 5.15.0-122-generic
[ +20 ms] • Chrome (web) • chrome • web-javascript • Google Chrome 127.0.6533.88
[ +5 ms] [✓] Network resources
[ +4 ms] • All expected network resources are available.
[ +1 ms] ! Doctor found issues in 2 categories.
[ +29 ms] "flutter doctor" took 1,101ms.
[ +196 ms] ensureAnalyticsSent: 123ms
[ ] Running 0 shutdown hooks
[ ] Shutdown hooks complete
[ ] exiting with code 0

Виджет и функции кнопки:
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

class LaunchUrlButton extends StatelessWidget {
final String url;
const LaunchUrlButton({super.key, required this.url});

Future _launchUrl(String url) async {
print('pressed with url $url');
Uri uri = Uri.parse(url);
if (!await canLaunchUrl(uri)) {
print('attempting to launch url $url');
await launchUrl(uri);
} else {
throw 'Could not launch $url';
}
}

@override
Widget build(BuildContext context) {
return SizedBox(
height: 100,
width: 100,
child: IconButton(
style: const ButtonStyle(),
icon: const Icon(Icons.link),
onPressed: () {
_launchUrl(url);
},
));
}
}


Подробнее здесь: https://stackoverflow.com/questions/790 ... -linux-ubu
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Linux»