Skip to main content

shape_of_view_null_safe 3.1.2 copy "shape_of_view_null_safe: ^3.1.2" to clipboard
shape_of_view_null_safe: ^3.1.2 copied to clipboard

Give any Flutter widget a custom shape. Circle, rounded rect, cut corners, arc, diagonal, triangle, bubble, star, polygon, or your own path.

shape_of_view_null_safe #

Give any Flutter widget a custom shape: circle, rounded rect, cut corners, arc, diagonal, triangle, bubble, star, polygon, or your own path.

Note #

This package is a fork of

https://pub.dev/packages/shape_of_view

with added null safety.

I reserve no rights to any of the content. Hopefully you don't sue me or anything :D I'm just trynna make this package null safe :)

How to use #

Add the package:

flutter pub add shape_of_view_null_safe

Import it in your Dart file:

import 'package:shape_of_view_null_safe/shape_of_view_null_safe.dart';

screen screen screen

ShapeOfView(
  shape: YOUR_SHAPE,
  elevation: 4,
  height: 300, //height & width are optional
  child: ...
),

Use implemented shapes #

ShapeOfView came with pre-created shapes :

Circle #

screen

ShapeOfView(
  shape: CircleShape(
    borderColor: Colors.white, //optional
    borderWidth: 2, //optional
  ),
  child: ...

RoundRect #

screen

ShapeOfView(
  shape: RoundRectShape(
     borderRadius: BorderRadius.circular(12),
     borderColor: Colors.white, //optional
     borderWidth: 2, //optional
  ),
  child: ...

ClipCorner #

screen

ShapeOfView(
  shape: CutCornerShape(
     borderRadius: BorderRadius.circular(12),
  ),
  child: ...

Arc #

screen

ShapeOfView(
  shape: ArcShape(
    direction: ArcDirection.Outside,
    height: 20,
    position: ArcPosition.Bottom
  ),
  child: ...
)

Diagonal #

screen

ShapeOfView(
  elevation: 4,
  height: 300,
  shape: DiagonalShape(
    position: DiagonalPosition.Bottom,
    direction: DiagonalDirection.Right,
    angle: DiagonalAngle.deg(angle: 10)
  ),
  child: ...
)

Triangle #

screen

ShapeOfView(
  shape: TriangleShape(
    percentBottom: 0.5,
    percentLeft: 0,
    percentRight: 0
  ),
  child: ...,
)

Bubble #

screen

ShapeOfView(
  shape: BubbleShape(
    position: BubblePosition.Bottom,
    arrowPositionPercent: 0.5,
    borderRadius: 20,
    arrowHeight: 10,
    arrowWidth: 10
  ),
  child: ...,
)

Star #

screen screen

ShapeOfView(
  shape: StarShape(
    noOfPoints: 5
  ),
  child: ...,
)

Polygon #

screen

ShapeOfView(
  shape: PolygonShape(
    numberOfSides: 9
  ),
  child: ...,
)

Use a custom Shape #

ShapeOfView(
  shape: CustomShape(
    builder: (rect) => Path()
      ..moveTo(rect!.width / 2, 0)
      ..lineTo(rect.width, rect.height)
      ..lineTo(0, rect.height)
      ..close(),
  ),
  child: ...,
)

or extend Shape

class MyShape extends Shape {
  @override
  Path build({Rect? rect, double? scale}) {
    final size = rect!.size;
    return Path()
      ..moveTo(size.width / 2, 0)
      ..lineTo(size.width, size.height)
      ..lineTo(0, size.height)
      ..close();
  }
}

then

ShapeOfView(
  shape: MyShape(),
  child: ...,
)

License #

Copyright 2019 florent37, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
89
likes
150
points
2.42k
downloads

Documentation

API reference

Publisher

verified publishercodingfries.com

Weekly Downloads

Give any Flutter widget a custom shape. Circle, rounded rect, cut corners, arc, diagonal, triangle, bubble, star, polygon, or your own path.

Repository (GitHub)
View/report issues

Topics

#shape #clip #widget #ui #path

License

Apache-2.0 (license)

Dependencies

flutter, vector_math

More

Packages that depend on shape_of_view_null_safe