搜索插件、代码仓与 APP 分类

插件详情v1.0.12

universal_image

一个用于在所有平台上显示所有图像类型的 Flutter 包

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
9.6万
喜欢数
38
Pub 分数
160

安装插件

flutter pub add universal_image

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Universal Image 是一个 Flutter 包,旨在跨所有主要平台(包括 Android、iOS、Web、macOS、Windows 和 Linux)显示各种图像格式。它通过提供一致的 API 简化了图像处理,该 API 可自动适应平台的原生图像支持。该包确保无需额外配置或平台特定代码即可可靠地渲染常见图像类型。非常适合需要广泛图像兼容性且设置简单的应用程序。

适合场景

  • 跨平台图像显示
  • 支持多种图像格式
  • 统一的多平台应用图像处理
  • Web 和桌面应用程序中的简化图像加载
  • 减少平台特定的图像代码
  • 快速集成到现有的Flutter项目中

主要特点

  • 支持所有标准图像格式
  • 自动平台适配
  • 所需最小配置
  • 跨平台一致的 API
  • 内置回退机制
  • 在所有目标上优化性能

适合对象

  • 面向多个平台的开发者
  • 需要支持多种图像格式的应用程序
  • 致力于代码简洁的项目
  • 避免使用平台特定的图像逻辑
  • 具有动态或用户上传图像的应用程序
  • 具有图像需求的桌面和网络应用程序

使用建议

  • 可能不支持罕见或实验性的图像格式
  • 依赖于底层平台的图像库
  • 与专用包相比,自定义功能有限
  • 包含编解码器可能带来的尺寸开销
  • 需要互联网访问以加载远程图像
  • 最适合一般用途,而非高级图像处理

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

universal_image

pub package

A comprehensive image package that provides a unified solution for displaying all major image formats across mobile, desktop, and web platforms in Flutter applications.
Skip the hassle of Image.network(), Image.asset(), or Image.memory() - simply pass your image source and let UniversalImage handle the rest

Key Features

  • Supports a wide range of image formats, including JPEG, PNG, GIF, Animated GIF, WebP, Animated WebP, BMP, and WBMP from the built-in Image widget.
  • Seamless integration with flutter_svg for rendering SVG images.
  • Powerful caching capabilities with extended_image for optimal performance.
  • Streamlined usage with imageUri, eliminating the need to specify network, asset, or file paths separately.
  • Ability to work with Icons font and memory-based images.

Example usage:

  • Assets provider
    var image = UniversalImage(
      'assets/image.png', // path must start with 'assets'
      color: Colors.black,
      matchTextDirection: false,
      scale: 1.0,
      width: 100,
      height: 100,
      frameBuilder: null,
      errorBuilder: null,
      semanticLabel: null,
      excludeFromSemantics: false,
      colorBlendMode: BlendMode.clear,
      fit: BoxFit.cover,
      alignment: Alignment.center,
      repeat: ImageRepeat.noRepeat,
      centerSlice: Rect.fromLTWH(0, 0, 100, 100),
      gaplessPlayback: false,
      isAntiAlias: false,
      filterQuality: FilterQuality.low,
      cacheWidth: 100,
      cacheHeight: 100,
      allowDrawingOutsideViewBox: false,
      placeholder: Container(),
      svgSkiaMode: true, // using flutter_svg on web, make sure building with FLUTTER_WEB_USE_SKIA=true
    );
  • File provider:
var image = UniversalImage(
      '/com.package.app/files/image.png', // image storage file path
      color: Colors.black,
      matchTextDirection: false,
      scale: 1.0,
      width: 100,
      height: 100,
      frameBuilder: null,
      errorBuilder: null,
      semanticLabel: null,
      excludeFromSemantics: false,
      colorBlendMode: BlendMode.clear,
      fit: BoxFit.cover,
      alignment: Alignment.center,
      repeat: ImageRepeat.noRepeat,
      centerSlice: Rect.fromLTWH(0, 0, 100, 100),
      gaplessPlayback: false,
      isAntiAlias: false,
      filterQuality: FilterQuality.low,
      cacheWidth: 100,
      cacheHeight: 100,
      allowDrawingOutsideViewBox: false,
      svgSkiaMode: false,
      placeholder: Container(),
    );
  • Network provider:
var image = UniversalImage(
      'https://flutter.github.io/assets-for-api-docs/assets/widgets/owl.jpg',
      color: Colors.black,
      matchTextDirection: false,
      scale: 1.0,
      width: 100,
      height: 100,
      frameBuilder: null,
      errorBuilder: null,
      semanticLabel: null,
      excludeFromSemantics: false,
      colorBlendMode: BlendMode.clear,
      fit: BoxFit.cover,
      alignment: Alignment.center,
      repeat: ImageRepeat.noRepeat,
      centerSlice: Rect.fromLTWH(0, 0, 100, 100),
      gaplessPlayback: false,
      isAntiAlias: false,
      filterQuality: FilterQuality.low,
      cacheWidth: 100,
      cacheHeight: 100,
      allowDrawingOutsideViewBox: false,
      svgSkiaMode: false,
      placeholder: Container(),
    );
  • Icon provider:
var image = UniversalImage(
      Icons.add,
      color: Colors.black,
      size: 30,
      textDirection: TextDirection.ltr
    );
  • Base64 provider:
Uint8List data = await loadImage();
var base64String = data.base64Image; // or replace any base64 image string 
var image = UniversalImage(
      base64String,
      color: Colors.black,
      matchTextDirection: false,
      scale: 1.0,
      width: 100,
      height: 100,
      frameBuilder: null,
      errorBuilder: null,
      semanticLabel: null,
      excludeFromSemantics: false,
      colorBlendMode: BlendMode.clear,
      fit: BoxFit.cover,
      alignment: Alignment.center,
      repeat: ImageRepeat.noRepeat,
      centerSlice: Rect.fromLTWH(0, 0, 100, 100),
      gaplessPlayback: false,
      isAntiAlias: false,
      filterQuality: FilterQuality.low,
      cacheWidth: 100,
      cacheHeight: 100,
      allowDrawingOutsideViewBox: false,
    );
  • Bytes memory provider:
Uint8List data = await loadImage();
var image = UniversalImage(
      data,
      color: Colors.black,
      matchTextDirection: false,
      scale: 1.0,
      width: 100,
      height: 100,
      frameBuilder: null,
      errorBuilder: null,
      semanticLabel: null,
      excludeFromSemantics: false,
      colorBlendMode: BlendMode.clear,
      fit: BoxFit.cover,
      alignment: Alignment.center,
      repeat: ImageRepeat.noRepeat,
      centerSlice: Rect.fromLTWH(0, 0, 100, 100),
      gaplessPlayback: false,
      isAntiAlias: false,
      filterQuality: FilterQuality.low,
      cacheWidth: 100,
      cacheHeight: 100,
      allowDrawingOutsideViewBox: false,
    );

License

License

Copyright (C) 2020 ductranit

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

所属分类

依赖

依赖清单 2 项

源码仓库

使用此插件的项目

所在榜单