Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //single_marker_widget.dart
- class SingleMarkerWidget extends StatefulWidget {
- final Table table;
- const SingleMarkerWidget({Key key, this.table}) : super(key: key);
- @override
- _SingleMarkerWidgetState createState() => _SingleMarkerWidgetState();
- }
- class _SingleMarkerWidgetState extends State<SingleMarkerWidget> {
- @override
- Widget build(BuildContext context) {
- return ClipShadowPath(
- clipper: _SingleMarkerClipper(),
- shadow: Shadow(
- color: Colors.grey[800],
- blurRadius: 25,
- offset: Offset(5.0, 8.0),
- ),
- child: RepaintBoundary(
- child: Marquee(
- textList: [
- widget.table.tableGame.gameName,
- widget.table.tableVenue.venueName,
- widget.table.tableVenue.venueDistrict,
- ],
- ),
- ),
- );
- }
- }
- class _SingleMarkerClipper extends CustomClipper<Path> {
- @override
- getClip(Size size) {
- print(
- '_SingleMarkerClipper ==== getClip'); //1- THIS PRINT PRINTS WAY TOO OFTEN. THIS IS WHAT I AM TRYING TO GET RID OF.
- //....
- //DRAW THE CUSTOM SHAPE
- //....
- return path;
- }
- @override
- bool shouldReclip(CustomClipper oldClipper) {
- return false;
- }
- }
- //clip_shadow_path.dart
- @immutable
- class ClipShadowPath extends StatelessWidget {
- final Shadow shadow;
- final CustomClipper<Path> clipper;
- final Widget child;
- const ClipShadowPath({
- @required this.shadow,
- @required this.clipper,
- @required this.child,
- });
- @override
- Widget build(BuildContext context) {
- print('ClipShadowPath ==== build');
- return CustomPaint(
- painter: _ClipShadowShadowPainter(
- clipper: this.clipper,
- shadow: this.shadow,
- ),
- child: ClipPath(child: this.child, clipper: this.clipper),
- );
- }
- }
- class _ClipShadowShadowPainter extends CustomPainter {
- final Shadow shadow;
- final CustomClipper<Path> clipper;
- const _ClipShadowShadowPainter(
- {@required this.shadow, @required this.clipper});
- @override
- void paint(Canvas canvas, Size size) {
- print(
- '_ClipShadowShadowPainter ==== paint'); //2- THIS PRINT PRINTS WAY TOO OFTEN. THIS IS WHAT I AM TRYING TO GET RID OF.
- var paint = shadow.toPaint();
- var clipPath = clipper.getClip(size).shift(shadow.offset);
- canvas.drawPath(clipPath, paint);
- }
- @override
- bool shouldRepaint(CustomPainter oldDelegate) {
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement