Skip to content

Instantly share code, notes, and snippets.

@collinjackson
Last active May 12, 2020 10:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save collinjackson/4318255c6390f080f91011329a068d62 to your computer and use it in GitHub Desktop.
Save collinjackson/4318255c6390f080f91011329a068d62 to your computer and use it in GitHub Desktop.
Test case for BackdropFilter bugs
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
void main() {
runApp(new MaterialApp(
home: new HomePage(),
));
}
class HomePage extends StatefulWidget {
HomePageState createState() => new HomePageState();
}
class HomePageState extends State<HomePage> {
double _sigma = 3.0;
double _opacity = 0.5;
bool _showText = true;
BoxShape _innerClip;
BoxShape _outerClip;
@override
Widget build(BuildContext context) {
Widget test =
new BackdropFilter(
filter: new ui.ImageFilter.blur(sigmaX: _sigma, sigmaY: _sigma),
child: new Container(
color: Colors.blue.withOpacity(_opacity),
padding: const EdgeInsets.all(30.0),
width: 90.0,
height: 90.0,
child: new Center(
child: _showText ? new Text('Test') : null,
),
),
);
switch (_innerClip) {
case BoxShape.circle:
test = new ClipOval(child: test);
break;
case BoxShape.rectangle:
test = new ClipRect(child: test);
break;
}
test = new Container(
decoration: new BoxDecoration(
color: Colors.grey.shade200.withOpacity(_opacity),
),
padding: new EdgeInsets.all(30.0),
child: test,
);
switch (_outerClip) {
case BoxShape.circle:
test = new ClipOval(child: test);
break;
case BoxShape.rectangle:
test = new ClipRect(child: test);
break;
}
test = new Container(
height: 200.0,
margin: new EdgeInsets.all(10.0),
decoration: new BoxDecoration(
image: new DecorationImage(
fit: BoxFit.cover,
image: new NetworkImage(
'http://www.powerpointhintergrund.com/uploads/abstract-pattern-background-0.jpeg'
),
)
),
child: new Center(
child: test,
),
);
return new Scaffold(
appBar: new AppBar(
title: new Text('BackdropFilter Test'),
),
body: new Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
test,
new Expanded(
child: new ListView(
children: <Widget>[
new ListTile(
title: new Text('Sigma'),
subtitle: new Slider(
min: 0.0,
max: 50.0,
value: _sigma,
onChanged: (double value) {
setState(() {
_sigma = value;
});
},
),
),
new ListTile(
title: new Text('Opacity'),
subtitle: new Slider(
min: 0.0,
max: 1.0,
value: _opacity,
onChanged: (double value) {
setState(() {
_opacity = value;
});
},
),
),
new CheckboxListTile(
value: _showText,
onChanged: (bool value) {
setState(() {
_showText = value;
});
},
title: new Text('Show text'),
),
new ListTile(
title: new Text('Inner clip'),
subtitle: new DropdownButton<BoxShape>(
onChanged: (BoxShape value) {
setState(() {
_innerClip = value;
});
},
value: _innerClip,
items: <DropdownMenuItem<BoxShape>>[
new DropdownMenuItem(
value: null,
child: new Text('None'),
),
new DropdownMenuItem(
value: BoxShape.circle,
child: new Text('ClipOval'),
),
new DropdownMenuItem(
value: BoxShape.rectangle,
child: new Text('ClipRect'),
),
],
),
),
new ListTile(
title: new Text('Outer clip'),
subtitle: new DropdownButton<BoxShape>(
onChanged: (BoxShape value) {
setState(() {
_outerClip = value;
});
},
value: _outerClip,
items: <DropdownMenuItem<BoxShape>>[
new DropdownMenuItem(
value: null,
child: new Text('None'),
),
new DropdownMenuItem(
value: BoxShape.circle,
child: new Text('ClipOval'),
),
new DropdownMenuItem(
value: BoxShape.rectangle,
child: new Text('ClipRect'),
),
],
),
),
],
),
),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment