我想将New Project模板创建的默认Flutter应用程序的AppBar标题转换为链接。这是我的代码:
having count(module) > 1
在第9行中,您可以看到带有title参数的MyHomePage构造函数调用。
答案 0 :(得分:0)
将url_launcher
插件添加到pubspec.yaml
dependencies:
url_launcher: 2.0.1
编写此代码:
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
class TitleLink extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
elevation: 0.5,
centerTitle: true,
title: new InkWell(
child: new Text("www.google.com"),
onTap: () => launch('https://google.com'),
),
),
body: new Center(child: new Text("Tap on Title to open Google"))
);
}
}