Skip to content

Commit

Permalink
Fixed a bug where border would cause weird shadows
Browse files Browse the repository at this point in the history
  • Loading branch information
arashAndroid committed Feb 6, 2024
1 parent a6dde7c commit d3bf39c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.1

Fixed: Fixed a bug where border would cause weird shadows

## 0.1.0

**BREAKING CHANGES**
Expand Down
14 changes: 10 additions & 4 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,24 @@ class MainApp extends StatelessWidget {
textDirection: TextDirection.rtl,
),
),
// padding: EdgeInsets.all(0),
// elevation: 5,
// backgroundColor: Theme.of(context).colorScheme.surface,
// borderColor: Theme.of(context).colorScheme.onSurface,
// borderThickness: 4,
PaperCard(
height: 200,
width: 150,
textureAssetPath: 'assets/crayon_mask.png',
borderThickness: 0,
// textureAssetPath: 'assets/crayon_mask.png',
borderThickness: 10,
elevation: 5,
child: Text(
'تست فارسی 3: سلام دنیا',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17),
textDirection: TextDirection.rtl,
),
backgroundColor: Color.fromARGB(201, 255, 205, 25),
textureOpacity: 0.1,
backgroundColor: Color.fromARGB(255, 255, 205, 25),
// textureOpacity: 0.1,
),
PaperCard(
height: 100,
Expand Down
6 changes: 2 additions & 4 deletions lib/src/widgets/PaperCard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import 'package:flutter/material.dart';

import 'package:widget_mask/widget_mask.dart';

import 'package:flutter/foundation.dart' show kIsWeb;

class PaperCard extends StatelessWidget {
/// child to your widget.
final Widget? child;
Expand Down Expand Up @@ -411,13 +409,13 @@ class PaintCard extends CustomPainter {

final paint = Paint()
..color = backgroundColor
..blendMode = BlendMode.srcOut
..blendMode = BlendMode.src
..style = PaintingStyle.fill;
final borderPaint = Paint()..color = borderColor;

if (elevation > 0) canvas.drawPath(shadowPath, shadowPaint);
canvas.saveLayer(Rect.fromLTWH(0, 0, size.width, size.height), borderPaint);
if (borderThickness > 0) canvas.drawPath((kIsWeb && backgroundColor.opacity < 1) ? pathBorder : pathBorder, borderPaint);
if (borderThickness > 0) canvas.drawPath(pathBorder, borderPaint);
canvas.drawPath(pathFill, paint);
canvas.restore();
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: paper_card
description: A paper card for Flutter. It is a card that looks like a cartoonish paper. It is customizable and you can add your texture on it.
version: 0.1.0
version: 0.1.1
homepage: https://github.com/arashAndroid/paper_card.git

environment:
Expand Down

0 comments on commit d3bf39c

Please sign in to comment.