BarcodeView class
Shows a barcode. Drawn as vectors from the module matrix, so it is sharp at any size and pixel density.
The writer encodes the data, exactly as writer.encode and the
exports do; the style draws it.
BarcodeView('https://pub.dev', width: 200)
BarcodeView(
'4006381333931',
writer: const BarcodeWriter(BarcodeFormat.ean13),
width: 240,
)
BarcodeView.bytes(
payload,
writer: const BarcodeWriter(BarcodeFormat.dataMatrix),
width: 120,
)
Without width and height it fills the incoming constraints, keeping the symbol's aspect ratio.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- BarcodeView
Constructors
- BarcodeView(String data, {Key? key, BarcodeWriter writer = const BarcodeWriter(BarcodeFormat.qrCode), BarcodeStyle style = BarcodeStyle.classic, double? width, double? height, String? semanticLabel, Widget errorBuilder(BuildContext context, BarcodeWriteException error)?})
-
Creates a barcode view for the text
data, encoded withwriter(a QR code by default).const - BarcodeView.bytes(Uint8List bytes, {Key? key, BarcodeWriter writer = const BarcodeWriter(BarcodeFormat.qrCode), BarcodeStyle style = BarcodeStyle.classic, double? width, double? height, String? semanticLabel, Widget errorBuilder(BuildContext context, BarcodeWriteException error)?})
-
Creates a barcode view for binary
bytes, encoded withwriter(formats with a byte mode: QR, Data Matrix, Aztec, PDF417).const - BarcodeView.symbol(BarcodeSymbol symbol, {Key? key, BarcodeStyle style = BarcodeStyle.classic, double? width, double? height, String? semanticLabel})
-
Draws a BarcodeSymbol as it is: the modules a reader sampled from a
code (
Barcode.symbol), or a symbol fromBarcodeWriter.encodeorBarcodeStyle.encode. Nothing is encoded, so the code shown is exactly the one read.
Properties
- bytes → Uint8List?
-
The binary data to encode, or
nullfor text.final - data → String?
-
The text to encode, or
nullfor BarcodeView.bytes.final - errorBuilder → Widget Function(BuildContext context, BarcodeWriteException error)?
-
Shown instead of the barcode if data cannot be encoded. Without it,
an empty box is shown and the error is reported to
FlutterError.final - hashCode → int
-
The hash code for this object.
no setterinherited
- height → double?
-
Height in logical pixels.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- semanticLabel → String?
-
Accessibility label. By default the format's name, the
BarcodeStyle.title and BarcodeStyle.caption, and the text under a
linear barcode when it is shown; never the encoded data, which may be
a password or bank details.
final
- style → BarcodeStyle
-
Colors, shapes, logo, title, caption and quiet zone.
final
- symbol → BarcodeSymbol?
-
The symbol to draw as it is, from BarcodeView.symbol.
final
- width → double?
-
Width in logical pixels.
final
- writer → BarcodeWriter?
-
Encodes data or bytes: the format, error correction, GS1, version
and the text under linear barcodes (BarcodeWriter.showText);
nullfor BarcodeView.symbol, which encodes nothing.final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< BarcodeView> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited