在此處輸入影像描述
class News {
int? id;
String? title;
String? imageUrl;
}
return Container(
child: Center(
child: ListView(
children: [
Card(
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Image.network(_featuredNews.imageUrl!),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
_featuredNews.title!,
style: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.bold,
color: Colors.black),
),
),
當我運行此代碼時,空值檢查運算子用于空值,我的顫振 3.0 請幫助我完成我的作業
uj5u.com熱心網友回復:
Flutter 使用 Dart 語言。請參閱Dart-Null 感知運算子。
添加這個
_featuredNews.title ?? ""
_featuredNews.imageUrl ?? ""
uj5u.com熱心網友回復:
也許 _featuredNews.imageUrl!或 _featuredNews.title!是原因。
你試試怎么樣
errorBuilder在 Image.network 中使用- 或改成喜歡
_featuredNews.title ?? ''處理 - 或通過 'required' variables 接收變數。. .
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/491771.html
