このページには広告が含まれる場合があります。
Flutterのバージョン2.2から「Null-safety」が強制適用となりましたが、
その際に、Flutter2.2未満のときは普通に動いていたこんなコードに
@override
Widget build(BuildContext context) {
return CircleAvatar(
radius: radius,
backgroundImage: isImageFromFile
? FileImage(File(photoUrl))
: CachedNetworkImageProvider(photoUrl),
);
}
突如
The argument type Object can’t be assigned to the parameter type ImageProvider
という謎の文法エラーが発生してしまいますので、
以下の要領で「CachedNetworkImageProvider(・・・)」のコンストラクタの後ろに「as」を付けて「ImageProvider」に強制型変換してやると解消します。
Steps to Reproduce Just paste the following code class NoImage extends StatelessWidget { @override Widget build(BuildContext context) { return Container( decoration: BoxDecoration( image: Decoratio...
(詳しくは、以下の動画で解説していますので、よろしければご覧下さい)



















