Skip to content

Commit

Permalink
🚑 Fix example
Browse files Browse the repository at this point in the history
  • Loading branch information
Raincal committed Aug 14, 2021
1 parent df6c846 commit 40a0fa9
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 24 deletions.
2 changes: 1 addition & 1 deletion blurhash/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void blurHashEncode() async {
}
void blurHashDecode() async {
Uint8List imageDataBytes;
Uint8List? imageDataBytes;
try {
imageDataBytes = await BlurHash.decode(blurhash, 20, 12);
} on PlatformException catch (e) {
Expand Down
16 changes: 8 additions & 8 deletions blurhash/example/lib/blurhash_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@ import 'package:transparent_image/transparent_image.dart';

class BlurHashImage extends StatefulWidget {
BlurHashImage(
{Key key,
@required this.blurHash,
@required this.image,
{Key? key,
required this.blurHash,
required this.image,
this.width,
this.height,
this.fit = BoxFit.cover})
: super(key: key);

final String blurHash;
final String image;
final double width;
final double height;
final double? width;
final double? height;
final BoxFit fit;

_BlurHashImageState createState() => _BlurHashImageState();
}

class _BlurHashImageState extends State<BlurHashImage> {
Uint8List _imageDataBytes;
Uint8List? _imageDataBytes;

@override
void initState() {
Expand All @@ -34,7 +34,7 @@ class _BlurHashImageState extends State<BlurHashImage> {
}

Future blurHashDecode() async {
Uint8List imageDataBytes;
Uint8List? imageDataBytes;

try {
imageDataBytes = await BlurHash.decode(widget.blurHash, 32, 32);
Expand All @@ -56,7 +56,7 @@ class _BlurHashImageState extends State<BlurHashImage> {
FractionallySizedBox(
widthFactor: 1,
child: Image.memory(
_imageDataBytes,
_imageDataBytes!,
width: widget.width,
height: widget.height,
fit: widget.fit,
Expand Down
6 changes: 3 additions & 3 deletions blurhash/example/lib/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class HomePage extends StatefulWidget {
}

class HomePageState extends State<HomePage> {
Uint8List _imageDataBytes;
Uint8List? _imageDataBytes;
TextEditingController _blurHashController =
TextEditingController(text: "LEHV6nWB2yk8pyo0adR*.7kCMdnj");

Expand All @@ -27,7 +27,7 @@ class HomePageState extends State<HomePage> {
}

void blurHashDecode() async {
Uint8List imageDataBytes;
Uint8List? imageDataBytes;
try {
imageDataBytes = await BlurHash.decode(_blurHashController.text, 20, 12,
useCache: false);
Expand Down Expand Up @@ -112,7 +112,7 @@ class HomePageState extends State<HomePage> {
: FractionallySizedBox(
widthFactor: 1,
child: Image.memory(
_imageDataBytes,
_imageDataBytes!,
fit: BoxFit.cover,
),
),
Expand Down
4 changes: 2 additions & 2 deletions blurhash/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1

environment:
sdk: ">=2.7.0 <3.0.0"
sdk: ">=2.12.0 <3.0.0"

dependencies:
flutter:
Expand All @@ -27,7 +27,7 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.1
transparent_image: ^1.0.0
transparent_image: ^2.0.0

dev_dependencies:
flutter_test:
Expand Down
21 changes: 12 additions & 9 deletions blurhash/example/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,20 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:blurhash_example/main.dart';

void main() {
testWidgets('Verify Platform version', (WidgetTester tester) async {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());

// Verify that platform version is retrieved.
expect(
find.byWidgetPredicate(
(Widget widget) => widget is Text &&
widget.data.startsWith('Running on:'),
),
findsOneWidget,
);
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);

// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();

// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
2 changes: 1 addition & 1 deletion blurhash/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 1.0.0
homepage: https://github.com/Raincal/blurhash/tree/master/blurhash

environment:
sdk: ">=2.12.0-0 <3.0.0"
sdk: ">=2.12.0 <3.0.0"
flutter: ">=1.24.0"

dependencies:
Expand Down

0 comments on commit 40a0fa9

Please sign in to comment.