Skip to content

Instantly share code, notes, and snippets.

@Djelnar
Forked from d3xvn/DiamondBorder.dart
Created October 17, 2019 23:04
Show Gist options
  • Select an option

  • Save Djelnar/f4c5c3caabf10043820c3ffeb3d4d1ae to your computer and use it in GitHub Desktop.

Select an option

Save Djelnar/f4c5c3caabf10043820c3ffeb3d4d1ae to your computer and use it in GitHub Desktop.
class _DiamondBorder extends ShapeBorder {
const _DiamondBorder();
@override
EdgeInsetsGeometry get dimensions {
return const EdgeInsets.only();
}
@override
Path getInnerPath(Rect rect, { TextDirection textDirection }) {
return getOuterPath(rect, textDirection: textDirection);
}
@override
Path getOuterPath(Rect rect, { TextDirection textDirection }) {
return Path()
..moveTo(rect.left + rect.width / 2.0, rect.top)
..lineTo(rect.right, rect.top + rect.height / 2.0)
..lineTo(rect.left + rect.width / 2.0, rect.bottom)
..lineTo(rect.left, rect.top + rect.height / 2.0)
..close();
}
@override
void paint(Canvas canvas, Rect rect, { TextDirection textDirection }) {}
// This border doesn't support scaling.
@override
ShapeBorder scale(double t) {
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment