[英]Dart Flutter display Icons
Im writing my first code and I want to display a Icon, and I try to use the command Icon (Icons.star, color: Colors.red, size: 100, ),
.我正在写我的第一个代码,我想显示一个图标,我尝试使用命令Icon (Icons.star, color: Colors.red, size: 100, ),
。 But it doesn't work.但它不起作用。 Can somebody help me.有人可以帮助我吗? Thx谢谢
Welcome to Stackoverflow
.欢迎来到Stackoverflow
。 Try the following code.试试下面的代码。 Your above code is also correct.你上面的代码也是正确的。
Try to check below line in your pubspec.yaml
file尝试检查pubspec.yaml
文件中的以下行
flutter:
uses-material-design: true
ReferFlutter Icons
参考Flutter Icons
Full Example:完整示例:
import 'package:flutter/material.dart';
void main() {
runApp(
MyApp(),
);
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: MyWidget(),
),
),
);
}
}
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: Icon(
Icons.star,
color: Colors.red,
size: 100,
),
);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.