image_utils_class 2.0.0 copy "image_utils_class: ^2.0.0" to clipboard
image_utils_class: ^2.0.0 copied to clipboard

A Flutter plugin for iOS and Android for converting 1. any network, assets or file image to base64 and uint8list 2. Converting base64 and uint8list to image

ImageUtils #

A Flutter plugin for iOS and Android for

  • converting any network, assets or file image to base64 and uint8list
  • converting base64 and uint8list to image

Installation #

First, add image_utils_class as a dependency in your pubspec.yaml file.

Example #

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:image_utils_class/image_utils_class.dart';

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final picker = ImagePicker();
  TextEditingController base64;

  @override
  void initState() {
    base64 = TextEditingController(text: '');
    super.initState();
  } 
 
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Container(
          child: Column(
            children: [
              MaterialButton(
                  onPressed: () async {
                    final pickedFile =
                        await picker.getImage(source: ImageSource.gallery);
                    setState(() {
                      if (pickedFile != null) {
                        base64.text =
                            ImageUtils.fileToBase64(File(pickedFile.path));
                      } else {
                        print('No image selected.');
                      }
                    });
                  },
                  child: Text("Select Image")),
              SizedBox(height: 10),
              Text("Base64 String of selected image:${base64.text}"),
              SizedBox(height: 30),
              Text("Base64 to Image:"),
              CircleAvatar(
                radius: 25,
                backgroundImage: ImageUtils.base64ToImage(base64.text),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

All Functions of Class #

Function Will Return
ImageUtils.base64ToImage ( String base64String ) MemoryImage
ImageUtils.base64ToUnit8list ( String base64String ) Uint8List
ImageUtils.fileToBase64 ( File imgFile ) Base64String
ImageUtils.networkImageToBase64 ( String url ) Future of Base64String
ImageUtils.assetImageToBase64 ( String path ) Future of Base64String
9
likes
40
pub points
58%
popularity

Publisher

unverified uploader

A Flutter plugin for iOS and Android for converting 1. any network, assets or file image to base64 and uint8list 2. Converting base64 and uint8list to image

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter, http

More

Packages that depend on image_utils_class