Dart library with stack blur algorithm for RGBA images

Pub Package
pub points

Applies the stack blur to
a buffer with RGBA pixels.

The Stack blur algorithm works fast and looks good. It is a compromise between
Gaussian blur
and Box blur.

image library

import 'dart:io';

import 'package:image/image.dart';
import 'package:stack_blur/stack_blur.dart';

void main() {
  // loading image from file
  final image = decodeImage(File('source.png').readAsBytesSync())!;

  // blurring image pixels with blur radius 42
  stackBlurRgba(, image.width, image.height, 42);

  // saving image to file

bitmap library

Flutter images have the same RGBA pixel buffer. You can get it in a rather non-obvious
through ImageStreamListener.

import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:bitmap/bitmap.dart';

Future<Image> blurAsset(String assetName) async {
  ImageProvider provider = ExactAssetImage(assetName);

  // Rain dance to get RGBA pixels from image
  final ImageStream stream = provider.resolve(ImageConfiguration.empty);
  final completer = Completer<ui.Image>();
  late ImageStreamListener listener;
  listener = ImageStreamListener((frame, _) {
  ui.Image image = await completer.future;
  ByteData rgbaData = (await image.toByteData(format: ui.ImageByteFormat.rawRgba))!;

  // This is the pixels we need
  Uint32List rgbaPixels = rgbaData.buffer.asUint32List();

  // We can blur the image buffer
  stackBlurRgba(rgbaPixels, image.width, image.height, 42);

  // We need a third-party 'bitmap' library to turn the buffer into a widget
  final bitmap = Bitmap.fromHeadless(
      image.width, image.height,
  return Image.memory(bitmap.buildHeaded());


View Github

A userbot made for telegram

Send delayed/scheduled HTTP requests