Skip to content

Commit

Permalink
fixes for...
Browse files Browse the repository at this point in the history
Barcode not centered bigship#1
foregroundColor doesn't work bigship#3
Barcode is rendered outside the canvas bigship#13
Code93 barcode has extra bars on the end bigship#14
  • Loading branch information
bruceanwyl committed Oct 5, 2019
1 parent 4f90617 commit 028e140
Show file tree
Hide file tree
Showing 7 changed files with 1,270 additions and 783 deletions.
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

0 comments on commit 028e140

Please sign in to comment.