Skip to content

Instantly share code, notes, and snippets.

View TechieBlossom's full-sized avatar

Prateek Sharma TechieBlossom

View GitHub Profile
@TechieBlossom
TechieBlossom / hexagon_widget.dart
Last active January 13, 2023 18:40
Tween values for rating
_paceAnimation = Tween<double>(
begin: 0.0,
end: messi.pace / 100,
).animate(_controller);
_shootAnimation = Tween<double>(
begin: 0.0,
end: messi.shoot / 100,
).animate(_controller);
...
@TechieBlossom
TechieBlossom / custom_clipper.dart
Last active January 13, 2023 18:06
ClipPath and CustomClipper
ClipPath(
clipper: HexagonClipper(radius: radius),
child: SizedBox(
width: diameter,
height: diameter,
child: ColoredBox(
color: Colors.blueAccent.withOpacity(0.7),
),
),
)
@TechieBlossom
TechieBlossom / custom_painter.dart
Created January 13, 2023 17:31
Inner hexagons
// Inner-most hexagon
Offset(
1/5 * radius * cos(pi * 2 * degree / 360) + center.dx,
1/5 * radius * sin(pi * 2 * degree / 360) + center.dy,
)
//Farthest inner hexagon
Offset(
5/5 * radius * cos(pi * 2 * degree / 360) + center.dx,
5/5 * radius * sin(pi * 2 * degree / 360) + center.dy,
@TechieBlossom
TechieBlossom / custom_painter.dart
Created January 13, 2023 17:20
Rotate base hexagon with 30 degrees
final degree = 60 * i + 30;
@TechieBlossom
TechieBlossom / custom_painter.dart
Last active January 13, 2023 15:23
Generate 6 offsets
for (int i = 0; i < 6; i++) {
final degree = 60 * i;
canvas.drawLine(
Offset(
radius * cos(pi * 2 * degree / 360) + center.dx,
radius * sin(pi * 2 * degree / 360) + center.dy,
),
Offset(
radius * cos(pi * 2 * (degree + 60) / 360) + center.dx,
radius * sin(pi * 2 * (degree + 60) / 360) + center.dy,
@TechieBlossom
TechieBlossom / custom_paint.dart
Created January 13, 2023 15:11
Custom Paint with CustomPainter
CustomPaint(
painter: HexagonPainter(radius: radius),
)
class HexagonPainter extends CustomPainter {
const HexagonPainter({
required this.radius,
});
final double radius;
return Scaffold(
body: Stack(
children: <Widget>[
ProductDetailBackground(
screenHeight: screenHeight,
screenWidth: screenWidth,
),
SingleChildScrollView(
child: Column(
children: <Widget>[
return Scaffold(
body: Stack(
children: <Widget>[
ProductDetailBackground(
screenHeight: screenHeight,
screenWidth: screenWidth,
),
SingleChildScrollView(
child: Column(
children: <Widget>[
GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: Icon(
Icons.arrow_back,
),
)
import 'package:flutter/widgets.dart';
class FadePageRoute extends PageRouteBuilder {
final Widget widget;
FadePageRoute({this.widget})
: super(
pageBuilder: (
BuildContext context,
Animation<double> animation,