From 3d9b4b5c28be0729acd32cd403ede03fc33560f6 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Sat, 29 Jul 2023 22:30:12 +0200 Subject: [PATCH] refactor(neon): Use image instead of bitmap library to encode bitmaps --- packages/app/pubspec.lock | 8 -------- packages/neon/neon/lib/src/utils/push_utils.dart | 5 ++--- packages/neon/neon/pubspec.yaml | 2 +- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/packages/app/pubspec.lock b/packages/app/pubspec.lock index 4dc1921b..4e473c3c 100644 --- a/packages/app/pubspec.lock +++ b/packages/app/pubspec.lock @@ -41,14 +41,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.11.0" - bitmap: - dependency: transitive - description: - name: bitmap - sha256: d4ec0147d64eff00efbbeead5c04d517ea4fbb528022adaa3551e3586e80f4d4 - url: "https://pub.dev" - source: hosted - version: "0.1.3" boolean_selector: dependency: transitive description: diff --git a/packages/neon/neon/lib/src/utils/push_utils.dart b/packages/neon/neon/lib/src/utils/push_utils.dart index f96016e1..47d8960f 100644 --- a/packages/neon/neon/lib/src/utils/push_utils.dart +++ b/packages/neon/neon/lib/src/utils/push_utils.dart @@ -1,13 +1,13 @@ import 'dart:convert'; import 'dart:ui'; -import 'package:bitmap/bitmap.dart'; import 'package:crypto/crypto.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_cache_manager/flutter_cache_manager.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:flutter_svg/flutter_svg.dart' show SvgFileLoader, vg; +import 'package:image/image.dart' as img; import 'package:meta/meta.dart'; import 'package:neon/src/blocs/accounts.dart'; import 'package:neon/src/models/account.dart'; @@ -132,8 +132,7 @@ class PushUtils { final image = recorder.endRecording().toImageSync(scaledSize.width.toInt(), scaledSize.height.toInt()); final bytes = await image.toByteData(format: ImageByteFormat.png); - final bitmap = await Bitmap.fromProvider(MemoryImage(bytes!.buffer.asUint8List())); - largeIconBitmap = ByteArrayAndroidBitmap(bitmap.buildHeaded()); + largeIconBitmap = ByteArrayAndroidBitmap(img.encodeBmp(img.decodePng(bytes!.buffer.asUint8List())!)); } } } catch (e, s) { diff --git a/packages/neon/neon/pubspec.yaml b/packages/neon/neon/pubspec.yaml index 990ef77e..4b25ffd4 100644 --- a/packages/neon/neon/pubspec.yaml +++ b/packages/neon/neon/pubspec.yaml @@ -7,7 +7,6 @@ environment: flutter: '>=3.10.4' dependencies: - bitmap: ^0.1.3 collection: ^1.17.1 crypto: ^3.0.3 file_picker: ^5.3.0 @@ -24,6 +23,7 @@ dependencies: flutter_zxing: ^1.1.2 # ^1.2.0 downgrades to image ^3.0.0 which breaks our dependencies. See https://github.com/khoren93/flutter_zxing/issues/94 go_router: ^9.0.3 http: ^0.13.6 + image: ^4.0.17 intersperse: ^2.0.0 intl: ^0.18.0 json_annotation: ^4.8.1