network_to_memory_image 1.0.0 copy "network_to_memory_image: ^1.0.0" to clipboard
network_to_memory_image: ^1.0.0 copied to clipboard

The NetworkToMemoryImage library fetches network images and converts them into Uint8List for easy use in Flutter. It supports single and multiple image downloads with error handling, making it ideal f [...]

Here's a README.md file for network_to_memory_image Flutter package:


# Network to Memory Image

[![Pub.dev](https://img.shields.io/pub/v/network_to_memory_image)](https://pub.dev/packages/network_to_memory_image)  
A Flutter package to convert network images into `Uint8List` for efficient image manipulation and offline usage.

## ✨ Features
- Load single or multiple network images into memory (`Uint8List`).
- Easily integrate with `Image.memory()`.
- Handles invalid URLs gracefully.

## 🚀 Installation
Add the package to your `pubspec.yaml`:
```yaml
dependencies:
  network_to_memory_image: latest_version

Run:

flutter pub get

📌 Usage #

Single Image Example #

import 'package:flutter/material.dart';
import 'package:network_to_memory_image/network_to_memory_image.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  Uint8List? _imageBytes;

  @override
  void initState() {
    super.initState();
    _loadImage();
  }

  Future<void> _loadImage() async {
    final imageBytes = await NetworkToMemoryImage.loadSingle(
      "https://picsum.photos/200",
    );
    setState(() {
      _imageBytes = imageBytes;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text("Network to Memory Image")),
        body: Center(
          child: _imageBytes != null
              ? Image.memory(_imageBytes!)
              : CircularProgressIndicator(),
        ),
      ),
    );
  }
}

Multiple Images Example #

import 'package:flutter/material.dart';
import 'package:network_to_memory_image/network_to_memory_image.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  List<Uint8List?> _imageList = [];
  bool _isLoading = true;

  @override
  void initState() {
    super.initState();
    _loadImages();
  }

  Future<void> _loadImages() async {
    List<String> urls = [
      "https://picsum.photos/200?random=1",
      "https://picsum.photos/200?random=2",
      "https://picsum.photos/200?random=3",
    ];
    
    final images = await NetworkToMemoryImage.loadMultiple(urls);

    setState(() {
      _imageList = images;
      _isLoading = false;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text("Network to Memory Image")),
        body: Center(
          child: _isLoading
              ? CircularProgressIndicator()
              : Wrap(
                  spacing: 10,
                  runSpacing: 10,
                  children: _imageList.map((imageBytes) {
                    return imageBytes != null
                        ? Image.memory(imageBytes, width: 100, height: 100)
                        : Icon(Icons.error, size: 50, color: Colors.red);
                  }).toList(),
                ),
        ),
      ),
    );
  }
}

📜 License #

MIT License

🧑‍💻 Developer #


Support the Project #

If you find this package useful, give it a ⭐ on GitHub! Contributions and feedback are welcome! 🚀


---

This version is concise, removes unnecessary content, and focuses on the essential details. Let me know if you need further adjustments! 🚀
2
likes
150
points
15
downloads

Publisher

unverified uploader

Weekly Downloads

The NetworkToMemoryImage library fetches network images and converts them into Uint8List for easy use in Flutter. It supports single and multiple image downloads with error handling, making it ideal for loading and caching images efficiently.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, http

More

Packages that depend on network_to_memory_image