import 'dart:ui';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'ImageFilter Color Leak Issue',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
title: const Text('ImageFilter.blur Color Leak Issue'),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expanded(
child: Container(
color: Colors.white,
width: double.infinity,
child: FittedBox(
fit: BoxFit.contain,
child: Padding(
padding: const EdgeInsets.all(40),
child: Container(
width: 400,
height: 400,
color: const Color(0xFF0000FF),
child: GridView.count(
padding: EdgeInsets.zero,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
crossAxisCount: 3,
children: tiles(),
),
),
),
),
),
),
Expanded(
child: Container(
color: Colors.black,
width: double.infinity,
child: FittedBox(
fit: BoxFit.contain,
child: Padding(
padding: const EdgeInsets.all(40),
child: Container(
width: 400,
height: 400,
color: const Color(0xFF0000FF),
child: GridView.count(
padding: EdgeInsets.zero,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
crossAxisCount: 3,
children: tiles(),
),
),
),
),
),
),
],
),
),
);
}
List<Widget> tiles() => List<Widget>.generate(
9,
(_) => ClipRRect(
child: BackdropFilter(
filter: ImageFilter.blur(
sigmaX: 20,
sigmaY: 20,
),
child: Container(
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.2),
borderRadius: BorderRadius.circular(12),
),
),
),
),
);
}
I'm having an issue with a GridView of blurred tiles using
BackdropFilter with ImageFilter.blurwhere any surrounding color leaks into them:Here is a Dartpad example: https://dartpad.dev/?id=1196002918293fdd251557b037d2d786
Here is the code sample:
flutter doctor: