Skip to content

Instantly share code, notes, and snippets.

@iskakaushik
Created October 12, 2021 18:30
Show Gist options
  • Save iskakaushik/219d9b16cc94bbaa8560fdb9361096f1 to your computer and use it in GitHub Desktop.
Save iskakaushik/219d9b16cc94bbaa8560fdb9361096f1 to your computer and use it in GitHub Desktop.
import 'dart:math' as math;
import 'dart:ui';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
// ignore: use_key_in_widget_constructors
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Blurred Edges',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Blurred Edges'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
AnimationController? animator;
@override
void initState() {
super.initState();
animator = AnimationController(
vsync: this,
);
animator!.repeat(period: const Duration(seconds: 3));
}
@override
Widget build(BuildContext context) {
print('device pixel ratio = ${window.devicePixelRatio}');
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Stack(
children: <Widget>[
Container(width: 360, height: 400),
Positioned(
left: 50,
top: 50,
child: Container(width: 50, height: 50, color: Colors.grey),
),
Positioned(
left: 50,
top: 50,
child: ImageFiltered(
imageFilter: ImageFilter.blur(sigmaX: 20.0, sigmaY: 20.0),
child: Container(width: 50, height: 50, color: Colors.red),
),
),
Positioned(
left: 250.2,
top: 50.2,
child: Container(width: 50.2, height: 50.2, color: Colors.grey),
),
Positioned(
left: 250.2,
top: 50.2,
child: ImageFiltered(
imageFilter: ImageFilter.blur(sigmaX: 20.0, sigmaY: 20.0),
child: Container(width: 50.2, height: 50.2, color: Colors.red),
),
),
Positioned(
left: 50,
top: 250,
child: Container(width: 50, height: 50, color: Colors.grey),
),
Positioned(
left: 50,
top: 250,
child: ImageFiltered(
imageFilter: ImageFilter.blur(sigmaX: 20.0, sigmaY: 20.0),
child: Transform.rotate(
angle: math.pi / 4.0,
child: Container(width: 50, height: 50, color: Colors.red),
),
),
),
Positioned(
left: 250,
top: 250,
child: Container(width: 50, height: 50, color: Colors.grey),
),
Positioned(
left: 250,
top: 250,
child: ImageFiltered(
imageFilter: ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0),
child: RotationTransition(
turns: animator!,
child: Container(width: 50, height: 50, color: Colors.red),
),
),
),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment