import 'package:flutter/material.dart';
import 'package:share/share.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Stop addiction',
theme: ThemeData(
primarySwatch: Colors.teal,
),
home: Scaffold(
appBar: AppBar(backgroundColor:Colors.black,
title: Text('stop addiction',style:TextStyle(color:Colors.red),),centerTitle: true,actions: <Widget>[
IconButton(icon: Icon(Icons.share,color:Colors.white70,), onPressed:Share.share('check out my website https://example.com');)
],
),
body: _blank()
),
);
}
}
问题:
答案 0 :(得分:1)
代码应为
IconButton(icon: Icon(Icons.share,color:Colors.white70,), onPressed:() => Share.share('check out my website https://example.com')/*semicolon removed here*/)
然后,删除分号