File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,9 @@ class _MyHomePageState extends State<MyHomePage> {
5353 });
5454 },
5555 onDetect: (p0) {},
56+ onDispose: () {
57+ debugPrint ("Barcode scanner disposed!" );
58+ },
5659 controller: MobileScannerController (
5760 detectionSpeed: DetectionSpeed .noDuplicates,
5861 ),
Original file line number Diff line number Diff line change @@ -127,6 +127,9 @@ class AiBarcodeScanner extends StatefulWidget {
127127 /// The function that signals when the barcode scanner is started.
128128 final void Function (MobileScannerArguments ? )? onScannerStarted;
129129
130+ /// Called when this object is removed from the tree permanently.
131+ final void Function ()? onDispose;
132+
130133 /// if set barcodes will only be scanned if they fall within this [Rect]
131134 /// useful for having a cut-out overlay for example. these [Rect]
132135 /// coordinates are relative to the widget size, so by how much your
@@ -173,6 +176,7 @@ class AiBarcodeScanner extends StatefulWidget {
173176 this .errorBuilder,
174177 this .placeholderBuilder,
175178 this .onScannerStarted,
179+ this .onDispose,
176180 this .scanWindow,
177181 this .startDelay,
178182 this .hintWidget,
@@ -203,6 +207,10 @@ class _AiBarcodeScannerState extends State<AiBarcodeScanner> {
203207 void dispose () {
204208 controller.dispose ();
205209 super .dispose ();
210+
211+ if (widget.onDispose != null ) {
212+ widget.onDispose !();
213+ }
206214 }
207215
208216 @override
You can’t perform that action at this time.
0 commit comments