android - 如何通过点击图像或卡片在应用程序中打开任何 URL?
问题描述
好吧,我是Flutter的新手,正在尝试制作一个简单的名片类应用程序。我无法通过点击此应用程序的图标来弄清楚如何打开应用程序内的任何链接:-
这是我用 Dart 编写的代码(我删除了部分代码,但保留了所需的部分)
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.teal[300],
body: SafeArea(
child: Column(
//To align everything which is inside the container
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
CircleAvatar(
radius: 60,
backgroundColor: Colors.redAccent,
backgroundImage: AssetImage('images/myself.jpg'),
), //image
Text('Manish',
style: TextStyle(
fontFamily: 'Pacifico',
fontSize: 20.0,
color: Colors.white,
fontWeight: FontWeight.bold,
)), //Name
Text(
'FLUTTER DEVELOPER',
style: TextStyle(
fontFamily: 'Source Sans Pro',
fontSize: 13.0,
color: Colors.indigo[900],
letterSpacing: 1.8,
fontWeight: FontWeight.bold,
),
), //Flutter developer
SizedBox(
height: 25.0,
width: 200.0,
child: Divider(
color: Colors.lightGreenAccent,
),
), //Height
Card(
color: Colors.white,
//To resize this container
margin: EdgeInsets.symmetric(
vertical: 1.0,
horizontal: 10.0,
),
//There's no padding property in "Card" but if you are using "Container" then you can use
//padding: EdgeInsets.all(10.0),
child: Padding(
padding: EdgeInsets.all(
7.0,
),
child: ListTile(
leading: Icon(
Icons.phone,
color: Colors.teal[500],
size: 30.0,
),
title: Text(
'+91 9876543211',
style: TextStyle(
color: Colors.black,
fontFamily: 'Source Sans Pro',
fontWeight: FontWeight.bold,
fontSize: 18.0,
),
),
)),
), //Phone Number
Card(
color: Colors.white,
//To resize this container and give spaces for all the container
margin: EdgeInsets.symmetric(
vertical: 10.0,
horizontal: 10.0,
),
//There's no padding property in "Card" but if you are using "Container" then you can use
//padding: EdgeInsets.all(10.0),
child: Padding(
padding: const EdgeInsets.all(7.0),
child: ListTile(
leading: Icon(
Icons.email,
color: Colors.teal[500],
size: 30.0,
),
title: Text(
'xfgbxgfbxfg@gmail.com',
style: TextStyle(
color: Colors.black,
fontFamily: 'Source Sans Pro',
fontWeight: FontWeight.bold,
fontSize: 18.0,
),
),
)),
), //Email
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Card(
shape: RoundedRectangleBorder(
borderRadius: const BorderRadius.all(
Radius.circular(13.0),
),
),
child: InkWell(
child: Container(
width: 69.5,
height: 69.5,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('images/LinkedInIcon.png'),
fit: BoxFit.fill,
),
//shape: BoxShape.rectangle,
),
),
),
), //LinkedIn
Card(
shape: RoundedRectangleBorder(
borderRadius: const BorderRadius.all(
Radius.circular(13.0),
),
),
child: InkWell(
child: Container(
width: 70,
height: 69,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('images/GitHubIcon.png'),
fit: BoxFit.fill,
),
//shape: BoxShape.circle,
),
),
),
), //Github
],
),
),
),
);
}
}
解决方案
推荐阅读
- c - 不破坏复制/粘贴的子类编辑控件
- swift - 右键单击 UIKitForMac 的 UIButton(催化剂)
- ruby-on-rails - 无法登录会话(Rails)
- python - 动态屏蔽 pandas df 以查找与列表中的字符串匹配的行
- javascript - 单击超链接图像/文本时如何播放声音(仍将您带到超链接网页)
- kubernetes - 我的虚拟机重新启动后,Kubelet 节点设置为 NotReady
- javascript - React Native 在这样的结构中绑定 null 做了什么: someFunction.bind(null, someHook)
- reactjs - 如何从 reactJS 前端点击 Express 后端?
- arm - 为什么 Cortex-M4 在链接器脚本中包含 ARM 到 Thumb 胶水
- python - Pytorch:降低 U-net 模型中的参数