Created
December 6, 2019 12:53
-
-
Save peekpt/5be23b577e99856e2bbd223c6df69299 to your computer and use it in GitHub Desktop.
Revisions
-
peekpt created this gist
Dec 6, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,108 @@ import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( theme: ThemeData.light(), debugShowCheckedModeBanner: false, home: Scaffold( body: Center( child: TriangleError(), ), ), ); } } class TriangleError extends StatefulWidget { const TriangleError({Key key}) : super(key: key); @override _TriangleErrorState createState() => _TriangleErrorState(); } class _TriangleErrorState extends State<TriangleError> with TickerProviderStateMixin { AnimationController rotationController; @override void initState() { rotationController = AnimationController( duration: const Duration(milliseconds: 2000), vsync: this, )..repeat(); super.initState(); } @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.all(10), child: Center( child: AspectRatio( aspectRatio: 1, child: Stack( children: <Widget>[ Align( alignment: Alignment.center, child: RotationTransition( turns: Tween(begin: 0.0, end: 1.0).animate(rotationController), child: ClipPath( clipper: TrianglePath(), child: LayoutBuilder( builder: (context, constrains) { return Container( // uncomment and reload view // color: Colors.red, decoration: BoxDecoration( gradient: LinearGradient( colors: [ Theme.of(context).primaryColorLight, Theme.of(context) .primaryColorLight .withAlpha(10) ], begin: Alignment.bottomCenter, end: Alignment.topCenter, ), ), margin: EdgeInsets.all(constrains.maxHeight / 8), ); }, ), ), ), ), ], ), ), ), ); } } class TrianglePath extends CustomClipper<Path> { var radius = 10.0; @override Path getClip(Size size) { Path path = Path(); path.lineTo(size.width / 4, 0); path.lineTo(size.width / 2, size.height / 2); path.lineTo(size.width - size.width / 4, 0); path.lineTo(0, 0); return path; } @override bool shouldReclip(CustomClipper<Path> oldClipper) => false; }