我有此代码:
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:meta/meta.dart';
class RoundedButton extends StatelessWidget {
final Color backgroundColor;
final String textButton;
const RoundedButton(
{Key key, @required this.backgroundColor, @required this.textButton})
: super(key: key);
@override
Widget build(BuildContext context) {
return Container(
alignment: Alignment.center,
decoration: BoxDecoration(
color: backgroundColor ?? Colors.grey,
borderRadius: BorderRadius.circular(50)),
width: getWidthByPercent(context, 90),
height: getWidthByPercent(context, 15),
child: Text(
textButton ?? "",
style: TextStyle(
color: Colors.white,
fontSize: getWidthByPercent(context, 7),
fontWeight: FontWeight.w300),
),
);
}
}
但是当我在另一个页面上使用此窗口小部件时,该窗口小部件并未警告我有关所需参数的信息:
Widget build(BuildContext context) {
return Positioned(
top: getHeightByPercent(context, 60),
bottom: getHeightByPercent(context, 1),
left: getHeightByPercent(context, 1),
right: getHeightByPercent(context, 1),
child: Container(
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
color: whiteDefault,
borderRadius: BorderRadius.circular(15),
),
child: Column(
children: <Widget>[
Text(
"SDS Connect",
style: initialTitle(context, 10),
),
Text(
"The first to connect you with the information you need through NFC technology and innovate cloud based solutions",
style: softGray(context, 5),
textAlign: TextAlign.center,
),
RoundedButton()
],
),
),
);
有某种使用方式吗?我在其他项目上以某种方式使用了此功能,但我不记得如何使用它,可以在pubsbec.yaml上导入某些内容。
更新
我使用的是IntelliJ IDEA,由于某些原因,它们在小部件RoundedButton()
的调用中不显示警告,但仅在dart分析窗口中,有某种方法可以在小部件调用中显示?