How to generate barcodes using the Syncfusion Flutter Barcode Generator widget (SfBarcodeGenerator) ?
Description
This article describes how to create an example of Barcode in Syncfusion® Flutter widgets.
Solution
The Syncfusion® Flutter Barcode Generator is a data visualization widget used to generate and display data in a machine-readable format. It provides a perfect approach to encode text using supported symbology types.
Refer to the following instructions to know how to use the barcode generator.
Step 1: Create a simple project using the instructions given in the Getting Started with your first Flutter app documentation.
Step 2: Add the Syncfusion® Flutter Barcode dependency to your pubspec.yaml file.
dependencies: syncfusion_flutter_barcodes: ^xx.x.xx
Here xx.x.xx denotes the current version of Syncfusion® Flutter Barcodes package.
Step 3: Run the following command to get the required packages.
$ flutter pub get
Step 4: Import the following package in your Dart code.
import 'package:syncfusion_flutter_barcodes/barcodes.dart'; |
Step 5: Add the Barcode Generator widget as a child of any widget. Here, the widget is added as a child of the container widget and the height to the container is specified (otherwise it will take full container height). The default symbology of SfBarcodeGenerator is Code128.
@override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( body: Center( child: Container( height: 150, child:SfBarcodeGenerator(value:'http://www.syncfusion.com') ) ) ) ); }
Screenshots
For more information on the Barcode generator, please check the user guide and API reference.