패키지, 저장소 및 앱 카테고리 검색

패키지 상세v2.0.1

widgets_to_image

모든 위젯을 사용자 정의 가능한 형식, 품질 설정 및 고급 기능과 함께 고화질 이미지로 변환할 수 있는 강력한 Flutter 패키지입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
2.6만
좋아요
225
Pub 점수
160

패키지 설치

flutter pub add widgets_to_image

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

widgets_to_image는 Flutter 패키지로, 다양한 형식, 사용자 정의 가능한 품질 설정 및 고급 렌더링 옵션을 지원하여 어떤 위젯도 고화질 이미지로 변환할 수 있게 해줍니다. 앱 내에서 스크린샷, 미리보기 또는 내보낼 수 있는 자산을 직접 생성하는 데 이상적입니다. 이 패키지는 Android, iOS, Web, macOS, Windows, Linux 등 주요 플랫폼 전반에서 작동하므로 크로스플랫폼 프로젝트에 매우 유연합니다. 간단한 API를 통해 테스트 워크플로우, UI 미리보기 및 동적 콘텐츠 생성에 원활하게 통합됩니다.

사용 사례

  • 프로그래밍적으로 앱 스크린샷 생성하기
  • 개발 중에 UI 미리보기 만들기
  • 공유를 위해 위젯을 이미지로 내보내기
  • 시각 검증을 통한 자동 테스트
  • Flutter 앱 내에서 건축 설계 도구 구현

주요 기능

  • 다양한 이미지 형식 지원
  • 사용자 지정 가능한 이미지 품질 및 크기
  • 크로스 플랫폼 호환성
  • 기존 위젯과의 간편한 통합
  • 배경색 및 패딩과 같은 고급 렌더링 옵션

적합한 대상

  • UI 미리보기 도구를 개발하는 개발자
  • 자동 스크린샷 생성이 필요한 팀
  • 동적 이미지 내보내기를 필요로 하는 앱
  • 테스트 자동화 엔지니어
  • 디자인 중심의 플러터 애플리케이션

고려 사항

  • 복잡한 위젯 렌더링 시 성능 영향
  • 큰 또는 고해상도 이미지의 메모리 사용량
  • 비동기 렌더링을 올바르게 처리해야 합니다
  • 정적 이미지 출력에 제한됨(애니메이션 없음)
  • 최적의 결과를 얻기 위해 플랫폼별 구성이 필요할 수 있습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Widgets To Image

pub package License: MIT Demo

A powerful Flutter package to convert any widget into high-quality images with customizable formats, quality settings, and advanced features.

🌐 Live Demo

Try the interactive demo →

Experience the package capabilities with our modern, professional demo featuring:

  • 🎯 Basic widget capture examples
  • ⚙️ Advanced configuration options
  • 🎭 Animation capture demonstrations
  • 📱 Responsive design with Material 3

Demo

✨ Features

  • 🎯 Simple API - Convert any widget to image with just a few lines of code
  • 🖼️ Multiple Formats - Support for PNG, JPEG, Raw RGBA, and Raw Unmodified formats
  • ⚙️ Customizable Options - Control pixel ratio, quality, animations, and delays
  • 🎨 High Quality - Generate high-resolution images with custom pixel ratios
  • 🔄 Animation Support - Capture animated widgets with proper timing
  • 📱 Cross Platform - Works on iOS, Android, Web, macOS, Windows, and Linux
  • 🧪 Well Tested - Comprehensive test suite ensuring reliability
  • 📚 Rich Documentation - Detailed examples and API documentation

🚀 Getting Started

Installation

Add this to your package's pubspec.yaml file:

dependencies:
  widgets_to_image: ^2.0.0

Install it using the command line:

flutter pub get

Import the package:

import 'package:widgets_to_image/widgets_to_image.dart';

📖 Usage

Basic Usage
// Create a controller
WidgetsToImageController controller = WidgetsToImageController();

// Wrap your widget
WidgetsToImage(
  controller: controller,
  child: Container(
    width: 200,
    height: 100,
    color: Colors.blue,
    child: const Center(
      child: Text(
        'Hello World!',
        style: TextStyle(color: Colors.white, fontSize: 20),
      ),
    ),
  ),
)

// Capture the widget
Uint8List? bytes = await controller.capture();
Advanced Usage with Options
// Capture with custom options
Uint8List? bytes = await controller.capture(
  options: const CaptureOptions(
    format: ImageFormat.jpeg,
    pixelRatio: 3.0,
    quality: 95,
    waitForAnimations: true,
    delayMs: 100,
  ),
);
Convenience Methods
// Capture as PNG with high resolution
Uint8List? pngBytes = await controller.capturePng(
  pixelRatio: 3.0,
  waitForAnimations: true,
);

// Capture as JPEG with custom quality
Uint8List? jpegBytes = await controller.captureJpeg(
  quality: 90,
  pixelRatio: 2.0,
);
Reactive UI with Builder
WidgetsToImageBuilder(
  controller: controller,
  builder: (context, isCapturing, capture) {
    return Column(
      children: [
        if (isCapturing)
          const CircularProgressIndicator()
        else
          ElevatedButton(
            onPressed: () async {
              final bytes = await capture();
              // Handle the captured bytes
            },
            child: const Text('Capture Widget'),
          ),
      ],
    );
  },
)
Error Handling
try {
  final bytes = await controller.capture();
  // Success - use the bytes
} on CaptureException catch (e) {
  // Handle specific capture errors
  print('Capture failed: ${e.message}');
  if (e.originalError != null) {
    print('Caused by: ${e.originalError}');
  }
} catch (e) {
  // Handle other errors
  print('Unexpected error: $e');
}
Lifecycle Callbacks
controller.onCaptureStart = () {
  print('Capture started');
};

controller.onCaptureComplete = (bytes) {
  print('Capture completed with ${bytes.length} bytes');
};

controller.onCaptureError = (error) {
  print('Capture failed: ${error.message}');
};

🔧 API Reference

CaptureOptions
Property Type Default Description
pixelRatio double 1.0 The pixel ratio for the captured image
format ImageFormat ImageFormat.png The output image format
quality int 95 Quality for JPEG format (0-100)
waitForAnimations bool false Wait for animations before capturing
delayMs int 0 Additional delay in milliseconds
ImageFormat
  • ImageFormat.png - PNG format with transparency support
  • ImageFormat.jpeg - JPEG format with quality control
  • ImageFormat.rawRgba - Raw RGBA pixel data
  • ImageFormat.rawUnmodified - Raw unmodified pixel data
WidgetsToImageController Methods
  • capture({CaptureOptions options}) - Capture with custom options
  • capturePng({...}) - Convenience method for PNG capture
  • captureJpeg({...}) - Convenience method for JPEG capture
  • dispose() - Clean up resources
WidgetsToImage Properties
  • controller - The capture controller (required)
  • child - The widget to capture
  • clipBehavior - Whether to clip the child widget

📱 Example App

The package includes a comprehensive example app demonstrating:

  • Basic widget capture
  • Advanced options configuration
  • Animated widget capture
  • Different image formats
  • Error handling
  • Reactive UI updates

Run the example:

cd example
flutter run

🛠️ Platform Support

Platform Support
Android ✅
iOS ✅
Web ✅
macOS ✅
Windows ✅
Linux ✅

🤝 Contributing

Contributions are welcome! Please read our contributing guidelines and submit pull requests to our repository.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Flutter team for the amazing framework
  • Community contributors for feedback and improvements

📞 Support


Made with ❤️ by Mohamed Abdo phone

MacOS

phone

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트