Skip to content

Commit

Permalink
Fix nullable image #29
Browse files Browse the repository at this point in the history
  • Loading branch information
vintage committed Mar 31, 2021
1 parent 483f6f6 commit 7e3592d
Show file tree
Hide file tree
Showing 5 changed files with 11 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 @@
## 2.0.1

* Fix nullable image

## 2.0.0

* Migrate package to null safety
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Scratch card widget which temporarily hides content from user.

[![Version](https://img.shields.io/badge/pub-v2.0.0-blue.svg)](https://pub.dartlang.org/packages/scratcher)
[![Version](https://img.shields.io/badge/pub-v2.0.1-blue.svg)](https://pub.dartlang.org/packages/scratcher)

![Demo](https://media.giphy.com/media/fXztsRTXoKsVuChtTl/giphy.gif)

Expand All @@ -18,7 +18,7 @@ Scratch card widget which temporarily hides content from user.
1. First thing you need to do is adding the scratcher as a project dependency in `pubspec.yaml`:
```yaml
dependencies:
scratcher: "^2.0.0"
scratcher: "^2.0.1"
```
2. Now you can install it by running `flutter pub get` or through code editor.
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.0.0"
version: "2.0.1"
sky_engine:
dependency: transitive
description: flutter
Expand Down
8 changes: 3 additions & 5 deletions lib/widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ double _getAccuracyValue(ScratchAccuracy accuracy) {
case ScratchAccuracy.high:
return 100.0;
}

return 0;
}

/// Scratcher widget which covers given child with scratchable overlay.
Expand Down Expand Up @@ -95,7 +93,7 @@ class Scratcher extends StatefulWidget {
}

class ScratcherState extends State<Scratcher> {
late Future<ui.Image> _imageLoader;
late Future<ui.Image?> _imageLoader;
Offset? _lastPosition;

List<ScratchPoint?> points = [];
Expand Down Expand Up @@ -127,9 +125,9 @@ class ScratcherState extends State<Scratcher> {

@override
Widget build(BuildContext context) {
return FutureBuilder<ui.Image>(
return FutureBuilder<ui.Image?>(
future: _imageLoader,
builder: (BuildContext context, AsyncSnapshot<ui.Image> snapshot) {
builder: (BuildContext context, AsyncSnapshot<ui.Image?> snapshot) {
if (snapshot.connectionState != ConnectionState.waiting) {
final paint = CustomPaint(
foregroundPainter: ScratchPainter(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: scratcher
description: Scratch card widget which temporarily hides content from user.
homepage: https://github.com/vintage/scratcher

version: 2.0.0
version: 2.0.1

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down

0 comments on commit 7e3592d

Please sign in to comment.