image_path_utils.dart 521 B

123456789101112131415161718192021
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/widgets.dart';
  3. //用于加载本地图片的工具类
  4. class ImagePathUtils {
  5. // static bool isSubModule = false; //当前是否是子模块
  6. //如果是子组件,如果是宿主App无需加根目录
  7. static ImageProvider getAssetImagePath(String path) {
  8. return AssetImage(getImgPath(path));
  9. }
  10. static String getImgPath(String name) {
  11. // if (isSubModule) {
  12. // return "../../$name";
  13. // } else {
  14. return name;
  15. // }
  16. }
  17. }