Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Files and directories created by pub
.packages
.pub/
build/
# Remove the following pattern if you wish to check in your lock file
**/pubspec.lock

# Directory created by dartdoc
doc/api/
.idea
/intl_en.arb
.DS_Store

# coverage
coverage/
lcov.info

# tests
.flutter-plugins

# Files generated by dart tools
.dart_tool

# generated by flutter
flutter_export_environment.sh
193 changes: 139 additions & 54 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,33 +1,104 @@
import 'package:flutter/material.dart';
import 'package:barcode_flutter/barcode_flutter.dart';

void main() => runApp(new MyApp());

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
return MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: new MyHomePage(codeList: [
new BarCodeItem(type: BarCodeType.Code39, codeStr: "CODE39", description: "Code39 with text", hasText: true),
new BarCodeItem(type: BarCodeType.Code39, codeStr: "CODE39", description: "Code39", hasText: false),
new BarCodeItem(type: BarCodeType.Code93, codeStr: "BARCODE93", description: "Code93 with text", hasText: true),
new BarCodeItem(type: BarCodeType.Code93, codeStr: "BARCODE93", description: "Code93", hasText: false),
new BarCodeItem(type: BarCodeType.Code128, codeStr: "BARCODE128", description: "Code128 with text", hasText: true),
new BarCodeItem(type: BarCodeType.Code128, codeStr: "BARCODE128", description: "Code128", hasText: false),
new BarCodeItem(type: BarCodeType.CodeEAN8, codeStr: "65833254", description: "EAN8 with text", hasText: true),
new BarCodeItem(type: BarCodeType.CodeEAN8, codeStr: "65833254", description: "EAN8", hasText: false),
new BarCodeItem(type: BarCodeType.CodeEAN13, codeStr: "9501101530003", description: "EAN13 with text", hasText: true),
new BarCodeItem(type: BarCodeType.CodeEAN13, codeStr: "9501101530003", description: "EAN13", hasText: false),
new BarCodeItem(type: BarCodeType.CodeUPCA, codeStr: "123456789012", description: "UPCA with text", hasText: true),
new BarCodeItem(type: BarCodeType.CodeUPCA, codeStr: "123456789012", description: "UPCA", hasText: false),
new BarCodeItem(type: BarCodeType.CodeUPCE, codeStr: "00123457", description: "UPCE with text", hasText: true),
new BarCodeItem(type: BarCodeType.CodeUPCE, codeStr: "00123457", description: "UPCE", hasText: false),
],)
home: MyHomePage(
codeList: [
BarCodeItem(
type: BarCodeType.Code39,
codeStr: "CODE39",
description: "Code39 with text",
hasText: true,
),
BarCodeItem(
type: BarCodeType.Code39,
codeStr: "CODE39",
description: "Code39",
hasText: false,
),
BarCodeItem(
type: BarCodeType.Code93,
codeStr: "BARCODE93",
description: "Code93 with text",
hasText: true,
),
BarCodeItem(
type: BarCodeType.Code93,
codeStr: "BARCODE93",
description: "Code93",
hasText: false,
),
BarCodeItem(
type: BarCodeType.Code128,
codeStr: "BARCODE128",
description: "Code128 with text",
hasText: true,
),
BarCodeItem(
type: BarCodeType.Code128,
codeStr: "BARCODE128",
description: "Code128",
hasText: false,
),
BarCodeItem(
type: BarCodeType.CodeEAN8,
codeStr: "65833254",
description: "EAN8 with text",
hasText: true,
),
BarCodeItem(
type: BarCodeType.CodeEAN8,
codeStr: "65833254",
description: "EAN8",
hasText: false,
),
BarCodeItem(
type: BarCodeType.CodeEAN13,
codeStr: "9501101530003",
description: "EAN13 with text",
hasText: true,
),
BarCodeItem(
type: BarCodeType.CodeEAN13,
codeStr: "9501101530003",
description: "EAN13",
hasText: false,
),
BarCodeItem(
type: BarCodeType.CodeUPCA,
codeStr: "123456789012",
description: "UPCA with text",
hasText: true,
),
BarCodeItem(
type: BarCodeType.CodeUPCA,
codeStr: "123456789012",
description: "UPCA",
hasText: false,
),
BarCodeItem(
type: BarCodeType.CodeUPCE,
codeStr: "00123457",
description: "UPCE with text",
hasText: true,
),
BarCodeItem(
type: BarCodeType.CodeUPCE,
codeStr: "00123457",
description: "UPCE",
hasText: false,
),
],
),
);
}
}
Expand All @@ -38,49 +109,63 @@ class MyHomePage extends StatefulWidget {
final String title = "BarCode Flutter";

@override
_MyHomePageState createState() => new _MyHomePageState();
_MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text(widget.title),
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: new ListView(
body: ListView(
children: widget.codeList.map((element) {
return new Padding(padding: const EdgeInsets.all(10.0),
child: new Card(
child: new Column(
children: <Widget>[
new Align(
alignment: Alignment.centerLeft,
child: new Text(element.description,
textAlign: TextAlign.left,
style: new TextStyle(fontWeight: FontWeight.bold, fontSize: 20.0, color: Colors.black45),
return Padding(
padding: const EdgeInsets.all(10.0),
child: Card(
color: Colors.blueGrey[50],
child: Padding(
padding: EdgeInsets.all(8.0),
child: Column(
children: <Widget>[
Align(
alignment: Alignment.centerLeft,
child: Text(
element.description,
textAlign: TextAlign.left,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20.0,
color: Colors.black45,
),
),
),
),
new Center(child:
new Container(padding: const EdgeInsets.all(10.0),
child: new BarCodeImage(
data:element.codeStr,
codeType: element.type,
lineWidth: 2.0,
barHeight: 100.0,
hasText: element.hasText,
onError: (error) {
print("Generate barcode failed. error msg: $error");
},
Center(
child: Container(
padding: const EdgeInsets.all(10.0),
child: BarCodeImage(
// backgroundColor: Colors.red,
// foregroundColor: Colors.deepPurple,
data: element.codeStr,
codeType: element.type,
lineWidth: 2.0,
barHeight: 100.0,
hasText: element.hasText,
onError: (error) {
print("Generate barcode failed. error msg: $error");
},
),
),
)
)
]
)
),) ;
}
).toList()
));
),
],
),
),
),
);
}).toList(),
),
);
}
}

Expand Down
Loading