SHARE
TWEET

Untitled

a guest Jun 20th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //single_marker_widget.dart
  2. class SingleMarkerWidget extends StatefulWidget {
  3.   final Table table;
  4.   const SingleMarkerWidget({Key key, this.table}) : super(key: key);
  5.   @override
  6.   _SingleMarkerWidgetState createState() => _SingleMarkerWidgetState();
  7. }
  8.  
  9. class _SingleMarkerWidgetState extends State<SingleMarkerWidget> {
  10.   @override
  11.   Widget build(BuildContext context) {
  12.     return ClipShadowPath(
  13.       clipper: _SingleMarkerClipper(),
  14.       shadow: Shadow(
  15.         color: Colors.grey[800],
  16.         blurRadius: 25,
  17.         offset: Offset(5.0, 8.0),
  18.       ),
  19.       child: RepaintBoundary(
  20.         child: Marquee(
  21.           textList: [
  22.             widget.table.tableGame.gameName,
  23.             widget.table.tableVenue.venueName,
  24.             widget.table.tableVenue.venueDistrict,
  25.           ],
  26.         ),
  27.       ),
  28.     );
  29.   }
  30. }
  31.  
  32. class _SingleMarkerClipper extends CustomClipper<Path> {
  33.   @override
  34.   getClip(Size size) {
  35.     print(
  36.         '_SingleMarkerClipper ==== getClip'); //1- THIS PRINT PRINTS WAY TOO OFTEN. THIS IS WHAT I AM TRYING TO GET RID OF.
  37.     //....
  38.     //DRAW THE CUSTOM SHAPE
  39.     //....
  40.     return path;
  41.   }
  42.  
  43.   @override
  44.   bool shouldReclip(CustomClipper oldClipper) {
  45.     return false;
  46.   }
  47. }
  48.  
  49. //clip_shadow_path.dart
  50. @immutable
  51. class ClipShadowPath extends StatelessWidget {
  52.   final Shadow shadow;
  53.   final CustomClipper<Path> clipper;
  54.   final Widget child;
  55.  
  56.   const ClipShadowPath({
  57.     @required this.shadow,
  58.     @required this.clipper,
  59.     @required this.child,
  60.   });
  61.  
  62.   @override
  63.   Widget build(BuildContext context) {
  64.     print('ClipShadowPath ==== build');
  65.     return CustomPaint(
  66.       painter: _ClipShadowShadowPainter(
  67.         clipper: this.clipper,
  68.         shadow: this.shadow,
  69.       ),
  70.       child: ClipPath(child: this.child, clipper: this.clipper),
  71.     );
  72.   }
  73. }
  74.  
  75. class _ClipShadowShadowPainter extends CustomPainter {
  76.   final Shadow shadow;
  77.   final CustomClipper<Path> clipper;
  78.  
  79.   const _ClipShadowShadowPainter(
  80.       {@required this.shadow, @required this.clipper});
  81.  
  82.   @override
  83.   void paint(Canvas canvas, Size size) {
  84.     print(
  85.         '_ClipShadowShadowPainter ==== paint'); //2- THIS PRINT PRINTS WAY TOO OFTEN. THIS IS WHAT I AM TRYING TO GET RID OF.
  86.     var paint = shadow.toPaint();
  87.     var clipPath = clipper.getClip(size).shift(shadow.offset);
  88.     canvas.drawPath(clipPath, paint);
  89.   }
  90.  
  91.   @override
  92.   bool shouldRepaint(CustomPainter oldDelegate) {
  93.     return false;
  94.   }
  95. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top