只需在Text小部件周围包装InkWell,并将UrlLauncher(从服务库)提供给onTap属性:
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
runApp(new MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
title: new Text('UrlLauchner'),
),
body: new Center(
child: new InkWell(
child: new Text('Open Browser'),
onTap: () => UrlLauncher.launch(
'https://docs.flutter.io/flutter/services/UrlLauncher-class.html')),
),
),
);
}
}
您可以为“文本”窗口小部件提供样式,使其看起来像链接 .
更新
在仔细研究这个问题之后,我找到了一个不同的解决方案来实现你要求的'in line'超链接 . 您