搜尋套件、儲存庫與 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 項

原始碼儲存庫

使用此套件的專案

所在榜單