Hi all ๐, I want to integrate the "anyline SDK" (www.anyline.com) in my Flutterflow project as a "Custom Widget" so that I can scan barcodes with the camera. For some the app crashes on android every time I try to open the bottom sheet which should load the anyline SDK.
I have the following code:
// Automatic FlutterFlow imports
import '/backend/backend.dart';
import '/backend/schema/structs/index.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/widgets/index.dart'; // Imports other custom widgets
import '/custom_code/actions/index.dart'; // Imports custom actions
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom widget code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!
import 'package:anyline_plugin/anyline_plugin.dart';
class AnylineScanner extends StatefulWidget {
const AnylineScanner({
super.key,
this.width,
this.height,
this.keyAnyline,
this.config,
});
final double? width;
final double? height;
final String? keyAnyline;
final String? config;
@override
State<AnylineScanner> createState() => _AnylineScannerState();
}
class _AnylineScannerState extends State<AnylineScanner> {
late AnylinePlugin _anylinePlugin;
@override
void initState() {
super.initState();
_initializeSdk();
}
Future<void> _initializeSdk() async {
if (widget.keyAnyline == null) {
print("Error: License key is null.");
return;
}
_anylinePlugin = AnylinePlugin();
try {
await _anylinePlugin.initSdk(widget.keyAnyline!);
print("Anyline SDK initialized successfully.");
} catch (error) {
print("Error initializing Anyline SDK: $error");
}
}
@override
Widget build(BuildContext context) {
return Container(
width: widget.width ?? double.infinity,
height: widget.height ?? double.infinity,
// Add your scanner UI or functionality here
);
}
}
Maybe I'm doing something super obvious wrong in the code?
Here's more info about the Anyline plugin: https://documentation.anyline.com/flutter-plugin-component/latest/getting-started.html
I'm not sure if I can test whether it works on my desktop, because it uses the camera. On desktop (Test Session) it doesn't crash at least.
On my Android phone I don't know how to debug it best. Where can I find the print() statements for instance?
Haven't tested it on iOS yet.
Thanks for every help or suggestion. ๐