binary_image_generator 0.0.1 binary_image_generator: ^0.0.1 copied to clipboard
A Flutter package to generate customizable 5x5 grid images based on a 15-bit binary string. Define background and square colors, and receive the generated image as a Uint8List for reuse or further pro [...]
import 'dart:typed_data';
import 'package:binary_image_generator/binary_image_generator.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Binary Image Generator Example')),
body: const Center(
child: BinaryImageTester(),
),
),
);
}
}
class BinaryImageTester extends StatelessWidget {
const BinaryImageTester({super.key});
@override
Widget build(BuildContext context) {
// Binary string must be exactly 15 bits
const binaryString = '111110000000011';
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ClipOval(
child: BinaryImageGenerator(
binaryString: binaryString,
backgroundColor: Colors.yellow, // Customize background color
squareColor: Colors.black, // Customize square color
onImageReady: (Uint8List imageData) {
// This callback gets called when the image is ready
// You could also display the image, save it, or send it to a server, etc.
},
),
),
],
);
}
}