Blame view

lib/common/widgets/ow_image_widget.dart 731 Bytes
6f617434   liangchengyou   feat:磨耳朵/视频跟读列表页接口调整
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  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.contains('http')?
      CachedNetworkImage(
        imageUrl: name,
        height: height,
        width: width,
        fit: fit,
      ):Image.asset(
        name,
        height: height,
        width: width,
        fit: fit,
      );
    }
  }