我正在尝试在Flutter中使用launch_url插件,但是当我单击该按钮时,我的应用会立即退出。
我用于按钮的代码:
new MaterialButton(
child: const Text('M-COM'),
height: 50.0,
minWidth: 200.0,
color: Colors.blue,
textColor: Colors.white,
splashColor: Colors.blueGrey,
onPressed: _launchURL,
)
_launchURL的代码:
_launchURL() async {
const url = 'https://flutter.io';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
进口:
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
import 'dart:async';
依赖项:
dependencies:
flutter:
sdk: flutter
url_launcher:
我得到的错误:
F/libc ( 6730): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xd in tid 6748 (Thread-2), pid 6730 (.flutterstarter)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'google/sdk_gphone_x86/generic_x86:9/PPP4.180612.007/4860066:userdebug/dev-keys'
Revision: '0'
ABI: 'x86'
pid: 6730, tid: 6748, name: Thread-2 >>> com.yourcompany.flutterstarter <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xd
Cause: null pointer dereference
eax c8e6faac ebx c8e6faac ecx 0000000a edx c7e0f570
edi c5d175f0 esi c7e10408
ebp c7e0f468 esp c7e0f468 eip c84aa1d8
backtrace:
#00 pc 006981d8 /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#01 pc 008f5b75 /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#02 pc 008e87ea /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#03 pc 008ffb03 /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#04 pc 008eb310 /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#05 pc 008f5eea /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#06 pc 008e87ea /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#07 pc 008fe2fb /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#08 pc 008e8d97 /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#09 pc 008fdcb7 /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#10 pc 008eafb7 /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#11 pc 008f997f /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#12 pc 008eaff8 /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#13 pc 008fa175 /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#14 pc 008eaf8a /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#15 pc 008f997f /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#16 pc 008eaff8 /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#17 pc 008fcc16 /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#18 pc 008eb034 /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#19 pc 008ef41e /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#20 pc 008f0570 /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#21 pc 0091433e /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#22 pc 0092fad4 /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#23 pc 00932f2a /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#24 pc 00934573 /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#25 pc 00933d2b /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#26 pc 0093004a /data/app/com.yourcompany.flutterstarter-MdONNcPhZQnLdPJuB2HJaQ==/lib/x86/libflutter.so
#27 pc 0000056b <anonymous:c6440000>
Lost connection to device.
我正在使用Android Studio,并尝试在Android上运行该应用程序。我在做什么错了?