'Desktop' 已弃用,不应使用 (DeviceScreenType)
'Desktop' is deprecated and shouldn't be used (DeviceScreenType)
我试图让我的文本响应,但我收到错误:
'Desktop' is deprecated and shouldn't be used
'Mobile' is deprecated and shouldn't be used
有人知道为什么我不能使用 DeviceScreenType.Desktop 和 DeviceScreenType.Mobile 吗?
我试图自己弄清楚,但我根本不明白。希望你能帮帮我。
class CourseDetails extends StatelessWidget {
const CourseDetails({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return ResponsiveBuilder(
builder: (context, sizingInformation) {
var textAlignment;
if (sizingInformation.deviceScreenType == DeviceScreenType.Desktop) {
textAlignment = TextAlign.left;
} else {
textAlignment = TextAlign.center;
}
double titleSize;
if (sizingInformation.deviceScreenType == DeviceScreenType.Mobile) {
titleSize = 50;
} else {
titleSize = 80;
}
double descriptionSize;
if (sizingInformation.deviceScreenType == DeviceScreenType.Mobile) {
descriptionSize = 16;
} else {
descriptionSize = 21;
}
如果您查看源代码,您可以看到弃用警告的内容:
enum DeviceScreenType {
@Deprecated('Use lowercase version')
Mobile,
@Deprecated('Use lowercase version')
Tablet,
@Deprecated('Use lowercase version')
Desktop,
@Deprecated('Use lowercase version')
Watch,
mobile,
tablet,
desktop,
watch
}
简而言之:将您的枚举转换为小写,例如:DeviceScreenType.desktop
我试图让我的文本响应,但我收到错误:
'Desktop' is deprecated and shouldn't be used
'Mobile' is deprecated and shouldn't be used
有人知道为什么我不能使用 DeviceScreenType.Desktop 和 DeviceScreenType.Mobile 吗? 我试图自己弄清楚,但我根本不明白。希望你能帮帮我。
class CourseDetails extends StatelessWidget {
const CourseDetails({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return ResponsiveBuilder(
builder: (context, sizingInformation) {
var textAlignment;
if (sizingInformation.deviceScreenType == DeviceScreenType.Desktop) {
textAlignment = TextAlign.left;
} else {
textAlignment = TextAlign.center;
}
double titleSize;
if (sizingInformation.deviceScreenType == DeviceScreenType.Mobile) {
titleSize = 50;
} else {
titleSize = 80;
}
double descriptionSize;
if (sizingInformation.deviceScreenType == DeviceScreenType.Mobile) {
descriptionSize = 16;
} else {
descriptionSize = 21;
}
如果您查看源代码,您可以看到弃用警告的内容:
enum DeviceScreenType {
@Deprecated('Use lowercase version')
Mobile,
@Deprecated('Use lowercase version')
Tablet,
@Deprecated('Use lowercase version')
Desktop,
@Deprecated('Use lowercase version')
Watch,
mobile,
tablet,
desktop,
watch
}
简而言之:将您的枚举转换为小写,例如:DeviceScreenType.desktop