Browse Source

Merge pull request #507 from provokateurin/refactor/encode-bitmaps-using-image

refactor(neon): Use image instead of bitmap library to encode bitmaps
pull/523/head
Kate 1 year ago committed by GitHub
parent
commit
2e5bc1252f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      packages/app/pubspec.lock
  2. 5
      packages/neon/neon/lib/src/utils/push_utils.dart
  3. 2
      packages/neon/neon/pubspec.yaml

8
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:

5
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';
@ -133,8 +133,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) {

2
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

Loading…
Cancel
Save