|
|
@ -14,6 +14,7 @@ class WriterWidget extends StatefulWidget { |
|
|
|
this.height = 120, |
|
|
|
this.height = 120, |
|
|
|
this.margin = 0, |
|
|
|
this.margin = 0, |
|
|
|
this.eccLevel = 0, |
|
|
|
this.eccLevel = 0, |
|
|
|
|
|
|
|
this.messages = const Messages(), |
|
|
|
this.onSuccess, |
|
|
|
this.onSuccess, |
|
|
|
this.onError, |
|
|
|
this.onError, |
|
|
|
}); |
|
|
|
}); |
|
|
@ -24,6 +25,7 @@ class WriterWidget extends StatefulWidget { |
|
|
|
final int height; |
|
|
|
final int height; |
|
|
|
final int margin; |
|
|
|
final int margin; |
|
|
|
final int eccLevel; |
|
|
|
final int eccLevel; |
|
|
|
|
|
|
|
final Messages messages; |
|
|
|
final Function(EncodeResult result, Uint8List? bytes)? onSuccess; |
|
|
|
final Function(EncodeResult result, Uint8List? bytes)? onSuccess; |
|
|
|
final Function(String error)? onError; |
|
|
|
final Function(String error)? onError; |
|
|
|
|
|
|
|
|
|
|
@ -69,6 +71,7 @@ class _WriterWidgetState extends State<WriterWidget> |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
Widget build(BuildContext context) { |
|
|
|
Widget build(BuildContext context) { |
|
|
|
|
|
|
|
final Messages m = widget.messages; |
|
|
|
return SingleChildScrollView( |
|
|
|
return SingleChildScrollView( |
|
|
|
child: Form( |
|
|
|
child: Form( |
|
|
|
key: _formKey, |
|
|
|
key: _formKey, |
|
|
@ -91,13 +94,13 @@ class _WriterWidgetState extends State<WriterWidget> |
|
|
|
decoration: InputDecoration( |
|
|
|
decoration: InputDecoration( |
|
|
|
border: const OutlineInputBorder(), |
|
|
|
border: const OutlineInputBorder(), |
|
|
|
filled: true, |
|
|
|
filled: true, |
|
|
|
labelText: 'Enter barcode text here', |
|
|
|
labelText: m.textLabel, |
|
|
|
counterText: |
|
|
|
counterText: |
|
|
|
'${_textController.value.text.length} / $_maxTextLength', |
|
|
|
'${_textController.value.text.length} / $_maxTextLength', |
|
|
|
), |
|
|
|
), |
|
|
|
validator: (String? value) { |
|
|
|
validator: (String? value) { |
|
|
|
if (value?.isEmpty ?? false) { |
|
|
|
if (value?.isEmpty ?? false) { |
|
|
|
return 'Please enter some text'; |
|
|
|
return m.invalidText; |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
}, |
|
|
|
}, |
|
|
@ -125,13 +128,13 @@ class _WriterWidgetState extends State<WriterWidget> |
|
|
|
child: TextFormField( |
|
|
|
child: TextFormField( |
|
|
|
controller: _widthController, |
|
|
|
controller: _widthController, |
|
|
|
keyboardType: TextInputType.number, |
|
|
|
keyboardType: TextInputType.number, |
|
|
|
decoration: const InputDecoration( |
|
|
|
decoration: InputDecoration( |
|
|
|
labelText: 'Width', |
|
|
|
labelText: m.widthLabel, |
|
|
|
), |
|
|
|
), |
|
|
|
validator: (String? value) { |
|
|
|
validator: (String? value) { |
|
|
|
final int? width = int.tryParse(value ?? ''); |
|
|
|
final int? width = int.tryParse(value ?? ''); |
|
|
|
if (width == null) { |
|
|
|
if (width == null) { |
|
|
|
return 'Invalid number'; |
|
|
|
return m.invalidWidth; |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
}, |
|
|
|
}, |
|
|
@ -142,13 +145,13 @@ class _WriterWidgetState extends State<WriterWidget> |
|
|
|
child: TextFormField( |
|
|
|
child: TextFormField( |
|
|
|
controller: _heightController, |
|
|
|
controller: _heightController, |
|
|
|
keyboardType: TextInputType.number, |
|
|
|
keyboardType: TextInputType.number, |
|
|
|
decoration: const InputDecoration( |
|
|
|
decoration: InputDecoration( |
|
|
|
labelText: 'Height', |
|
|
|
labelText: m.heightLabel, |
|
|
|
), |
|
|
|
), |
|
|
|
validator: (String? value) { |
|
|
|
validator: (String? value) { |
|
|
|
final int? width = int.tryParse(value ?? ''); |
|
|
|
final int? width = int.tryParse(value ?? ''); |
|
|
|
if (width == null) { |
|
|
|
if (width == null) { |
|
|
|
return 'Invalid number'; |
|
|
|
return m.invalidHeight; |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
}, |
|
|
|
}, |
|
|
@ -163,13 +166,13 @@ class _WriterWidgetState extends State<WriterWidget> |
|
|
|
child: TextFormField( |
|
|
|
child: TextFormField( |
|
|
|
controller: _marginController, |
|
|
|
controller: _marginController, |
|
|
|
keyboardType: TextInputType.number, |
|
|
|
keyboardType: TextInputType.number, |
|
|
|
decoration: const InputDecoration( |
|
|
|
decoration: InputDecoration( |
|
|
|
labelText: 'Margin', |
|
|
|
labelText: m.marginLabel, |
|
|
|
), |
|
|
|
), |
|
|
|
validator: (String? value) { |
|
|
|
validator: (String? value) { |
|
|
|
final int? width = int.tryParse(value ?? ''); |
|
|
|
final int? width = int.tryParse(value ?? ''); |
|
|
|
if (width == null) { |
|
|
|
if (width == null) { |
|
|
|
return 'Invalid number'; |
|
|
|
return m.invalidMargin; |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
}, |
|
|
|
}, |
|
|
@ -180,13 +183,13 @@ class _WriterWidgetState extends State<WriterWidget> |
|
|
|
child: TextFormField( |
|
|
|
child: TextFormField( |
|
|
|
controller: _eccController, |
|
|
|
controller: _eccController, |
|
|
|
keyboardType: TextInputType.number, |
|
|
|
keyboardType: TextInputType.number, |
|
|
|
decoration: const InputDecoration( |
|
|
|
decoration: InputDecoration( |
|
|
|
labelText: 'ECC Level', |
|
|
|
labelText: m.eccLevelLabel, |
|
|
|
), |
|
|
|
), |
|
|
|
validator: (String? value) { |
|
|
|
validator: (String? value) { |
|
|
|
final int? width = int.tryParse(value ?? ''); |
|
|
|
final int? width = int.tryParse(value ?? ''); |
|
|
|
if (width == null) { |
|
|
|
if (width == null) { |
|
|
|
return 'Invalid number'; |
|
|
|
return m.invalidEccLevel; |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
}, |
|
|
|
}, |
|
|
@ -198,7 +201,7 @@ class _WriterWidgetState extends State<WriterWidget> |
|
|
|
// Write button |
|
|
|
// Write button |
|
|
|
ElevatedButton( |
|
|
|
ElevatedButton( |
|
|
|
onPressed: createBarcode, |
|
|
|
onPressed: createBarcode, |
|
|
|
child: const Text('Create'), |
|
|
|
child: Text(m.createButton), |
|
|
|
), |
|
|
|
), |
|
|
|
const SizedBox(height: 10), |
|
|
|
const SizedBox(height: 10), |
|
|
|
], |
|
|
|
], |
|
|
|