Skip to content

Instantly share code, notes, and snippets.

@jkmpariab
Created December 8, 2019 18:48
Show Gist options
  • Select an option

  • Save jkmpariab/862e31ad0567fa3d0de037dae0bc1cd4 to your computer and use it in GitHub Desktop.

Select an option

Save jkmpariab/862e31ad0567fa3d0de037dae0bc1cd4 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() {
runApp(App());
}
class App extends StatefulWidget {
@override
State<App> createState() => _AppState();
}
class _AppState extends State<App> with SingleTickerProviderStateMixin {
AnimationController _controller;
@override
void initState() {
super.initState();
_controller =
AnimationController(vsync: this, duration: const Duration(seconds: 5))
..repeat();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'My App',
home: Scaffold(
appBar: AppBar(title: Text('Say hello to flutter on web!')),
body: AnimatedBuilder(
animation: _controller,
builder: (_, __) {
return ClipPath(
clipper: MyClipper(),
child: Container(
decoration: BoxDecoration(
gradient: RadialGradient(
center: Alignment(0, 0),
radius: 2,
colors: [
Colors.yellow,
Colors.transparent,
],
stops: [0, _controller.value],
),
),
),
);
},
),
),
);
}
}
class MyClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
// return Path()
// ..moveTo(size.width / 3, 0)
// ..lineTo(0, size.height)
// ..lineTo(size.width, size.height)
// ..lineTo(size.width * 2 / 3, 0);
// return Path()
// ..moveTo(20, size.height - 20)
// ..quadraticBezierTo(-100, -100, size.width - 20, 20)
// ..quadraticBezierTo(
// size.width - -100, size.height - -100, 20, size.height - 20);
return Path()
..lineTo(0, 200)
..lineTo(200, 200)
..lineTo(200, 0)
..lineTo(0, 0)
..moveTo(size.width - 200, size.height - 200)
..lineTo(size.width - 200, size.height)
..lineTo(size.width, size.height)
..lineTo(size.width, size.height - 200)
..lineTo(size.width - 200, size.height - 200);
}
@override
bool shouldReclip(_) => false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment