ow_image_widget.dart
734 Bytes
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
class OwImageWidget extends StatelessWidget {
const OwImageWidget({super.key, this.width, this.height, required this.name, this.fit});
final double? width;
final double? height;
final BoxFit? fit;
final String name;
@override
Widget build(BuildContext context) {
if (name.isEmpty) {
return SizedBox(
height: height,
width: width,
);
}
return name.startsWith('http')?
CachedNetworkImage(
imageUrl: name,
height: height,
width: width,
fit: fit,
):Image.asset(
name,
height: height,
width: width,
fit: fit,
);
}
}