HeartClipp

A Flutter package providing a custom clipper for creating a heart-shaped clipping path.

Introduction

The HeartClipp class is a custom clipper designed to create a heart-shaped clipping path for use in Flutter applications. It's a simple and elegant way to create heart-shaped views or masks.

Installation

To use the HeartClipp package in your Flutter project, follow these steps:

  1. Add the package to your project's pubspec.yaml file under the dependencies section:

    dependencies:
      flutter:
        sdk: flutter
      heart_clipp: ^1.0.0 # Replace with the desired version
    
  2. Run flutter pub get to fetch and install the package.

Usage

Here's how to use the HeartClipp class to create a heart-shaped clipping path in your Flutter application:

import 'package:flutter/material.dart';
import 'package:heart_clipp/heart_clipp.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('HeartClipp Example'),
        ),
        body: Center(
          child: ClipPath(
            clipper: HeartClipp(),
            child: Container(
              width: 200,
              height: 200,
              color: Colors.red,
            ),
          ),
        ),
      ),
    );
  }
}

In the example above, we import the HeartClipp class from the heart_clipp package, apply it as a custom clipper using ClipPath, and create a heart-shaped container with a red background color.

Customization

You can adjust the shape of the heart by modifying the control points in the HeartClipp class. Here how:

path.cubicTo(
  size.width,
  halfHeight * 0.8, // Adjust this value to control the top shape
  halfWidth * 1.4,
  -halfHeight * 0.5, // Adjust this value to control the top shape
  halfWidth,
  halfHeight * 0.2, // Adjust this value to control the top shape
);

Feel free to experiment with the control point values to achieve the desired heart shape.

License

This package is distributed under the MIT License. See the LICENSE file for more details.

Issues and Contributions

If you encounter any issues or have suggestions for improvements, please create an issue or submit a pull request on the GitHub repository.

Libraries

heart_image