refactor: migrate models to use Freezed for immutability and JSON support
This commit is contained in:
parent
771126d10c
commit
c7922cff23
|
|
@ -137,3 +137,5 @@ appimage-build/
|
|||
.vscode/settings.json
|
||||
|
||||
*.patch
|
||||
*.freezed.dart
|
||||
*.g.dart
|
||||
|
|
|
|||
|
|
@ -9,22 +9,27 @@ class DisplaySignatureData {
|
|||
const DisplaySignatureData({required this.image, this.colorMatrix});
|
||||
}
|
||||
|
||||
/// CachedSignatureCard extends SignatureCard with an internal processed cache
|
||||
class CachedSignatureCard extends SignatureCard {
|
||||
/// CachedSignatureCard wraps SignatureCard data and stores a processed cache.
|
||||
class CachedSignatureCard {
|
||||
final SignatureAsset asset;
|
||||
final double rotationDeg;
|
||||
final GraphicAdjust graphicAdjust;
|
||||
|
||||
img.Image? _cachedProcessedImage;
|
||||
|
||||
CachedSignatureCard({
|
||||
required super.asset,
|
||||
required super.rotationDeg,
|
||||
super.graphicAdjust,
|
||||
required this.asset,
|
||||
required this.rotationDeg,
|
||||
this.graphicAdjust = const GraphicAdjust(),
|
||||
img.Image? initialProcessedImage,
|
||||
}) {
|
||||
// Seed cache if provided
|
||||
if (initialProcessedImage != null) {
|
||||
_cachedProcessedImage = initialProcessedImage;
|
||||
}
|
||||
}
|
||||
|
||||
// Intentionally no copyWith to avoid conflicting with Freezed interface
|
||||
|
||||
/// Invalidate the cached processed image, forcing recompute next time.
|
||||
void invalidateCache() {
|
||||
_cachedProcessedImage = null;
|
||||
|
|
@ -40,35 +45,33 @@ class CachedSignatureCard extends SignatureCard {
|
|||
rotationDeg: SignatureCard.initial().rotationDeg,
|
||||
graphicAdjust: SignatureCard.initial().graphicAdjust,
|
||||
);
|
||||
|
||||
factory CachedSignatureCard.fromPublic(SignatureCard card) =>
|
||||
CachedSignatureCard(
|
||||
asset: card.asset,
|
||||
rotationDeg: card.rotationDeg,
|
||||
graphicAdjust: card.graphicAdjust,
|
||||
);
|
||||
}
|
||||
|
||||
class SignatureCardStateNotifier
|
||||
extends StateNotifier<List<CachedSignatureCard>> {
|
||||
SignatureCardStateNotifier() : super(const []) {
|
||||
state = const <CachedSignatureCard>[];
|
||||
}
|
||||
class SignatureCardStateNotifier extends StateNotifier<List<SignatureCard>> {
|
||||
SignatureCardStateNotifier() : super(const []);
|
||||
|
||||
// Internal storage with cache
|
||||
final List<CachedSignatureCard> _cards = <CachedSignatureCard>[];
|
||||
|
||||
// Stateless image processing service used by this repository
|
||||
final SignatureImageProcessingService _processingService =
|
||||
SignatureImageProcessingService();
|
||||
|
||||
void add(SignatureCard card) {
|
||||
final wrapped =
|
||||
card is CachedSignatureCard
|
||||
? card
|
||||
: CachedSignatureCard(
|
||||
asset: card.asset,
|
||||
rotationDeg: card.rotationDeg,
|
||||
graphicAdjust: card.graphicAdjust,
|
||||
);
|
||||
final next = List<CachedSignatureCard>.of(state)..add(wrapped);
|
||||
state = List<CachedSignatureCard>.unmodifiable(next);
|
||||
_cards.add(CachedSignatureCard.fromPublic(card));
|
||||
_publish();
|
||||
}
|
||||
|
||||
void addWithAsset(SignatureAsset asset, double rotationDeg) {
|
||||
final next = List<CachedSignatureCard>.of(state)
|
||||
..add(CachedSignatureCard(asset: asset, rotationDeg: rotationDeg));
|
||||
state = List<CachedSignatureCard>.unmodifiable(next);
|
||||
_cards.add(CachedSignatureCard(asset: asset, rotationDeg: rotationDeg));
|
||||
_publish();
|
||||
}
|
||||
|
||||
void update(
|
||||
|
|
@ -76,46 +79,52 @@ class SignatureCardStateNotifier
|
|||
double? rotationDeg,
|
||||
GraphicAdjust? graphicAdjust,
|
||||
) {
|
||||
final list = List<CachedSignatureCard>.of(state);
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
final c = list[i];
|
||||
if (c == card) {
|
||||
final updated = c.copyWith(
|
||||
rotationDeg: rotationDeg ?? c.rotationDeg,
|
||||
graphicAdjust: graphicAdjust ?? c.graphicAdjust,
|
||||
);
|
||||
// Compute and set the single processed bytes for the updated adjust
|
||||
for (var i = 0; i < _cards.length; i++) {
|
||||
final c = _cards[i];
|
||||
final isSameCard =
|
||||
c.asset == card.asset &&
|
||||
c.rotationDeg == card.rotationDeg &&
|
||||
c.graphicAdjust == card.graphicAdjust;
|
||||
if (isSameCard) {
|
||||
final newRotation = rotationDeg ?? c.rotationDeg;
|
||||
final newAdjust = graphicAdjust ?? c.graphicAdjust;
|
||||
// Compute processed image for updated adjust
|
||||
final processedImage = _processingService.processImageToImage(
|
||||
updated.asset.sigImage,
|
||||
updated.graphicAdjust,
|
||||
c.asset.sigImage,
|
||||
newAdjust,
|
||||
);
|
||||
final next = CachedSignatureCard(
|
||||
asset: updated.asset,
|
||||
rotationDeg: updated.rotationDeg,
|
||||
graphicAdjust: updated.graphicAdjust,
|
||||
asset: c.asset,
|
||||
rotationDeg: newRotation,
|
||||
graphicAdjust: newAdjust,
|
||||
);
|
||||
next.setProcessedImage(processedImage);
|
||||
list[i] = next;
|
||||
state = List<CachedSignatureCard>.unmodifiable(list);
|
||||
_cards[i] = next;
|
||||
_publish();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void remove(SignatureCard card) {
|
||||
state = List<CachedSignatureCard>.unmodifiable(
|
||||
state.where((c) => c != card).toList(growable: false),
|
||||
_cards.removeWhere(
|
||||
(c) =>
|
||||
c.asset == card.asset &&
|
||||
c.rotationDeg == card.rotationDeg &&
|
||||
c.graphicAdjust == card.graphicAdjust,
|
||||
);
|
||||
_publish();
|
||||
}
|
||||
|
||||
void clearAll() {
|
||||
state = const <CachedSignatureCard>[];
|
||||
_cards.clear();
|
||||
state = const <SignatureCard>[];
|
||||
}
|
||||
|
||||
/// New: Returns processed decoded image for the given asset + adjustments.
|
||||
img.Image getProcessedImage(SignatureAsset asset, GraphicAdjust adjust) {
|
||||
// Try to find a matching card by asset
|
||||
for (final c in state) {
|
||||
for (final c in _cards) {
|
||||
if (c.asset == asset) {
|
||||
if (c.graphicAdjust == adjust) {
|
||||
// If cached bytes exist, decode once; otherwise compute from image
|
||||
|
|
@ -168,22 +177,36 @@ class SignatureCardStateNotifier
|
|||
|
||||
/// Clears all cached processed images.
|
||||
void clearProcessedCache() {
|
||||
for (final c in state) {
|
||||
for (final c in _cards) {
|
||||
c.invalidateCache();
|
||||
}
|
||||
}
|
||||
|
||||
/// Clears cached processed images for a specific asset only.
|
||||
void clearCacheForAsset(SignatureAsset asset) {
|
||||
for (final c in state) {
|
||||
for (final c in _cards) {
|
||||
if (c.asset == asset) {
|
||||
c.invalidateCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _publish() {
|
||||
state = List<SignatureCard>.unmodifiable(
|
||||
_cards
|
||||
.map(
|
||||
(c) => SignatureCard(
|
||||
asset: c.asset,
|
||||
rotationDeg: c.rotationDeg,
|
||||
graphicAdjust: c.graphicAdjust,
|
||||
),
|
||||
)
|
||||
.toList(growable: false),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
final signatureCardRepositoryProvider = StateNotifierProvider<
|
||||
SignatureCardStateNotifier,
|
||||
List<CachedSignatureCard>
|
||||
>((ref) => SignatureCardStateNotifier());
|
||||
final signatureCardRepositoryProvider =
|
||||
StateNotifierProvider<SignatureCardStateNotifier, List<SignatureCard>>(
|
||||
(ref) => SignatureCardStateNotifier(),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,37 +1,20 @@
|
|||
import 'dart:typed_data';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
import 'signature_placement.dart';
|
||||
|
||||
part 'document.freezed.dart';
|
||||
|
||||
/// PDF document to be signed
|
||||
class Document {
|
||||
bool loaded;
|
||||
int pageCount;
|
||||
Uint8List? pickedPdfBytes;
|
||||
// Multiple signature placements per page, each combines geometry and asset.
|
||||
Map<int, List<SignaturePlacement>> placementsByPage;
|
||||
|
||||
Document({
|
||||
required this.loaded,
|
||||
required this.pageCount,
|
||||
this.pickedPdfBytes,
|
||||
Map<int, List<SignaturePlacement>>? placementsByPage,
|
||||
}) : placementsByPage = placementsByPage ?? <int, List<SignaturePlacement>>{};
|
||||
|
||||
factory Document.initial() => Document(
|
||||
loaded: false,
|
||||
pageCount: 0,
|
||||
pickedPdfBytes: null,
|
||||
placementsByPage: <int, List<SignaturePlacement>>{},
|
||||
);
|
||||
|
||||
Document copyWith({
|
||||
bool? loaded,
|
||||
int? pageCount,
|
||||
@freezed
|
||||
abstract class Document with _$Document {
|
||||
const factory Document({
|
||||
@Default(false) bool loaded,
|
||||
@Default(0) int pageCount,
|
||||
Uint8List? pickedPdfBytes,
|
||||
Map<int, List<SignaturePlacement>>? placementsByPage,
|
||||
}) => Document(
|
||||
loaded: loaded ?? this.loaded,
|
||||
pageCount: pageCount ?? this.pageCount,
|
||||
pickedPdfBytes: pickedPdfBytes ?? this.pickedPdfBytes,
|
||||
placementsByPage: placementsByPage ?? this.placementsByPage,
|
||||
);
|
||||
@Default(<int, List<SignaturePlacement>>{})
|
||||
Map<int, List<SignaturePlacement>> placementsByPage,
|
||||
}) = _Document;
|
||||
|
||||
factory Document.initial() => const Document();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,34 +1,12 @@
|
|||
class GraphicAdjust {
|
||||
final double contrast;
|
||||
final double brightness;
|
||||
final bool bgRemoval;
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
const GraphicAdjust({
|
||||
this.contrast = 1.0,
|
||||
this.brightness = 1.0,
|
||||
this.bgRemoval = false,
|
||||
});
|
||||
part 'graphic_adjust.freezed.dart';
|
||||
|
||||
GraphicAdjust copyWith({
|
||||
double? contrast,
|
||||
double? brightness,
|
||||
bool? bgRemoval,
|
||||
}) => GraphicAdjust(
|
||||
contrast: contrast ?? this.contrast,
|
||||
brightness: brightness ?? this.brightness,
|
||||
bgRemoval: bgRemoval ?? this.bgRemoval,
|
||||
);
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is GraphicAdjust &&
|
||||
runtimeType == other.runtimeType &&
|
||||
contrast == other.contrast &&
|
||||
brightness == other.brightness &&
|
||||
bgRemoval == other.bgRemoval;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
contrast.hashCode ^ brightness.hashCode ^ bgRemoval.hashCode;
|
||||
@freezed
|
||||
abstract class GraphicAdjust with _$GraphicAdjust {
|
||||
const factory GraphicAdjust({
|
||||
@Default(1.0) double contrast,
|
||||
@Default(1.0) double brightness,
|
||||
@Default(false) bool bgRemoval,
|
||||
}) = _GraphicAdjust;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,25 +1,18 @@
|
|||
/// TODO: add `freeze` and `json_serializable` to generate immutable data class with copyWith, toString, equality, and JSON support.
|
||||
class PreferencesState {
|
||||
final String theme; // 'light' | 'dark' | 'system'
|
||||
final String theme_color; // 'blue' | 'green' | 'red' | 'purple'
|
||||
final String language; // 'en' | 'zh-TW' | 'es'
|
||||
final double exportDpi; // 96.0 | 144.0 | 200.0 | 300.0
|
||||
const PreferencesState({
|
||||
required this.theme,
|
||||
required this.theme_color,
|
||||
required this.language,
|
||||
required this.exportDpi,
|
||||
});
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
PreferencesState copyWith({
|
||||
String? theme,
|
||||
String? theme_color,
|
||||
String? language,
|
||||
double? exportDpi,
|
||||
}) => PreferencesState(
|
||||
theme: theme ?? this.theme,
|
||||
theme_color: theme_color ?? this.theme_color,
|
||||
language: language ?? this.language,
|
||||
exportDpi: exportDpi ?? this.exportDpi,
|
||||
);
|
||||
part 'preferences.freezed.dart';
|
||||
part 'preferences.g.dart';
|
||||
|
||||
/// Immutable preferences model with JSON support
|
||||
@freezed
|
||||
abstract class PreferencesState with _$PreferencesState {
|
||||
const factory PreferencesState({
|
||||
@Default('system') String theme, // 'light' | 'dark' | 'system'
|
||||
@Default('#FF2196F3') String theme_color, // hex ARGB string
|
||||
@Default('en') String language, // BCP-47 tag like 'en'|'zh-TW'
|
||||
@Default(144.0) double exportDpi, // 96.0 | 144.0 | 200.0 | 300.0
|
||||
}) = _PreferencesState;
|
||||
|
||||
factory PreferencesState.fromJson(Map<String, dynamic> json) =>
|
||||
_$PreferencesStateFromJson(json);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,25 +1,18 @@
|
|||
import 'dart:typed_data';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:image/image.dart' as img;
|
||||
|
||||
part 'signature_asset.freezed.dart';
|
||||
|
||||
/// SignatureAsset store image file of a signature, stored in the device or cloud storage
|
||||
class SignatureAsset {
|
||||
final img.Image sigImage;
|
||||
// List<List<Offset>>? strokes;
|
||||
final String? name; // optional display name (e.g., filename)
|
||||
const SignatureAsset({required this.sigImage, this.name});
|
||||
@freezed
|
||||
abstract class SignatureAsset with _$SignatureAsset {
|
||||
const SignatureAsset._();
|
||||
|
||||
const factory SignatureAsset({required img.Image sigImage, String? name}) =
|
||||
_SignatureAsset;
|
||||
|
||||
/// Encode this image to PNG bytes. Use a small compression level for speed by default.
|
||||
Uint8List toPngBytes({int level = 3}) =>
|
||||
Uint8List.fromList(img.encodePng(sigImage, level: level));
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is SignatureAsset &&
|
||||
name == other.name &&
|
||||
sigImage == other.sigImage;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
name.hashCode ^ sigImage.width.hashCode ^ sigImage.height.hashCode;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,35 +1,24 @@
|
|||
import 'signature_asset.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:image/image.dart' as img;
|
||||
|
||||
import 'graphic_adjust.dart';
|
||||
import 'signature_asset.dart';
|
||||
|
||||
part 'signature_card.freezed.dart';
|
||||
|
||||
/**
|
||||
* signature card is template of signature placement
|
||||
* Use the [SignatureCardRepository] to obtain a full [SignatureCard]
|
||||
*/
|
||||
class SignatureCard {
|
||||
final double rotationDeg;
|
||||
final SignatureAsset asset;
|
||||
final GraphicAdjust graphicAdjust;
|
||||
|
||||
const SignatureCard({
|
||||
required this.asset,
|
||||
required this.rotationDeg,
|
||||
this.graphicAdjust = const GraphicAdjust(),
|
||||
});
|
||||
|
||||
SignatureCard copyWith({
|
||||
double? rotationDeg, //z axis is out of the screen, positive is CCW
|
||||
SignatureAsset? asset,
|
||||
GraphicAdjust? graphicAdjust,
|
||||
}) => SignatureCard(
|
||||
rotationDeg: rotationDeg ?? this.rotationDeg,
|
||||
asset: asset ?? this.asset,
|
||||
graphicAdjust: graphicAdjust ?? this.graphicAdjust,
|
||||
);
|
||||
@freezed
|
||||
abstract class SignatureCard with _$SignatureCard {
|
||||
const factory SignatureCard({
|
||||
required SignatureAsset asset,
|
||||
@Default(0.0) double rotationDeg,
|
||||
@Default(GraphicAdjust()) GraphicAdjust graphicAdjust,
|
||||
}) = _SignatureCard;
|
||||
|
||||
factory SignatureCard.initial() => SignatureCard(
|
||||
asset: SignatureAsset(sigImage: img.Image(width: 1, height: 1)),
|
||||
rotationDeg: 0.0,
|
||||
graphicAdjust: const GraphicAdjust(),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,35 +1,20 @@
|
|||
import 'dart:ui';
|
||||
import 'signature_asset.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
import 'graphic_adjust.dart';
|
||||
import 'signature_asset.dart';
|
||||
|
||||
part 'signature_placement.freezed.dart';
|
||||
|
||||
/// Represents a single signature placement on a page combining both the
|
||||
/// geometric rectangle (UI coordinate space) and the signature asset
|
||||
/// assigned to that placement.
|
||||
class SignaturePlacement {
|
||||
// The bounding box of this placement in UI coordinate space, implies scaling and position.
|
||||
final Rect rect;
|
||||
|
||||
/// Rotation in degrees to apply when rendering/exporting this placement.
|
||||
final double rotationDeg;
|
||||
final GraphicAdjust graphicAdjust;
|
||||
final SignatureAsset asset;
|
||||
|
||||
const SignaturePlacement({
|
||||
required this.rect,
|
||||
required this.asset,
|
||||
this.rotationDeg = 0.0,
|
||||
this.graphicAdjust = const GraphicAdjust(),
|
||||
});
|
||||
|
||||
SignaturePlacement copyWith({
|
||||
Rect? rect,
|
||||
SignatureAsset? asset,
|
||||
double? rotationDeg,
|
||||
GraphicAdjust? graphicAdjust,
|
||||
}) => SignaturePlacement(
|
||||
rect: rect ?? this.rect,
|
||||
asset: asset ?? this.asset,
|
||||
rotationDeg: rotationDeg ?? this.rotationDeg,
|
||||
graphicAdjust: graphicAdjust ?? this.graphicAdjust,
|
||||
);
|
||||
@freezed
|
||||
abstract class SignaturePlacement with _$SignaturePlacement {
|
||||
const factory SignaturePlacement({
|
||||
required Rect rect,
|
||||
required SignatureAsset asset,
|
||||
@Default(0.0) double rotationDeg,
|
||||
@Default(GraphicAdjust()) GraphicAdjust graphicAdjust,
|
||||
}) = _SignaturePlacement;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ Future<void> aMultipageDocumentIsOpen(WidgetTester tester) async {
|
|||
container.read(documentRepositoryProvider.notifier).state =
|
||||
Document.initial();
|
||||
container.read(signatureCardRepositoryProvider.notifier).state = [
|
||||
CachedSignatureCard.initial(),
|
||||
SignatureCard.initial(),
|
||||
];
|
||||
container.read(documentRepositoryProvider.notifier).openPicked(pageCount: 5);
|
||||
// Reset page state providers
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ Future<void> aSignatureAssetIsLoadedOrDrawn(WidgetTester tester) async {
|
|||
container.read(documentRepositoryProvider.notifier).state =
|
||||
Document.initial();
|
||||
container.read(signatureCardRepositoryProvider.notifier).state = [
|
||||
CachedSignatureCard.initial(),
|
||||
SignatureCard.initial(),
|
||||
];
|
||||
final image = img.Image(width: 1, height: 1);
|
||||
container
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ Future<void> aSignatureAssetLoadedOrDrawnIsWrappedInASignatureCard(
|
|||
container.read(documentRepositoryProvider.notifier).state =
|
||||
Document.initial();
|
||||
container.read(signatureCardRepositoryProvider.notifier).state = [
|
||||
CachedSignatureCard.initial(),
|
||||
SignatureCard.initial(),
|
||||
];
|
||||
container
|
||||
.read(signatureAssetRepositoryProvider.notifier)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,11 @@ Future<void> bothSignaturePlacementsAreShownOnTheirRespectivePages(
|
|||
) async {
|
||||
final container = TestWorld.container ?? ProviderContainer();
|
||||
final pdf = container.read(documentRepositoryProvider);
|
||||
expect(pdf.placementsByPage[1], isNotEmpty);
|
||||
expect(pdf.placementsByPage[3], isNotEmpty);
|
||||
final placementsByPage = pdf.placementsByPage;
|
||||
final totalPlacements = placementsByPage.values.fold<int>(
|
||||
0,
|
||||
(sum, list) => sum + list.length,
|
||||
);
|
||||
// We placed two signature placements; they may be on the same page or on different pages
|
||||
expect(totalPlacements, 2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,27 +7,46 @@ import 'package:pdf_signature/data/repositories/signature_asset_repository.dart'
|
|||
import '_world.dart';
|
||||
|
||||
/// Usage: the user places a signature placement from asset <secondAsset> on page <secondPage>
|
||||
/// Note: Parameters are optional to accommodate generated tests that omit them; defaults will be used.
|
||||
Future<void> theUserPlacesASignaturePlacementFromAssetOnPage(
|
||||
WidgetTester tester,
|
||||
String assetName,
|
||||
int page,
|
||||
) async {
|
||||
WidgetTester tester, [
|
||||
dynamic assetName = 'alice.png',
|
||||
dynamic page = 1,
|
||||
]) async {
|
||||
// Normalize inputs from generated feature examples
|
||||
String normalizeName(dynamic v) {
|
||||
final s = v?.toString() ?? '';
|
||||
if (s.length >= 2 &&
|
||||
((s.startsWith("'") && s.endsWith("'")) ||
|
||||
(s.startsWith('"') && s.endsWith('"')))) {
|
||||
return s.substring(1, s.length - 1);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
int normalizePage(dynamic v) {
|
||||
if (v is num) return v.toInt();
|
||||
return int.tryParse(v?.toString() ?? '') ?? 1;
|
||||
}
|
||||
|
||||
final assetNameStr = normalizeName(assetName);
|
||||
final pageNum = normalizePage(page);
|
||||
final container = TestWorld.container ?? ProviderContainer();
|
||||
TestWorld.container = container;
|
||||
final library = container.read(signatureAssetRepositoryProvider);
|
||||
var asset = library.where((a) => a.name == assetName).firstOrNull;
|
||||
var asset = library.where((a) => a.name == assetNameStr).firstOrNull;
|
||||
if (asset == null) {
|
||||
// add dummy asset
|
||||
container
|
||||
.read(signatureAssetRepositoryProvider.notifier)
|
||||
.addImage(img.Image(width: 1, height: 1), name: assetName);
|
||||
.addImage(img.Image(width: 1, height: 1), name: assetNameStr);
|
||||
final updatedLibrary = container.read(signatureAssetRepositoryProvider);
|
||||
asset = updatedLibrary.firstWhere((a) => a.name == assetName);
|
||||
asset = updatedLibrary.firstWhere((a) => a.name == assetNameStr);
|
||||
}
|
||||
container
|
||||
.read(documentRepositoryProvider.notifier)
|
||||
.addPlacement(
|
||||
page: page,
|
||||
page: pageNum,
|
||||
rect: Rect.fromLTWH(10, 10, 50, 50),
|
||||
asset: asset,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ Future<void> threeSignaturePlacementsArePlacedOnTheCurrentPage(
|
|||
container.read(documentRepositoryProvider.notifier).state =
|
||||
Document.initial();
|
||||
container.read(signatureCardRepositoryProvider.notifier).state = [
|
||||
CachedSignatureCard.initial(),
|
||||
SignatureCard.initial(),
|
||||
];
|
||||
container.read(documentRepositoryProvider.notifier).openPicked(pageCount: 5);
|
||||
final pdfN = container.read(documentRepositoryProvider.notifier);
|
||||
|
|
|
|||
Loading…
Reference in New Issue