Flutter implementation of Figma's corner smoothing.

Overview

Figma Squircle

image

Flutter implementation of Figma's corner smoothing.

Usage

Decoration

The SmoothRectangleBorder can be provided to a regular ShapeDecoration with a custom SmoothBorderRadius.

Container(
    height: 100,
    width: 100,
    decoration: ShapeDecoration(
        color: Colors.red.withOpacity(0.75),
        shape: SmoothRectangleBorder(
            borderRadius: SmoothBorderRadius(
              cornerRadius: 10,
              cornerSmoothing: 0.5,
            ),
        ),
    ),
)

Only

Each corner can have an independent smoothing and radius.

SmoothBorderRadius.only(
    topLeft: SmoothRadius(
        cornerRadius: 10,
        cornerSmoothing: 1,
    ),
    topRight: SmoothRadius(
        cornerRadius: 20,
        cornerSmoothing: 0.4,
    ),
    bottomLeft: SmoothRadius(
        cornerRadius: 5,
        cornerSmoothing: 0.8,
    ),
    bottomRight: SmoothRadius(
        cornerRadius: 30,
        cornerSmoothing: 0.6,
    ),
),

Clip

To clip any widget with a smooth rectangle, use the ClipSmoothRect.

ClipSmoothRect(
    radius: SmoothBorderRadius(
        cornerRadius: 10,
        cornerSmoothing: 1,
    ),
    child: Container(
        color: Colors.red,
        width: 100,
        height: 100,
    ),
)

Thanks

Comments
  • Fixes an issue with BorderAlign

    Fixes an issue with BorderAlign

    There is currently an issue with how borders are painted. This PR aims to fix it.

    Before this PR: (Red being the same component without a border) image

    With this PR: image

    As we can see, before this PR, the component without border would not perfectly match with the same with a border.

    opened by letsar 3
  • Border & shadow on clipped image?

    Border & shadow on clipped image?

    Hello, thanks for this cool package. I'm having trouble figuring out how to add a border to a clipped image. Also, adding a shadow. I've tried several combinations but not luck so far. Any help appreciated. Thanks

    opened by jtkeyva 0
  • Percentage radius

    Percentage radius

    I have a custom squircle painter that I 'stole' off flutter/flutter PRs a while back. One thing I did was add the ability to paint percentage radii. It's a super handy feature, and the only thing stopping me from switching to figma_squircle full time.

    While there are ways to do this with a LayoutBuilder, there is enough information available in OutlinedBorder to paint percentage radii from a constructor and a percentage value.

    opened by lukepighetti 1
  • SmoothRectangleBorder doesnt complete with the BoderSide of another SmoothRectangleBorder

    SmoothRectangleBorder doesnt complete with the BoderSide of another SmoothRectangleBorder

    Minimal Code Example:

    import 'package:figma_squircle/figma_squircle.dart';
    import 'package:flutter/foundation.dart';
    import 'package:flutter/material.dart';
    import 'package:flutter/widgets.dart';
    
    class ASection extends StatelessWidget {
      const ASection({Key? key}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            Container(
              decoration: ShapeDecoration(
                color: Colors.blue,
                shape: SmoothRectangleBorder(
                  borderRadius: SmoothBorderRadius.only(
                    topLeft: SmoothRadius(
                      cornerRadius: 10,
                      cornerSmoothing: 0.5,
                    ),
                    topRight: SmoothRadius(
                      cornerRadius: 10,
                      cornerSmoothing: 0.5,
                    ),
                  ),
                ),
              ),
              height: 48,
            ),
            Container(
              decoration: ShapeDecoration(
                color: Colors.white,
                shape: SmoothRectangleBorder(
                  side: BorderSide(
                    color: Colors.green,
                  ),
                  borderRadius: SmoothBorderRadius.only(
                    bottomLeft: SmoothRadius(
                      cornerRadius: 10,
                      cornerSmoothing: 0.5,
                    ),
                    bottomRight: SmoothRadius(
                      cornerRadius: 10,
                      cornerSmoothing: 0.5,
                    ),
                  ),
                ),
              ),
              height: 48,
            )
          ],
        );
      }
    }
    
    
    Bildschirmfoto 2021-11-05 um 16 04 55

    If you are using BoxDecorations this does not happen. I think its because SmoothRectangleBorder extends OutlinedBorder

    opened by LenWdk 1
  • Wrapping with Opacity widget makes it work broken

    Wrapping with Opacity widget makes it work broken

    Hi, love this package!

    However, I've encountered a bug. I'm using it as border of a MaterialButton.

    MaterialButton( elevation: 0, shape: SmoothRectangleBorder( side: BorderSide(color: Colors.white, width: 4), borderRadius: SmoothBorderRadius( cornerRadius: 16, cornerSmoothing: 1.0, ), ), color: lightestColor.withOpacity(0.3)...

    When I wrap it with Opacity widget, there is an error on the corners as following photo shows. (Bottom one is wrapped with Opacity) (Even if the opacity is given as "0.99", it happens.)

    IMG_2C2865CFE7C8-1

    opened by knissophiliac 0
Owner
Aloïs Deniel
Flutter Freelance
Aloïs Deniel
Learn Flutter on Flutter! A widget directory with implementation samples!

Fludget Browse through a variety of widgets used in flutter This application is developed to learn Flutter using Flutter. Different widgets used in fl

ACM VIT 29 Nov 23, 2022
Paper is a implementation of Flx Design System for Flutter

Paper is a implementation of Flx Design System for Flutter. Installing Add a lines like this to your pubspec.yaml. dependencies: paper: git:

Flx Team 3 Nov 21, 2021
A Flutter package with custom implementation of Drawer

Flutter Zoom Drawer A Flutter package with custom implementation of the Side Menu (Drawer) Getting Started To start using this package, add flutter_zo

null 335 Dec 22, 2022
Flutter implementation of Google Mobile Vision.

flutter_mobile_vision Flutter implementation for Google Mobile Vision. Based on Google Mobile Vision. Android Samples -=- iOS Samples Liked? ⭐ Star th

Eduardo Folly 450 Jan 6, 2023
Backdrop implementation in flutter.

backdrop Backdrop implementation in flutter. This widget is in active development. Any contribution, idea, criticism or feedback is welcomed. Quick li

Harsh Bhikadia 6 Jan 6, 2022
a python-like bytes_io implementation for dart

bytes_io A python-like bytes_io implementation for dart A powerful helper for processing raw binary data Usage A simple usage example: import 'package

Kelly 5 Aug 31, 2022
A bugless implementation of BigDecimal in Dart based on Java's BigDecimal

big_decimal A bugless implementation of BigDecimal in Dart based on Java's BigDecimal Installation Add the following to your pubspec.yaml: dependencie

null 18 Jul 27, 2022
Libwinmedia implementation of just_audio.

just_audio_libwinmedia The libwinmedia implementation of [just_audio][https://github.com/ryanheise/just_audio]. Installation Add the just_audio_libwin

Bruno D'Luka 12 Oct 22, 2022
Implementation of FIrebase CRUD App.

firebase_crud_app_flutter A new Flutter application. Getting Started This project is a starting point for a Flutter application. A few resources to ge

Chinmay Munje 0 Nov 4, 2021
Music reader for online data (Google Drive implementation). Cross platform goal : iOS, Android, MacOS, Windows

omusic A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this i

JeanNicolasdeLamballerie 0 Nov 30, 2021
Actor model implementation in Dart. This package makes it easier to work with isolates, create clusters of isolates.

Actor model implementation in Dart Languages: Introduction About Theater Installing What is Actor Notes about the actors Actor system Actor tree Using

Gleb Batykov 39 Nov 14, 2022
A basic implementation of the robot testing pattern for integration/e2e tests

robot A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this is

Samuel Abada 3 Dec 13, 2021
This project is a implementation of a collection of terminal server samples in Dart

Terminal Server Samples ⭐ Star me on GitHub — it helps! This project is a implementation of a collection of terminal server samples in Dart licensed u

Javier Montenegro 0 Nov 26, 2021
Implementation and architecture for Firebase Authentication

fluttercompoundapp A new Flutter application. Getting Started This project is a starting point for a Flutter application. A few resources to get you s

Emmanuel Ahuno 0 Nov 27, 2021
Actively maintained, community-driven chat UI implementation with an optional Firebase BaaS.

Flutter Chat UI Actively maintained, community-driven chat UI implementation with an optional Firebase BaaS. Flyer Chat is a platform for creating in-

Flyer Chat 662 Jan 7, 2023
Lightweight SMS Misr gateway implementation in dart (unofficial).

palestine_sms_misr (unofficial) Part of PalestineDevelopers Lightweight SMS Misr gateway implementation in dart (unofficial). Table Of Contents Featur

Palestine Developers 3 Mar 10, 2022
Dart grocery store / cashier line simulation implementation

Grocery Store Cashier Line Simulation Quick Read Dart implementation of a grocery store cashier line simulation. $ dart bin/grocerysimulator.dart inpu

Danilo 0 Jan 13, 2022
Flutter Music Player - First Open Source Flutter based material design music player with audio plugin to play local music files.

Flutter Music Player First Open Source Flutter based Beautiful Material Design Music Player(Online Radio will be added soon.) Demo App Play Store BETA

Pawan Kumar 1.5k Jan 8, 2023
a project for learning all Flutter Widgets , sync from flutter.dev the officia website.

Flutter Widgets Catalog (WIP) 计划 1、使用Flutter开发一个全平台的Flutter Widgets Catalog APP,并且开源。在这个APP中可以通过图形化的方式查看所有Widgets的介绍,示例,视频教程。 2、所有文档内容由前一天从flutter.dev

ezshine 32 Aug 3, 2022