|
|
@ -8,12 +8,24 @@ import '../../flutter_zxing.dart'; |
|
|
|
class WriterWidget extends StatefulWidget { |
|
|
|
class WriterWidget extends StatefulWidget { |
|
|
|
const WriterWidget({ |
|
|
|
const WriterWidget({ |
|
|
|
super.key, |
|
|
|
super.key, |
|
|
|
|
|
|
|
this.text = '', |
|
|
|
|
|
|
|
this.format = Format.QRCode, |
|
|
|
|
|
|
|
this.width = 120, |
|
|
|
|
|
|
|
this.height = 120, |
|
|
|
|
|
|
|
this.margin = 0, |
|
|
|
|
|
|
|
this.eccLevel = 0, |
|
|
|
this.onSuccess, |
|
|
|
this.onSuccess, |
|
|
|
this.onError, |
|
|
|
this.onError, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
final Function(EncodeResult, Uint8List?)? onSuccess; |
|
|
|
final String text; |
|
|
|
final Function(String)? onError; |
|
|
|
final int format; |
|
|
|
|
|
|
|
final int width; |
|
|
|
|
|
|
|
final int height; |
|
|
|
|
|
|
|
final int margin; |
|
|
|
|
|
|
|
final int eccLevel; |
|
|
|
|
|
|
|
final Function(EncodeResult result, Uint8List? bytes)? onSuccess; |
|
|
|
|
|
|
|
final Function(String error)? onError; |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
State<WriterWidget> createState() => _WriterWidgetState(); |
|
|
|
State<WriterWidget> createState() => _WriterWidgetState(); |
|
|
@ -23,13 +35,10 @@ class _WriterWidgetState extends State<WriterWidget> |
|
|
|
with TickerProviderStateMixin { |
|
|
|
with TickerProviderStateMixin { |
|
|
|
final GlobalKey<FormState> _formKey = GlobalKey<FormState>(); |
|
|
|
final GlobalKey<FormState> _formKey = GlobalKey<FormState>(); |
|
|
|
final TextEditingController _textController = TextEditingController(); |
|
|
|
final TextEditingController _textController = TextEditingController(); |
|
|
|
final TextEditingController _widthController = |
|
|
|
final TextEditingController _widthController = TextEditingController(); |
|
|
|
TextEditingController(text: '300'); |
|
|
|
final TextEditingController _heightController = TextEditingController(); |
|
|
|
final TextEditingController _heightController = |
|
|
|
final TextEditingController _marginController = TextEditingController(); |
|
|
|
TextEditingController(text: '300'); |
|
|
|
final TextEditingController _eccController = TextEditingController(); |
|
|
|
final TextEditingController _marginController = |
|
|
|
|
|
|
|
TextEditingController(text: '10'); |
|
|
|
|
|
|
|
final TextEditingController _eccController = TextEditingController(text: '0'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool isAndroid() => Theme.of(context).platform == TargetPlatform.android; |
|
|
|
bool isAndroid() => Theme.of(context).platform == TargetPlatform.android; |
|
|
|
|
|
|
|
|
|
|
@ -37,6 +46,27 @@ class _WriterWidgetState extends State<WriterWidget> |
|
|
|
final List<int> _supportedFormats = CodeFormat.writerFormats; |
|
|
|
final List<int> _supportedFormats = CodeFormat.writerFormats; |
|
|
|
int _codeFormat = Format.QRCode; |
|
|
|
int _codeFormat = Format.QRCode; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
|
|
|
void initState() { |
|
|
|
|
|
|
|
_textController.text = widget.text; |
|
|
|
|
|
|
|
_widthController.text = widget.width.toString(); |
|
|
|
|
|
|
|
_heightController.text = widget.height.toString(); |
|
|
|
|
|
|
|
_marginController.text = widget.margin.toString(); |
|
|
|
|
|
|
|
_eccController.text = widget.eccLevel.toString(); |
|
|
|
|
|
|
|
_codeFormat = widget.format; |
|
|
|
|
|
|
|
super.initState(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
|
|
|
void dispose() { |
|
|
|
|
|
|
|
_textController.dispose(); |
|
|
|
|
|
|
|
_widthController.dispose(); |
|
|
|
|
|
|
|
_heightController.dispose(); |
|
|
|
|
|
|
|
_marginController.dispose(); |
|
|
|
|
|
|
|
_eccController.dispose(); |
|
|
|
|
|
|
|
super.dispose(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
Widget build(BuildContext context) { |
|
|
|
Widget build(BuildContext context) { |
|
|
|
return SingleChildScrollView( |
|
|
|
return SingleChildScrollView( |
|
|
|