【发布时间】:2022-08-18 07:29:48
【问题描述】:
import \'package:url_launcher/link.dart\';
如何拨打followLink和launchUrl()
child: Link(
target: LinkTarget.blank,
uri: Uri.parse(\'https://www.google.com\'),
builder: (context, followLink) =>
ElevatedButton(
onPressed: followLink,
style: ElevatedButton.styleFrom(primary: constants.appBarColor),
child: Container(
width: MediaQuery.of(context).size.width,
height: SizeConfig.safeBlockHorizontal * 4.5,
child: Center(
child: Text(
\'Visit Link\',
style: TextStyle(
fontSize: SizeConfig.safeBlockHorizontal * 4.05
),
),
),
),
),)
点击onPress后我需要调用这个方法launchUrl()
Future launchUrl() async{
await Future.delayed(const Duration(milliseconds: 900)).whenComplete(() => {
showToastWidget(\'Link clicked\', Colors.green),
callPointsPerClick();
});}
我在launchUrl() 下面尝试了这段代码,但followLink 不是
onPressed: (){
followLink;
launchUrl();}
-
followLink后面缺少括号,所以它不是函数调用。 VTC 为错字。