Cih*_*man 5 floating-action-button flutter
我试图创建浮动操作按钮,但缺少图标。
我的代码是:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
appBar: AppBar(
backgroundColor: Colors.blue,
centerTitle: true,
title: Text(
"Lessons of Flutter",
style: TextStyle(
color: Colors.white,
),
),
),
body: Center(
child: const Text('Press the button below!')
),
floatingActionButton: FloatingActionButton(
onPressed: () {
// Add your onPressed code here!
},
child: Icon(Icons.mouse),
backgroundColor: Colors.green,
),
),
);
}
}
Run Code Online (Sandbox Code Playgroud)
要使用此类,请确保在项目的flutter 部分的pubspec.yaml文件中设置use-material-design: true 。这可确保 MaterialIcons 字体包含在您的应用程序中。该字体用于显示图标。例如:
请参阅此链接: https://api.flutter.dev/flutter/material/Icons-class.html
| 归档时间: |
|
| 查看次数: |
12752 次 |
| 最近记录: |