diff --git a/README.md b/README.md
index ab452ac..228750d 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,9 @@ __Barcode Flutter is a Flutter library for simple and fast Barcode rendering via
# Update Notes
+2.0.0
+ - Migrated to Dart null safe
+
1.1.2
- Add Codabar support
- Fix wrong pattern for value 102 of Code128 ([#20](https://github.com/bigship/barcode.flutter/issues/20))
@@ -32,7 +35,7 @@ You can install the package by adding the following lines to your `pubspec.yaml`
```yaml
dependencies:
- barcode_flutter: ^1.1.2
+ barcode_flutter: ^2.0.0
```
After adding the dependency to your `pubspec.yaml` you can run: `flutter packages get` or update your packages using your IDE.
diff --git a/analysis_options.yaml b/analysis_options.yaml
new file mode 100644
index 0000000..705c943
--- /dev/null
+++ b/analysis_options.yaml
@@ -0,0 +1,19 @@
+# Recommended lints for Flutter apps, packages, and plugins.
+
+include: package:lints/recommended.yaml
+
+linter:
+ rules:
+ avoid_print: true
+ avoid_unnecessary_containers: true
+ avoid_web_libraries_in_flutter: true
+ no_logic_in_create_state: true
+ prefer_const_constructors: true
+ prefer_const_constructors_in_immutables: true
+ prefer_const_declarations: true
+ prefer_const_literals_to_create_immutables: true
+ sized_box_for_whitespace: true
+ use_full_hex_values_for_flutter_colors: true
+ use_key_in_widget_constructors: true
+ depend_on_referenced_packages: false
+ library_private_types_in_public_api: false
diff --git a/example/.idea/libraries/KotlinJavaRuntime.xml b/example/.idea/libraries/KotlinJavaRuntime.xml
new file mode 100644
index 0000000..2b96ac4
--- /dev/null
+++ b/example/.idea/libraries/KotlinJavaRuntime.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml
new file mode 100644
index 0000000..705c943
--- /dev/null
+++ b/example/analysis_options.yaml
@@ -0,0 +1,19 @@
+# Recommended lints for Flutter apps, packages, and plugins.
+
+include: package:lints/recommended.yaml
+
+linter:
+ rules:
+ avoid_print: true
+ avoid_unnecessary_containers: true
+ avoid_web_libraries_in_flutter: true
+ no_logic_in_create_state: true
+ prefer_const_constructors: true
+ prefer_const_constructors_in_immutables: true
+ prefer_const_declarations: true
+ prefer_const_literals_to_create_immutables: true
+ sized_box_for_whitespace: true
+ use_full_hex_values_for_flutter_colors: true
+ use_key_in_widget_constructors: true
+ depend_on_referenced_packages: false
+ library_private_types_in_public_api: false
diff --git a/example/android/.gitignore b/example/android/.gitignore
index 65b7315..0a741cb 100644
--- a/example/android/.gitignore
+++ b/example/android/.gitignore
@@ -1,10 +1,11 @@
-*.iml
-*.class
-.gradle
+gradle-wrapper.jar
+/.gradle
+/captures/
+/gradlew
+/gradlew.bat
/local.properties
-/.idea/workspace.xml
-/.idea/libraries
-.DS_Store
-/build
-/captures
GeneratedPluginRegistrant.java
+
+# Remember to never publicly share your keystore.
+# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
+key.properties
diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle
index 4821a24..6ca2344 100644
--- a/example/android/app/build.gradle
+++ b/example/android/app/build.gradle
@@ -11,24 +11,34 @@ if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
+def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
+if (flutterVersionCode == null) {
+ flutterVersionCode = '1'
+}
+
+def flutterVersionName = localProperties.getProperty('flutter.versionName')
+if (flutterVersionName == null) {
+ flutterVersionName = '1.0'
+}
+
apply plugin: 'com.android.application'
+apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
- compileSdkVersion 28
+ compileSdkVersion 30
- lintOptions {
- disable 'InvalidPackage'
+ sourceSets {
+ main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.example"
minSdkVersion 16
- targetSdkVersion 27
- versionCode 1
- versionName "1.0"
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ targetSdkVersion 30
+ versionCode flutterVersionCode.toInteger()
+ versionName flutterVersionName
}
buildTypes {
@@ -45,7 +55,5 @@ flutter {
}
dependencies {
- testImplementation 'junit:junit:4.12'
- androidTestImplementation 'com.android.support.test:runner:1.0.1'
- androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml
new file mode 100644
index 0000000..c208884
--- /dev/null
+++ b/example/android/app/src/debug/AndroidManifest.xml
@@ -0,0 +1,7 @@
+
+
+
+
diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml
index 1b515f8..34dd77e 100644
--- a/example/android/app/src/main/AndroidManifest.xml
+++ b/example/android/app/src/main/AndroidManifest.xml
@@ -1,39 +1,41 @@
-
-
-
-
-
-
-
+
+ android:name="io.flutter.embedding.android.NormalTheme"
+ android:resource="@style/NormalTheme"
+ />
+
+
+
+
diff --git a/example/android/app/src/main/java/com/example/example/MainActivity.java b/example/android/app/src/main/java/com/example/example/MainActivity.java
deleted file mode 100644
index 84f8920..0000000
--- a/example/android/app/src/main/java/com/example/example/MainActivity.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.example.example;
-
-import android.os.Bundle;
-import io.flutter.app.FlutterActivity;
-import io.flutter.plugins.GeneratedPluginRegistrant;
-
-public class MainActivity extends FlutterActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- GeneratedPluginRegistrant.registerWith(this);
- }
-}
diff --git a/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt b/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt
new file mode 100644
index 0000000..e793a00
--- /dev/null
+++ b/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt
@@ -0,0 +1,6 @@
+package com.example.example
+
+import io.flutter.embedding.android.FlutterActivity
+
+class MainActivity: FlutterActivity() {
+}
diff --git a/example/android/app/src/main/res/drawable-v21/launch_background.xml b/example/android/app/src/main/res/drawable-v21/launch_background.xml
new file mode 100644
index 0000000..f74085f
--- /dev/null
+++ b/example/android/app/src/main/res/drawable-v21/launch_background.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
diff --git a/example/android/app/src/main/res/values-night/styles.xml b/example/android/app/src/main/res/values-night/styles.xml
new file mode 100644
index 0000000..449a9f9
--- /dev/null
+++ b/example/android/app/src/main/res/values-night/styles.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
diff --git a/example/android/app/src/main/res/values/styles.xml b/example/android/app/src/main/res/values/styles.xml
index 00fa441..d74aa35 100644
--- a/example/android/app/src/main/res/values/styles.xml
+++ b/example/android/app/src/main/res/values/styles.xml
@@ -1,8 +1,18 @@
-
+
+
diff --git a/example/android/app/src/profile/AndroidManifest.xml b/example/android/app/src/profile/AndroidManifest.xml
new file mode 100644
index 0000000..c208884
--- /dev/null
+++ b/example/android/app/src/profile/AndroidManifest.xml
@@ -0,0 +1,7 @@
+
+
+
+
diff --git a/example/android/build.gradle b/example/android/build.gradle
index 6de3728..9b6ed06 100644
--- a/example/android/build.gradle
+++ b/example/android/build.gradle
@@ -1,11 +1,13 @@
buildscript {
+ ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.5.3'
+ classpath 'com.android.tools.build:gradle:4.1.0'
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
@@ -19,8 +21,6 @@ allprojects {
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
-}
-subprojects {
project.evaluationDependsOn(':app')
}
diff --git a/example/android/example_android.iml b/example/android/example_android.iml
new file mode 100644
index 0000000..1899969
--- /dev/null
+++ b/example/android/example_android.iml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/example/android/gradle.properties b/example/android/gradle.properties
index 7be3d8b..94adc3a 100644
--- a/example/android/gradle.properties
+++ b/example/android/gradle.properties
@@ -1,2 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
-android.enableR8=true
+android.useAndroidX=true
+android.enableJetifier=true
diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties
index 60d0454..bc6a58a 100644
--- a/example/android/gradle/wrapper/gradle-wrapper.properties
+++ b/example/android/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Tue Dec 31 09:19:52 EST 2019
+#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
diff --git a/example/android/settings.gradle b/example/android/settings.gradle
index 5a2f14f..44e62bc 100644
--- a/example/android/settings.gradle
+++ b/example/android/settings.gradle
@@ -1,15 +1,11 @@
include ':app'
-def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
+def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
+def properties = new Properties()
-def plugins = new Properties()
-def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
-if (pluginsFile.exists()) {
- pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
-}
+assert localPropertiesFile.exists()
+localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
-plugins.each { name, path ->
- def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
- include ":$name"
- project(":$name").projectDir = pluginDirectory
-}
+def flutterSdkPath = properties.getProperty("flutter.sdk")
+assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
+apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
diff --git a/example/ios/Flutter/Flutter.podspec b/example/ios/Flutter/Flutter.podspec
deleted file mode 100644
index 5ca3041..0000000
--- a/example/ios/Flutter/Flutter.podspec
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# NOTE: This podspec is NOT to be published. It is only used as a local source!
-#
-
-Pod::Spec.new do |s|
- s.name = 'Flutter'
- s.version = '1.0.0'
- s.summary = 'High-performance, high-fidelity mobile apps.'
- s.description = <<-DESC
-Flutter provides an easy and productive way to build and deploy high-performance mobile apps for Android and iOS.
- DESC
- s.homepage = 'https://flutter.io'
- s.license = { :type => 'MIT' }
- s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' }
- s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s }
- s.ios.deployment_target = '8.0'
- s.vendored_frameworks = 'Flutter.framework'
-end
diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
new file mode 100644
index 0000000..f9b0d7c
--- /dev/null
+++ b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
@@ -0,0 +1,8 @@
+
+
+
+
+ PreviewsEnabled
+
+
+
diff --git a/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
new file mode 100644
index 0000000..f9b0d7c
--- /dev/null
+++ b/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
@@ -0,0 +1,8 @@
+
+
+
+
+ PreviewsEnabled
+
+
+
diff --git a/example/ios/Runner/AppDelegate.swift b/example/ios/Runner/AppDelegate.swift
new file mode 100644
index 0000000..70693e4
--- /dev/null
+++ b/example/ios/Runner/AppDelegate.swift
@@ -0,0 +1,13 @@
+import UIKit
+import Flutter
+
+@UIApplicationMain
+@objc class AppDelegate: FlutterAppDelegate {
+ override func application(
+ _ application: UIApplication,
+ didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
+ ) -> Bool {
+ GeneratedPluginRegistrant.register(with: self)
+ return super.application(application, didFinishLaunchingWithOptions: launchOptions)
+ }
+}
diff --git a/example/ios/Runner/Runner-Bridging-Header.h b/example/ios/Runner/Runner-Bridging-Header.h
new file mode 100644
index 0000000..308a2a5
--- /dev/null
+++ b/example/ios/Runner/Runner-Bridging-Header.h
@@ -0,0 +1 @@
+#import "GeneratedPluginRegistrant.h"
diff --git a/example/lib/main.dart b/example/lib/main.dart
index 6294a61..03bb61a 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -1,233 +1,241 @@
-import 'package:flutter/material.dart';
+///
+/// Flutter BarCode Widget
+/// Copyright (c) 2018 the BarCode Flutter authors.
+/// See LICENSE for distribution and usage details.
+///
+// ignore_for_file: use_key_in_widget_constructors
+
+library barcode_flutter_example;
+
import 'package:barcode_flutter/barcode_flutter.dart';
+import 'package:flutter/material.dart';
-void main() => runApp(MyApp());
+///
+///
+void main() => runApp(const MyApp());
+///
+///
+///
class MyApp extends StatelessWidget {
+ ///
+ const MyApp();
+
@override
- Widget build(BuildContext context) {
- return MaterialApp(
- title: 'Barcode Flutter Demo',
- theme: ThemeData(
- primarySwatch: Colors.blue,
- ),
- home: MyHomePage(
- barcodes: [
- BarCodeItem(
- description: "Code39 with text",
- image: BarCodeImage(
- params: Code39BarCodeParams(
- "CODE39",
- withText: true,
- ),
- ),
- ),
- BarCodeItem(
- description: "Code39",
- image: BarCodeImage(
- params: Code39BarCodeParams(
- "CODE39",
- ),
- ),
- ),
- BarCodeItem(
- description: "Code39 with text",
- image: BarCodeImage(
- params: Code93BarCodeParams(
- "CODE93",
- withText: true,
- ),
- ),
- ),
- BarCodeItem(
- description: "Code93",
- image: BarCodeImage(
- params: Code93BarCodeParams(
- "CODE93",
- ),
- ),
- ),
- BarCodeItem(
- description: "Code128 with text",
- image: BarCodeImage(
- params: Code128BarCodeParams(
- "CODE128",
- withText: true,
- ),
- ),
- ),
- BarCodeItem(
- description: "Code128",
- image: BarCodeImage(
- params: Code128BarCodeParams(
- "CODE128",
- ),
- ),
- ),
- BarCodeItem(
- description: "EAN8 with text",
- image: BarCodeImage(
- params: EAN8BarCodeParams(
- "65833254",
- withText: true,
- ),
- ),
- ),
- BarCodeItem(
- description: "EAN8",
- image: BarCodeImage(
- params: EAN8BarCodeParams(
- "65833254",
- ),
- ),
- ),
- BarCodeItem(
- description: "EAN13 with text",
- image: BarCodeImage(
- params: EAN13BarCodeParams(
- "9501101530003",
- withText: true,
- ),
- ),
- ),
- BarCodeItem(
- description: "EAN13",
- image: BarCodeImage(
- params: EAN13BarCodeParams(
- "9501101530003",
- ),
- ),
- ),
- BarCodeItem(
- description: "UPCA with text",
- image: BarCodeImage(
- params: UPCABarCodeParams(
- "123456789012",
- withText: true,
- ),
- ),
- ),
- BarCodeItem(
- description: "UPCA",
- image: BarCodeImage(
- params: UPCABarCodeParams(
- "123456789012",
- ),
- ),
- ),
- BarCodeItem(
- description: "UPCE with text",
- image: BarCodeImage(
- params: UPCEBarCodeParams(
- "00123457",
- withText: true,
- ),
- ),
- ),
- BarCodeItem(
- description: "UPCE",
- image: BarCodeImage(
- params: UPCEBarCodeParams(
- "00123457",
- ),
- ),
- ),
- BarCodeItem(
- description: "ITF with text",
- image: BarCodeImage(
- params: ITFBarCodeParams(
- "133175398642265258",
- withText: true,
- ),
- ),
- ),
- BarCodeItem(
- description: "ITF",
- image: BarCodeImage(
- params: ITFBarCodeParams(
- "133175398642265258",
- ),
- ),
- ),
- BarCodeItem(
- description: "Codabar with text",
- image: BarCodeImage(
- params: CodabarBarCodeParams(
- "A123456789B",
- withText: true,
+ Widget build(BuildContext context) => MaterialApp(
+ title: 'Barcode Flutter Demo',
+ theme: ThemeData(primarySwatch: Colors.blue),
+ //
+ home: MyHomePage(
+ barcodes: [
+ //
+ BarCodeItem(
+ description: 'Code39 with text',
+ image: BarCodeImage(
+ params: Code39BarCodeParams('CODE39', withText: true),
),
- )
- ),
- BarCodeItem(
- description: "Codabar",
- image: BarCodeImage(
- params: CodabarBarCodeParams(
- "A123456789B",
+ ),
+ //
+ BarCodeItem(
+ description: 'Code39',
+ image: BarCodeImage(
+ params: Code39BarCodeParams('CODE39'),
),
- )
- )
- ],
- ),
- );
- }
+ ),
+ //
+ BarCodeItem(
+ description: 'Code39 with text',
+ image: BarCodeImage(
+ params: Code93BarCodeParams('CODE93', withText: true),
+ ),
+ ),
+ //
+ BarCodeItem(
+ description: 'Code93',
+ image: BarCodeImage(
+ params: Code93BarCodeParams('CODE93'),
+ ),
+ ),
+ //
+ BarCodeItem(
+ description: 'Code128 with text',
+ image: BarCodeImage(
+ params: Code128BarCodeParams('CODE128', withText: true),
+ ),
+ ),
+ //
+ BarCodeItem(
+ description: 'Code128',
+ image: BarCodeImage(
+ params: Code128BarCodeParams('CODE128'),
+ ),
+ ),
+ //
+ BarCodeItem(
+ description: 'EAN8 with text',
+ image: BarCodeImage(
+ params: EAN8BarCodeParams('65833254', withText: true),
+ ),
+ ),
+ //
+ BarCodeItem(
+ description: 'EAN8',
+ image: BarCodeImage(
+ params: EAN8BarCodeParams('65833254'),
+ ),
+ ),
+ //
+ BarCodeItem(
+ description: 'EAN13 with text',
+ image: BarCodeImage(
+ params: EAN13BarCodeParams('9501101530003', withText: true),
+ ),
+ ),
+ //
+ BarCodeItem(
+ description: 'EAN13',
+ image: BarCodeImage(
+ params: EAN13BarCodeParams('9501101530003'),
+ ),
+ ),
+ //
+ BarCodeItem(
+ description: 'UPCA with text',
+ image: BarCodeImage(
+ params: UPCABarCodeParams('123456789012', withText: true),
+ ),
+ ),
+ //
+ BarCodeItem(
+ description: 'UPCA',
+ image: BarCodeImage(
+ params: UPCABarCodeParams('123456789012'),
+ ),
+ ),
+ //
+ BarCodeItem(
+ description: 'UPCE with text',
+ image: BarCodeImage(
+ params: UPCEBarCodeParams('00123457', withText: true),
+ ),
+ ),
+ //
+ BarCodeItem(
+ description: 'UPCE',
+ image: BarCodeImage(
+ params: UPCEBarCodeParams('00123457'),
+ ),
+ ),
+ //
+ BarCodeItem(
+ description: 'ITF with text',
+ image: BarCodeImage(
+ params: ITFBarCodeParams('133175398642265258', withText: true),
+ ),
+ ),
+ //
+ BarCodeItem(
+ description: 'ITF',
+ image: BarCodeImage(
+ params: ITFBarCodeParams('133175398642265258'),
+ ),
+ ),
+ //
+ BarCodeItem(
+ description: 'Codabar with text',
+ image: BarCodeImage(
+ params: CodabarBarCodeParams('A123456789B', withText: true),
+ ),
+ ),
+ //
+ BarCodeItem(
+ description: 'Codabar',
+ image: BarCodeImage(
+ params: CodabarBarCodeParams('A123456789B'),
+ ),
+ ),
+ ],
+ ),
+ );
}
+///
+///
+///
class MyHomePage extends StatefulWidget {
- MyHomePage({this.barcodes});
+ ///
+ const MyHomePage({required this.barcodes, this.title = 'BarCode Flutter'});
+
+ ///
final List barcodes;
- final String title = "BarCode Flutter";
+
+ ///
+ final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
+///
+///
+///
class _MyHomePageState extends State {
@override
Widget build(BuildContext context) {
return Scaffold(
- appBar: AppBar(
- title: Text(widget.title),
- ),
+ //
+ appBar: AppBar(title: Text(widget.title)),
+ //
body: ListView(
- children: widget.barcodes.map((element) {
- return Padding(
- padding: const EdgeInsets.all(10.0),
- child: Card(
- child: Column(
- children: [
- Align(
- alignment: Alignment.centerLeft,
- child: Text(
- element.description,
- textAlign: TextAlign.left,
- style: TextStyle(
- fontWeight: FontWeight.bold,
- fontSize: 20.0,
- color: Colors.black45,
+ children: widget.barcodes
+ .map(
+ (element) => Padding(
+ padding: const EdgeInsets.all(10.0),
+ child: Card(
+ //
+ child: Column(
+ children: [
+ //
+ Align(
+ alignment: Alignment.centerLeft,
+ child: Text(
+ element.description,
+ textAlign: TextAlign.left,
+ style: const TextStyle(
+ fontWeight: FontWeight.bold,
+ color: Colors.black45,
+ fontSize: 20.0,
+ ),
+ ),
),
- ),
+ //
+ Center(
+ child: Container(
+ padding: const EdgeInsets.all(10.0),
+ child: element.image,
+ ),
+ )
+ ],
),
- Center(
- child: Container(
- padding: const EdgeInsets.all(10.0),
- child: element.image,
- ),
- )
- ],
+ ),
),
- ),
- );
- }).toList(),
+ )
+ .toList(),
),
);
}
}
+///
+///
+///
class BarCodeItem {
+ ///
+ BarCodeItem({required this.image, required this.description});
+
+ ///
String description;
+
+ ///
BarCodeImage image;
- BarCodeItem({
- this.image,
- this.description,
- });
}
diff --git a/example/macos/.gitignore b/example/macos/.gitignore
new file mode 100644
index 0000000..d2fd377
--- /dev/null
+++ b/example/macos/.gitignore
@@ -0,0 +1,6 @@
+# Flutter-related
+**/Flutter/ephemeral/
+**/Pods/
+
+# Xcode-related
+**/xcuserdata/
diff --git a/example/macos/Flutter/Flutter-Debug.xcconfig b/example/macos/Flutter/Flutter-Debug.xcconfig
new file mode 100644
index 0000000..c2efd0b
--- /dev/null
+++ b/example/macos/Flutter/Flutter-Debug.xcconfig
@@ -0,0 +1 @@
+#include "ephemeral/Flutter-Generated.xcconfig"
diff --git a/example/macos/Flutter/Flutter-Release.xcconfig b/example/macos/Flutter/Flutter-Release.xcconfig
new file mode 100644
index 0000000..c2efd0b
--- /dev/null
+++ b/example/macos/Flutter/Flutter-Release.xcconfig
@@ -0,0 +1 @@
+#include "ephemeral/Flutter-Generated.xcconfig"
diff --git a/example/macos/Flutter/GeneratedPluginRegistrant.swift b/example/macos/Flutter/GeneratedPluginRegistrant.swift
new file mode 100644
index 0000000..cccf817
--- /dev/null
+++ b/example/macos/Flutter/GeneratedPluginRegistrant.swift
@@ -0,0 +1,10 @@
+//
+// Generated file. Do not edit.
+//
+
+import FlutterMacOS
+import Foundation
+
+
+func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
+}
diff --git a/example/macos/Runner.xcodeproj/project.pbxproj b/example/macos/Runner.xcodeproj/project.pbxproj
new file mode 100644
index 0000000..cc89c87
--- /dev/null
+++ b/example/macos/Runner.xcodeproj/project.pbxproj
@@ -0,0 +1,572 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 51;
+ objects = {
+
+/* Begin PBXAggregateTarget section */
+ 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = {
+ isa = PBXAggregateTarget;
+ buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */;
+ buildPhases = (
+ 33CC111E2044C6BF0003C045 /* ShellScript */,
+ );
+ dependencies = (
+ );
+ name = "Flutter Assemble";
+ productName = FLX;
+ };
+/* End PBXAggregateTarget section */
+
+/* Begin PBXBuildFile section */
+ 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; };
+ 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; };
+ 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; };
+ 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; };
+ 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXContainerItemProxy section */
+ 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 33CC10E52044A3C60003C045 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 33CC111A2044C6BA0003C045;
+ remoteInfo = FLX;
+ };
+/* End PBXContainerItemProxy section */
+
+/* Begin PBXCopyFilesBuildPhase section */
+ 33CC110E2044A8840003C045 /* Bundle Framework */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 2147483647;
+ dstPath = "";
+ dstSubfolderSpec = 10;
+ files = (
+ );
+ name = "Bundle Framework";
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXCopyFilesBuildPhase section */
+
+/* Begin PBXFileReference section */
+ 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; };
+ 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; };
+ 33CC10ED2044A3C60003C045 /* example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "example.app"; sourceTree = BUILT_PRODUCTS_DIR; };
+ 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
+ 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; };
+ 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; };
+ 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; };
+ 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; };
+ 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; };
+ 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; };
+ 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; };
+ 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; };
+ 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; };
+ 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; };
+ 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; };
+ 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 33CC10EA2044A3C60003C045 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 33BA886A226E78AF003329D5 /* Configs */ = {
+ isa = PBXGroup;
+ children = (
+ 33E5194F232828860026EE4D /* AppInfo.xcconfig */,
+ 9740EEB21CF90195004384FC /* Debug.xcconfig */,
+ 7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
+ 333000ED22D3DE5D00554162 /* Warnings.xcconfig */,
+ );
+ path = Configs;
+ sourceTree = "";
+ };
+ 33CC10E42044A3C60003C045 = {
+ isa = PBXGroup;
+ children = (
+ 33FAB671232836740065AC1E /* Runner */,
+ 33CEB47122A05771004F2AC0 /* Flutter */,
+ 33CC10EE2044A3C60003C045 /* Products */,
+ D73912EC22F37F3D000D13A0 /* Frameworks */,
+ );
+ sourceTree = "";
+ };
+ 33CC10EE2044A3C60003C045 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 33CC10ED2044A3C60003C045 /* example.app */,
+ );
+ name = Products;
+ sourceTree = "";
+ };
+ 33CC11242044D66E0003C045 /* Resources */ = {
+ isa = PBXGroup;
+ children = (
+ 33CC10F22044A3C60003C045 /* Assets.xcassets */,
+ 33CC10F42044A3C60003C045 /* MainMenu.xib */,
+ 33CC10F72044A3C60003C045 /* Info.plist */,
+ );
+ name = Resources;
+ path = ..;
+ sourceTree = "";
+ };
+ 33CEB47122A05771004F2AC0 /* Flutter */ = {
+ isa = PBXGroup;
+ children = (
+ 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */,
+ 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */,
+ 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */,
+ 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */,
+ );
+ path = Flutter;
+ sourceTree = "";
+ };
+ 33FAB671232836740065AC1E /* Runner */ = {
+ isa = PBXGroup;
+ children = (
+ 33CC10F02044A3C60003C045 /* AppDelegate.swift */,
+ 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */,
+ 33E51913231747F40026EE4D /* DebugProfile.entitlements */,
+ 33E51914231749380026EE4D /* Release.entitlements */,
+ 33CC11242044D66E0003C045 /* Resources */,
+ 33BA886A226E78AF003329D5 /* Configs */,
+ );
+ path = Runner;
+ sourceTree = "";
+ };
+ D73912EC22F37F3D000D13A0 /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ );
+ name = Frameworks;
+ sourceTree = "";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 33CC10EC2044A3C60003C045 /* Runner */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */;
+ buildPhases = (
+ 33CC10E92044A3C60003C045 /* Sources */,
+ 33CC10EA2044A3C60003C045 /* Frameworks */,
+ 33CC10EB2044A3C60003C045 /* Resources */,
+ 33CC110E2044A8840003C045 /* Bundle Framework */,
+ 3399D490228B24CF009A79C7 /* ShellScript */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ 33CC11202044C79F0003C045 /* PBXTargetDependency */,
+ );
+ name = Runner;
+ productName = Runner;
+ productReference = 33CC10ED2044A3C60003C045 /* example.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 33CC10E52044A3C60003C045 /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastSwiftUpdateCheck = 0920;
+ LastUpgradeCheck = 0930;
+ ORGANIZATIONNAME = "";
+ TargetAttributes = {
+ 33CC10EC2044A3C60003C045 = {
+ CreatedOnToolsVersion = 9.2;
+ LastSwiftMigration = 1100;
+ ProvisioningStyle = Automatic;
+ SystemCapabilities = {
+ com.apple.Sandbox = {
+ enabled = 1;
+ };
+ };
+ };
+ 33CC111A2044C6BA0003C045 = {
+ CreatedOnToolsVersion = 9.2;
+ ProvisioningStyle = Manual;
+ };
+ };
+ };
+ buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */;
+ compatibilityVersion = "Xcode 9.3";
+ developmentRegion = en;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ Base,
+ );
+ mainGroup = 33CC10E42044A3C60003C045;
+ productRefGroup = 33CC10EE2044A3C60003C045 /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 33CC10EC2044A3C60003C045 /* Runner */,
+ 33CC111A2044C6BA0003C045 /* Flutter Assemble */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 33CC10EB2044A3C60003C045 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */,
+ 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXShellScriptBuildPhase section */
+ 3399D490228B24CF009A79C7 /* ShellScript */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputFileListPaths = (
+ );
+ inputPaths = (
+ );
+ outputFileListPaths = (
+ );
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n";
+ };
+ 33CC111E2044C6BF0003C045 /* ShellScript */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputFileListPaths = (
+ Flutter/ephemeral/FlutterInputs.xcfilelist,
+ );
+ inputPaths = (
+ Flutter/ephemeral/tripwire,
+ );
+ outputFileListPaths = (
+ Flutter/ephemeral/FlutterOutputs.xcfilelist,
+ );
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire";
+ };
+/* End PBXShellScriptBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 33CC10E92044A3C60003C045 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */,
+ 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */,
+ 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXTargetDependency section */
+ 33CC11202044C79F0003C045 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */;
+ targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */;
+ };
+/* End PBXTargetDependency section */
+
+/* Begin PBXVariantGroup section */
+ 33CC10F42044A3C60003C045 /* MainMenu.xib */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 33CC10F52044A3C60003C045 /* Base */,
+ );
+ name = MainMenu.xib;
+ path = Runner;
+ sourceTree = "";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ 338D0CE9231458BD00FA5F75 /* Profile */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CODE_SIGN_IDENTITY = "-";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.11;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ SDKROOT = macosx;
+ SWIFT_COMPILATION_MODE = wholemodule;
+ SWIFT_OPTIMIZATION_LEVEL = "-O";
+ };
+ name = Profile;
+ };
+ 338D0CEA231458BD00FA5F75 /* Profile */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ CLANG_ENABLE_MODULES = YES;
+ CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
+ CODE_SIGN_STYLE = Automatic;
+ COMBINE_HIDPI_IMAGES = YES;
+ INFOPLIST_FILE = Runner/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = (
+ "$(inherited)",
+ "@executable_path/../Frameworks",
+ );
+ PROVISIONING_PROFILE_SPECIFIER = "";
+ SWIFT_VERSION = 5.0;
+ };
+ name = Profile;
+ };
+ 338D0CEB231458BD00FA5F75 /* Profile */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_STYLE = Manual;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Profile;
+ };
+ 33CC10F92044A3C60003C045 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CODE_SIGN_IDENTITY = "-";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = dwarf;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ ENABLE_TESTABILITY = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.11;
+ MTL_ENABLE_DEBUG_INFO = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = macosx;
+ SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+ };
+ name = Debug;
+ };
+ 33CC10FA2044A3C60003C045 /* Release */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CODE_SIGN_IDENTITY = "-";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.11;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ SDKROOT = macosx;
+ SWIFT_COMPILATION_MODE = wholemodule;
+ SWIFT_OPTIMIZATION_LEVEL = "-O";
+ };
+ name = Release;
+ };
+ 33CC10FC2044A3C60003C045 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ CLANG_ENABLE_MODULES = YES;
+ CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
+ CODE_SIGN_STYLE = Automatic;
+ COMBINE_HIDPI_IMAGES = YES;
+ INFOPLIST_FILE = Runner/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = (
+ "$(inherited)",
+ "@executable_path/../Frameworks",
+ );
+ PROVISIONING_PROFILE_SPECIFIER = "";
+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+ SWIFT_VERSION = 5.0;
+ };
+ name = Debug;
+ };
+ 33CC10FD2044A3C60003C045 /* Release */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ CLANG_ENABLE_MODULES = YES;
+ CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements;
+ CODE_SIGN_STYLE = Automatic;
+ COMBINE_HIDPI_IMAGES = YES;
+ INFOPLIST_FILE = Runner/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = (
+ "$(inherited)",
+ "@executable_path/../Frameworks",
+ );
+ PROVISIONING_PROFILE_SPECIFIER = "";
+ SWIFT_VERSION = 5.0;
+ };
+ name = Release;
+ };
+ 33CC111C2044C6BA0003C045 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_STYLE = Manual;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Debug;
+ };
+ 33CC111D2044C6BA0003C045 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_STYLE = Automatic;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 33CC10F92044A3C60003C045 /* Debug */,
+ 33CC10FA2044A3C60003C045 /* Release */,
+ 338D0CE9231458BD00FA5F75 /* Profile */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 33CC10FC2044A3C60003C045 /* Debug */,
+ 33CC10FD2044A3C60003C045 /* Release */,
+ 338D0CEA231458BD00FA5F75 /* Profile */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 33CC111C2044C6BA0003C045 /* Debug */,
+ 33CC111D2044C6BA0003C045 /* Release */,
+ 338D0CEB231458BD00FA5F75 /* Profile */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 33CC10E52044A3C60003C045 /* Project object */;
+}
diff --git a/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
new file mode 100644
index 0000000..ae8ff59
--- /dev/null
+++ b/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
@@ -0,0 +1,89 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/example/macos/Runner.xcworkspace/contents.xcworkspacedata b/example/macos/Runner.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..1d526a1
--- /dev/null
+++ b/example/macos/Runner.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/example/macos/Runner/AppDelegate.swift b/example/macos/Runner/AppDelegate.swift
new file mode 100644
index 0000000..d53ef64
--- /dev/null
+++ b/example/macos/Runner/AppDelegate.swift
@@ -0,0 +1,9 @@
+import Cocoa
+import FlutterMacOS
+
+@NSApplicationMain
+class AppDelegate: FlutterAppDelegate {
+ override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
+ return true
+ }
+}
diff --git a/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json
new file mode 100644
index 0000000..a2ec33f
--- /dev/null
+++ b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json
@@ -0,0 +1,68 @@
+{
+ "images" : [
+ {
+ "size" : "16x16",
+ "idiom" : "mac",
+ "filename" : "app_icon_16.png",
+ "scale" : "1x"
+ },
+ {
+ "size" : "16x16",
+ "idiom" : "mac",
+ "filename" : "app_icon_32.png",
+ "scale" : "2x"
+ },
+ {
+ "size" : "32x32",
+ "idiom" : "mac",
+ "filename" : "app_icon_32.png",
+ "scale" : "1x"
+ },
+ {
+ "size" : "32x32",
+ "idiom" : "mac",
+ "filename" : "app_icon_64.png",
+ "scale" : "2x"
+ },
+ {
+ "size" : "128x128",
+ "idiom" : "mac",
+ "filename" : "app_icon_128.png",
+ "scale" : "1x"
+ },
+ {
+ "size" : "128x128",
+ "idiom" : "mac",
+ "filename" : "app_icon_256.png",
+ "scale" : "2x"
+ },
+ {
+ "size" : "256x256",
+ "idiom" : "mac",
+ "filename" : "app_icon_256.png",
+ "scale" : "1x"
+ },
+ {
+ "size" : "256x256",
+ "idiom" : "mac",
+ "filename" : "app_icon_512.png",
+ "scale" : "2x"
+ },
+ {
+ "size" : "512x512",
+ "idiom" : "mac",
+ "filename" : "app_icon_512.png",
+ "scale" : "1x"
+ },
+ {
+ "size" : "512x512",
+ "idiom" : "mac",
+ "filename" : "app_icon_1024.png",
+ "scale" : "2x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
diff --git a/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png
new file mode 100644
index 0000000..3c4935a
Binary files /dev/null and b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png differ
diff --git a/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png
new file mode 100644
index 0000000..ed4cc16
Binary files /dev/null and b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png differ
diff --git a/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png
new file mode 100644
index 0000000..483be61
Binary files /dev/null and b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png differ
diff --git a/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png
new file mode 100644
index 0000000..bcbf36d
Binary files /dev/null and b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png differ
diff --git a/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png
new file mode 100644
index 0000000..9c0a652
Binary files /dev/null and b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png differ
diff --git a/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png
new file mode 100644
index 0000000..e71a726
Binary files /dev/null and b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png differ
diff --git a/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png
new file mode 100644
index 0000000..8a31fe2
Binary files /dev/null and b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png differ
diff --git a/example/macos/Runner/Base.lproj/MainMenu.xib b/example/macos/Runner/Base.lproj/MainMenu.xib
new file mode 100644
index 0000000..537341a
--- /dev/null
+++ b/example/macos/Runner/Base.lproj/MainMenu.xib
@@ -0,0 +1,339 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/example/macos/Runner/Configs/AppInfo.xcconfig b/example/macos/Runner/Configs/AppInfo.xcconfig
new file mode 100644
index 0000000..cf9be60
--- /dev/null
+++ b/example/macos/Runner/Configs/AppInfo.xcconfig
@@ -0,0 +1,14 @@
+// Application-level settings for the Runner target.
+//
+// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the
+// future. If not, the values below would default to using the project name when this becomes a
+// 'flutter create' template.
+
+// The application's name. By default this is also the title of the Flutter window.
+PRODUCT_NAME = example
+
+// The application's bundle identifier
+PRODUCT_BUNDLE_IDENTIFIER = com.example.example
+
+// The copyright displayed in application information
+PRODUCT_COPYRIGHT = Copyright © 2021 com.example. All rights reserved.
diff --git a/example/macos/Runner/Configs/Debug.xcconfig b/example/macos/Runner/Configs/Debug.xcconfig
new file mode 100644
index 0000000..36b0fd9
--- /dev/null
+++ b/example/macos/Runner/Configs/Debug.xcconfig
@@ -0,0 +1,2 @@
+#include "../../Flutter/Flutter-Debug.xcconfig"
+#include "Warnings.xcconfig"
diff --git a/example/macos/Runner/Configs/Release.xcconfig b/example/macos/Runner/Configs/Release.xcconfig
new file mode 100644
index 0000000..dff4f49
--- /dev/null
+++ b/example/macos/Runner/Configs/Release.xcconfig
@@ -0,0 +1,2 @@
+#include "../../Flutter/Flutter-Release.xcconfig"
+#include "Warnings.xcconfig"
diff --git a/example/macos/Runner/Configs/Warnings.xcconfig b/example/macos/Runner/Configs/Warnings.xcconfig
new file mode 100644
index 0000000..42bcbf4
--- /dev/null
+++ b/example/macos/Runner/Configs/Warnings.xcconfig
@@ -0,0 +1,13 @@
+WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings
+GCC_WARN_UNDECLARED_SELECTOR = YES
+CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES
+CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE
+CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
+CLANG_WARN_PRAGMA_PACK = YES
+CLANG_WARN_STRICT_PROTOTYPES = YES
+CLANG_WARN_COMMA = YES
+GCC_WARN_STRICT_SELECTOR_MATCH = YES
+CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
+CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
+GCC_WARN_SHADOW = YES
+CLANG_WARN_UNREACHABLE_CODE = YES
diff --git a/example/macos/Runner/DebugProfile.entitlements b/example/macos/Runner/DebugProfile.entitlements
new file mode 100644
index 0000000..dddb8a3
--- /dev/null
+++ b/example/macos/Runner/DebugProfile.entitlements
@@ -0,0 +1,12 @@
+
+
+
+
+ com.apple.security.app-sandbox
+
+ com.apple.security.cs.allow-jit
+
+ com.apple.security.network.server
+
+
+
diff --git a/example/macos/Runner/Info.plist b/example/macos/Runner/Info.plist
new file mode 100644
index 0000000..4789daa
--- /dev/null
+++ b/example/macos/Runner/Info.plist
@@ -0,0 +1,32 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ $(DEVELOPMENT_LANGUAGE)
+ CFBundleExecutable
+ $(EXECUTABLE_NAME)
+ CFBundleIconFile
+
+ CFBundleIdentifier
+ $(PRODUCT_BUNDLE_IDENTIFIER)
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ $(PRODUCT_NAME)
+ CFBundlePackageType
+ APPL
+ CFBundleShortVersionString
+ $(FLUTTER_BUILD_NAME)
+ CFBundleVersion
+ $(FLUTTER_BUILD_NUMBER)
+ LSMinimumSystemVersion
+ $(MACOSX_DEPLOYMENT_TARGET)
+ NSHumanReadableCopyright
+ $(PRODUCT_COPYRIGHT)
+ NSMainNibFile
+ MainMenu
+ NSPrincipalClass
+ NSApplication
+
+
diff --git a/example/macos/Runner/MainFlutterWindow.swift b/example/macos/Runner/MainFlutterWindow.swift
new file mode 100644
index 0000000..2722837
--- /dev/null
+++ b/example/macos/Runner/MainFlutterWindow.swift
@@ -0,0 +1,15 @@
+import Cocoa
+import FlutterMacOS
+
+class MainFlutterWindow: NSWindow {
+ override func awakeFromNib() {
+ let flutterViewController = FlutterViewController.init()
+ let windowFrame = self.frame
+ self.contentViewController = flutterViewController
+ self.setFrame(windowFrame, display: true)
+
+ RegisterGeneratedPlugins(registry: flutterViewController)
+
+ super.awakeFromNib()
+ }
+}
diff --git a/example/macos/Runner/Release.entitlements b/example/macos/Runner/Release.entitlements
new file mode 100644
index 0000000..852fa1a
--- /dev/null
+++ b/example/macos/Runner/Release.entitlements
@@ -0,0 +1,8 @@
+
+
+
+
+ com.apple.security.app-sandbox
+
+
+
diff --git a/example/pubspec.lock b/example/pubspec.lock
index c9c9dcc..4dad320 100644
--- a/example/pubspec.lock
+++ b/example/pubspec.lock
@@ -1,76 +1,61 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
- archive:
- dependency: transitive
- description:
- name: archive
- url: "https://pub.dartlang.org"
- source: hosted
- version: "2.0.11"
- args:
- dependency: transitive
- description:
- name: args
- url: "https://pub.dartlang.org"
- source: hosted
- version: "1.5.2"
async:
dependency: transitive
description:
name: async
- url: "https://pub.dartlang.org"
+ sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
+ url: "https://pub.dev"
source: hosted
- version: "2.4.0"
+ version: "2.11.0"
barcode_flutter:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
- version: "1.1.2"
+ version: "2.0.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
- url: "https://pub.dartlang.org"
+ sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
+ url: "https://pub.dev"
source: hosted
- version: "1.0.5"
- charcode:
+ version: "2.1.1"
+ characters:
dependency: transitive
description:
- name: charcode
- url: "https://pub.dartlang.org"
+ name: characters
+ sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
+ url: "https://pub.dev"
source: hosted
- version: "1.1.2"
- collection:
+ version: "1.3.0"
+ clock:
dependency: transitive
description:
- name: collection
- url: "https://pub.dartlang.org"
+ name: clock
+ sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
+ url: "https://pub.dev"
source: hosted
- version: "1.14.11"
- convert:
+ version: "1.1.1"
+ collection:
dependency: transitive
description:
- name: convert
- url: "https://pub.dartlang.org"
+ name: collection
+ sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
+ url: "https://pub.dev"
source: hosted
- version: "2.1.1"
- crypto:
+ version: "1.17.1"
+ fake_async:
dependency: transitive
description:
- name: crypto
- url: "https://pub.dartlang.org"
- source: hosted
- version: "2.1.3"
- cupertino_icons:
- dependency: "direct main"
- description:
- name: cupertino_icons
- url: "https://pub.dartlang.org"
+ name: fake_async
+ sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
+ url: "https://pub.dev"
source: hosted
- version: "0.1.2"
+ version: "1.3.1"
flutter:
dependency: "direct main"
description: flutter
@@ -81,55 +66,54 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
- image:
+ js:
dependency: transitive
description:
- name: image
- url: "https://pub.dartlang.org"
+ name: js
+ sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
+ url: "https://pub.dev"
source: hosted
- version: "2.1.4"
+ version: "0.6.7"
+ lints:
+ dependency: "direct dev"
+ description:
+ name: lints
+ sha256: "6b0206b0bf4f04961fc5438198ccb3a885685cd67d4d4a32cc20ad7f8adbe015"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.1.0"
matcher:
dependency: transitive
description:
name: matcher
- url: "https://pub.dartlang.org"
+ sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
+ url: "https://pub.dev"
source: hosted
- version: "0.12.6"
+ version: "0.12.15"
+ material_color_utilities:
+ dependency: transitive
+ description:
+ name: material_color_utilities
+ sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.2.0"
meta:
dependency: transitive
description:
name: meta
- url: "https://pub.dartlang.org"
+ sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
+ url: "https://pub.dev"
source: hosted
- version: "1.1.8"
+ version: "1.9.1"
path:
dependency: transitive
description:
name: path
- url: "https://pub.dartlang.org"
- source: hosted
- version: "1.6.4"
- pedantic:
- dependency: transitive
- description:
- name: pedantic
- url: "https://pub.dartlang.org"
- source: hosted
- version: "1.8.0+1"
- petitparser:
- dependency: transitive
- description:
- name: petitparser
- url: "https://pub.dartlang.org"
- source: hosted
- version: "2.4.0"
- quiver:
- dependency: transitive
- description:
- name: quiver
- url: "https://pub.dartlang.org"
+ sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
+ url: "https://pub.dev"
source: hosted
- version: "2.0.5"
+ version: "1.8.3"
sky_engine:
dependency: transitive
description: flutter
@@ -139,64 +123,57 @@ packages:
dependency: transitive
description:
name: source_span
- url: "https://pub.dartlang.org"
+ sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
+ url: "https://pub.dev"
source: hosted
- version: "1.5.5"
+ version: "1.9.1"
stack_trace:
dependency: transitive
description:
name: stack_trace
- url: "https://pub.dartlang.org"
+ sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
+ url: "https://pub.dev"
source: hosted
- version: "1.9.3"
+ version: "1.11.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
- url: "https://pub.dartlang.org"
+ sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
+ url: "https://pub.dev"
source: hosted
- version: "2.0.0"
+ version: "2.1.1"
string_scanner:
dependency: transitive
description:
name: string_scanner
- url: "https://pub.dartlang.org"
+ sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
+ url: "https://pub.dev"
source: hosted
- version: "1.0.5"
+ version: "1.2.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
- url: "https://pub.dartlang.org"
+ sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
+ url: "https://pub.dev"
source: hosted
- version: "1.1.0"
+ version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
- url: "https://pub.dartlang.org"
- source: hosted
- version: "0.2.11"
- typed_data:
- dependency: transitive
- description:
- name: typed_data
- url: "https://pub.dartlang.org"
+ sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
+ url: "https://pub.dev"
source: hosted
- version: "1.1.6"
+ version: "0.5.1"
vector_math:
dependency: transitive
description:
name: vector_math
- url: "https://pub.dartlang.org"
+ sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
+ url: "https://pub.dev"
source: hosted
- version: "2.0.8"
- xml:
- dependency: transitive
- description:
- name: xml
- url: "https://pub.dartlang.org"
- source: hosted
- version: "3.5.0"
+ version: "2.1.4"
sdks:
- dart: ">=2.4.0 <3.0.0"
+ dart: ">=3.0.0 <4.0.0"
diff --git a/example/pubspec.yaml b/example/pubspec.yaml
index d7ae2ae..3945727 100644
--- a/example/pubspec.yaml
+++ b/example/pubspec.yaml
@@ -1,59 +1,16 @@
name: barcode_flutter_demo
description: Demo project for the Flutter Barcode library.
+environment:
+ sdk: ">=3.0.0 <4.0.0"
+
dependencies:
- flutter:
- sdk: flutter
barcode_flutter:
path: ..
-
- # The following adds the Cupertino Icons font to your application.
- # Use with the CupertinoIcons class for iOS style icons.
- cupertino_icons: ^0.1.2
+ flutter:
+ sdk: flutter
dev_dependencies:
flutter_test:
sdk: flutter
-
-
-# For information on the generic Dart part of this file, see the
-# following page: https://www.dartlang.org/tools/pub/pubspec
-
-# The following section is specific to Flutter.
-flutter:
-
- # The following line ensures that the Material Icons font is
- # included with your application, so that you can use the icons in
- # the material Icons class.
- uses-material-design: true
-
- # To add assets to your application, add an assets section, like this:
- # assets:
- # - images/a_dot_burr.jpeg
- # - images/a_dot_ham.jpeg
-
- # An image asset can refer to one or more resolution-specific "variants", see
- # https://flutter.io/assets-and-images/#resolution-aware.
-
- # For details regarding adding assets from package dependencies, see
- # https://flutter.io/assets-and-images/#from-packages
-
- # To add custom fonts to your application, add a fonts section here,
- # in this "flutter" section. Each entry in this list should have a
- # "family" key with the font family name, and a "fonts" key with a
- # list giving the asset and other descriptors for the font. For
- # example:
- # fonts:
- # - family: Schyler
- # fonts:
- # - asset: fonts/Schyler-Regular.ttf
- # - asset: fonts/Schyler-Italic.ttf
- # style: italic
- # - family: Trajan Pro
- # fonts:
- # - asset: fonts/TrajanPro.ttf
- # - asset: fonts/TrajanPro_Bold.ttf
- # weight: 700
- #
- # For details regarding fonts from package dependencies,
- # see https://flutter.io/custom-fonts/#from-packages
+ lints: ^2.0.1
diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart
index 3ab9489..cd26b10 100644
--- a/example/test/widget_test.dart
+++ b/example/test/widget_test.dart
@@ -1,29 +1,10 @@
-// This is a basic Flutter widget test.
-// To perform an interaction with a widget in your test, use the WidgetTester utility that Flutter
-// provides. For example, you can send tap and scroll gestures. You can also use WidgetTester to
-// find child widgets in the widget tree, read text, and verify that the values of widget properties
-// are correct.
-
-import 'package:flutter/material.dart';
-import 'package:flutter_test/flutter_test.dart';
-
-import 'package:barcode_flutter_demo/main.dart';
-
-void main() {
- testWidgets('Counter increments smoke test', (WidgetTester tester) async {
- // Build our app and trigger a frame.
- await tester.pumpWidget(new MyApp());
-
- // Verify that our counter starts at 0.
- expect(find.text('0'), findsOneWidget);
- expect(find.text('1'), findsNothing);
-
- // Tap the '+' icon and trigger a frame.
- await tester.tap(find.byIcon(Icons.add));
- await tester.pump();
-
- // Verify that our counter has incremented.
- expect(find.text('0'), findsNothing);
- expect(find.text('1'), findsOneWidget);
- });
-}
+/// This is a basic Flutter widget test.
+/// To perform an interaction with a widget in your test, use the WidgetTester utility that Flutter
+/// provides. For example, you can send tap and scroll gestures. You can also use WidgetTester to
+/// find child widgets in the widget tree, read text, and verify that the values of widget properties
+/// are correct.
+library barcode_flutter_example_tests;
+
+///
+///
+void main() {}
diff --git a/example/web/favicon.png b/example/web/favicon.png
new file mode 100644
index 0000000..8aaa46a
Binary files /dev/null and b/example/web/favicon.png differ
diff --git a/example/web/icons/Icon-192.png b/example/web/icons/Icon-192.png
new file mode 100644
index 0000000..b749bfe
Binary files /dev/null and b/example/web/icons/Icon-192.png differ
diff --git a/example/web/icons/Icon-512.png b/example/web/icons/Icon-512.png
new file mode 100644
index 0000000..88cfd48
Binary files /dev/null and b/example/web/icons/Icon-512.png differ
diff --git a/example/web/index.html b/example/web/index.html
new file mode 100644
index 0000000..0081e18
--- /dev/null
+++ b/example/web/index.html
@@ -0,0 +1,98 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ example
+
+
+
+
+
+
+
diff --git a/example/web/manifest.json b/example/web/manifest.json
new file mode 100644
index 0000000..8c01291
--- /dev/null
+++ b/example/web/manifest.json
@@ -0,0 +1,23 @@
+{
+ "name": "example",
+ "short_name": "example",
+ "start_url": ".",
+ "display": "standalone",
+ "background_color": "#0175C2",
+ "theme_color": "#0175C2",
+ "description": "A new Flutter project.",
+ "orientation": "portrait-primary",
+ "prefer_related_applications": false,
+ "icons": [
+ {
+ "src": "icons/Icon-192.png",
+ "sizes": "192x192",
+ "type": "image/png"
+ },
+ {
+ "src": "icons/Icon-512.png",
+ "sizes": "512x512",
+ "type": "image/png"
+ }
+ ]
+}
diff --git a/lib/barcode_flutter.dart b/lib/barcode_flutter.dart
index 2ea9b9b..cd2f355 100644
--- a/lib/barcode_flutter.dart
+++ b/lib/barcode_flutter.dart
@@ -1,10 +1,11 @@
-/*
- * Flutter BarCode generator
- * Copyright (c) 2018 the BarCode Flutter authors.
- * See LICENSE for distribution and usage details.
- */
+///
+/// Flutter BarCode generator
+/// Copyright (c) 2018 the BarCode Flutter authors.
+/// See LICENSE for distribution and usage details.
+///
+library barcode_flutter;
-export 'src/barcode_params.dart';
+export 'src/barcode_enum.dart';
export 'src/barcode_image.dart';
export 'src/barcode_painter.dart';
-export 'src/barcode_enum.dart';
+export 'src/barcode_params.dart';
diff --git a/lib/src/barcode_enum.dart b/lib/src/barcode_enum.dart
index 9d83792..1e8caf5 100644
--- a/lib/src/barcode_enum.dart
+++ b/lib/src/barcode_enum.dart
@@ -1,9 +1,13 @@
-/*
- * Flutter BarCode Widget
- * Copyright (c) 2018 the BarCode Flutter authors.
- * See LICENSE for distribution and usage details.
- */
+///
+/// Flutter BarCode Widget
+/// Copyright (c) 2018 the BarCode Flutter authors.
+/// See LICENSE for distribution and usage details.
+///
+// ignore_for_file: constant_identifier_names
+library barcode_flutter_enum;
+
+///
enum BarCodeType {
CodeEAN13,
CodeEAN8,
diff --git a/lib/src/barcode_image.dart b/lib/src/barcode_image.dart
index 35101b7..d0b7586 100644
--- a/lib/src/barcode_image.dart
+++ b/lib/src/barcode_image.dart
@@ -1,14 +1,14 @@
-/*
- * Flutter BarCode generator
- * Copyright (c) 2018 the BarCode Flutter authors.
- * See LICENSE for distribution and usage details.
- */
+///
+/// Flutter BarCode generator
+/// Copyright (c) 2018 the BarCode Flutter authors.
+/// See LICENSE for distribution and usage details.
+///
+// ignore_for_file: provide_deprecation_message
+
+library barcode_flutter_image;
import 'package:barcode_flutter/barcode_flutter.dart';
-import 'package:barcode_flutter/src/barcode_enum.dart';
import 'package:flutter/widgets.dart';
-import 'barcode_painter.dart';
-import 'barcode_params.dart';
/// A barcode custom painter
///
@@ -33,77 +33,128 @@ import 'barcode_params.dart';
/// )
/// )
/// ```
-class BarCodeImage extends StatelessWidget {
+class BarCodeImage extends StatelessWidget {
+ ///
+ ///
BarCodeImage({
+ super.key,
@deprecated this.data,
@deprecated this.codeType,
@deprecated this.lineWidth = 2.0,
@deprecated this.barHeight = 100.0,
@deprecated this.hasText = false,
- BarCodeParams params,
+ BarCodeParams? params,
this.padding,
this.backgroundColor,
Color foregroundColor = const Color(0xFF000000),
this.onError,
- }) : assert(params != null || (data != null && codeType != null), "params or data+codeType must be set"),
+ }) : assert(
+ params != null || (data != null && codeType != null),
+ 'params or data+codeType must be set',
+ ),
assert(
- (params != null && data == null && codeType == null) ||
- (params == null && data != null && codeType != null),
- "params and data+codeType cannot be set at the same time"),
+ (params != null && data == null && codeType == null) ||
+ (params == null && data != null && codeType != null),
+ 'params and data+codeType cannot be set at the same time',
+ ),
_painter = BarCodePainter(
- params ?? _getBarcodeParams(codeType, data, lineWidth, barHeight, hasText), foregroundColor,
+ params ??
+ _getBarcodeParams(
+ codeType,
+ data,
+ lineWidth,
+ barHeight,
+ hasText,
+ ),
+ foregroundColor,
onError: onError);
/// deprecated params
- final String data;
- final BarCodeType codeType;
+ final String? data;
+
+ ///
+ final BarCodeType? codeType;
+
+ ///
final double lineWidth;
+
+ ///
final double barHeight;
+
+ ///
final bool hasText;
- T get params => _painter.params;
+ ///
+ T? get params => _painter.params as T?;
+ ///
final BarCodePainter _painter;
- final Color backgroundColor;
- final EdgeInsets padding;
- final BarCodeError onError;
+ ///
+ final Color? backgroundColor;
+
+ ///
+ final EdgeInsets? padding;
- static BarCodeParams _getBarcodeParams(
- BarCodeType type, String data, double lineWidth, double barHeight, bool hasText) {
+ ///
+ final BarCodeError? onError;
+
+ ///
+ ///
+ static BarCodeParams? _getBarcodeParams(BarCodeType? type, String? data,
+ double lineWidth, double barHeight, bool hasText) {
switch (type) {
+ //
case BarCodeType.CodeEAN13:
- return EAN13BarCodeParams(data, withText: hasText, lineWidth: lineWidth, barHeight: barHeight);
+ return EAN13BarCodeParams(data!,
+ withText: hasText, lineWidth: lineWidth, barHeight: barHeight);
+ //
case BarCodeType.CodeEAN8:
- return EAN8BarCodeParams(data, withText: hasText, lineWidth: lineWidth, barHeight: barHeight);
+ return EAN8BarCodeParams(data!,
+ withText: hasText, lineWidth: lineWidth, barHeight: barHeight);
+ //
case BarCodeType.Code39:
- return Code39BarCodeParams(data, withText: hasText, lineWidth: lineWidth, barHeight: barHeight);
+ return Code39BarCodeParams(data!,
+ withText: hasText, lineWidth: lineWidth, barHeight: barHeight);
+ //
case BarCodeType.Code93:
- return Code93BarCodeParams(data, withText: hasText, lineWidth: lineWidth, barHeight: barHeight);
+ return Code93BarCodeParams(data!,
+ withText: hasText, lineWidth: lineWidth, barHeight: barHeight);
+ //
case BarCodeType.CodeUPCA:
- return UPCABarCodeParams(data, withText: hasText, lineWidth: lineWidth, barHeight: barHeight);
+ return UPCABarCodeParams(data!,
+ withText: hasText, lineWidth: lineWidth, barHeight: barHeight);
+ //
case BarCodeType.CodeUPCE:
- return UPCEBarCodeParams(data, withText: hasText, lineWidth: lineWidth, barHeight: barHeight);
+ return UPCEBarCodeParams(data!,
+ withText: hasText, lineWidth: lineWidth, barHeight: barHeight);
+ //
case BarCodeType.Code128:
- return Code128BarCodeParams(data, withText: hasText, lineWidth: lineWidth, barHeight: barHeight);
+ return Code128BarCodeParams(data!,
+ withText: hasText, lineWidth: lineWidth, barHeight: barHeight);
+ //
case BarCodeType.Codabar:
- return CodabarBarCodeParams(data, withText: hasText, lineWidth: lineWidth, barHeight: barHeight);
+ return CodabarBarCodeParams(data!,
+ withText: hasText, lineWidth: lineWidth, barHeight: barHeight);
+ //
+ default:
+ return null;
}
- return null;
}
@override
- Widget build(BuildContext context) {
- return Container(
- width: params.barCodeWidth + (padding?.left ?? 0) + (padding?.right ?? 0),
- height: params.barHeight + (padding?.top ?? 0) + (padding?.bottom ?? 0),
- decoration: BoxDecoration(
- color: backgroundColor,
- ),
- padding: padding,
- child: CustomPaint(
- painter: _painter,
- ),
- );
- }
+ Widget build(BuildContext context) => Container(
+ //
+ width: params!.barCodeWidth + //
+ (padding?.left ?? 0) +
+ (padding?.right ?? 0),
+ //
+ height: params!.barHeight + //
+ (padding?.top ?? 0) +
+ (padding?.bottom ?? 0),
+ //
+ padding: padding,
+ decoration: BoxDecoration(color: backgroundColor),
+ child: CustomPaint(painter: _painter),
+ );
}
diff --git a/lib/src/barcode_painter.dart b/lib/src/barcode_painter.dart
index f13346a..60b572b 100644
--- a/lib/src/barcode_painter.dart
+++ b/lib/src/barcode_painter.dart
@@ -1,21 +1,36 @@
-/*
- * Flutter BarCode generator
- * Copyright (c) 2018 the BarCode Flutter authors.
- * See LICENSE for distribution and usage details.
- */
+///
+/// Flutter BarCode generator
+/// Copyright (c) 2018 the BarCode Flutter authors.
+/// See LICENSE for distribution and usage details.
+///
+// ignore_for_file: avoid_print
+
+library barcode_flutter_painter;
+
+import 'dart:typed_data';
import 'package:barcode_flutter/barcode_flutter.dart';
import 'package:flutter/material.dart';
-import 'dart:typed_data';
-typedef void BarCodeError(dynamic error);
+///
+///
+typedef BarCodeError = void Function(dynamic error);
+///
+///
+///
class BarCodePainter extends CustomPainter {
+ ///
BarCodePainter(this.params, this.color, {this.onError});
- final BarCodeParams params;
+ ///
+ final BarCodeParams? params;
+
+ ///
final Color color;
- final BarCodeError onError;
+
+ ///
+ final BarCodeError? onError;
@override
void paint(Canvas canvas, Size size) {
@@ -23,281 +38,153 @@ class BarCodePainter extends CustomPainter {
if (params is Code39BarCodeParams) {
_drawBarCode39(canvas, size);
- } else if (params is Code93BarCodeParams) {
+ }
+ //
+ else if (params is Code93BarCodeParams) {
_drawBarCode93(canvas, size);
- } else if (params is Code128BarCodeParams) {
+ }
+ //
+ else if (params is Code128BarCodeParams) {
_drawBarCode128(canvas, size);
- } else if (params is EAN13BarCodeParams) {
+ }
+ //
+ else if (params is EAN13BarCodeParams) {
_drawBarCodeEAN13(canvas, size);
- } else if (params is EAN8BarCodeParams) {
+ }
+ //
+ else if (params is EAN8BarCodeParams) {
_drawBarCodeEAN8(canvas, size);
- } else if (params is UPCABarCodeParams) {
+ }
+ //
+ else if (params is UPCABarCodeParams) {
_drawBarCodeUPCA(canvas, size);
- } else if (params is UPCEBarCodeParams) {
+ }
+ //
+ else if (params is UPCEBarCodeParams) {
_drawBarCodeUPCE(canvas, size);
- } else if (params is ITFBarCodeParams) {
+ }
+ //
+ else if (params is ITFBarCodeParams) {
_drawBarCodeITF(canvas, size);
- } else if (params is CodabarBarCodeParams) {
+ }
+ //
+ else if (params is CodabarBarCodeParams) {
_drawBarCodeCodabar(canvas, size);
}
}
@override
- bool shouldRepaint(CustomPainter oldDelegate) {
- return false;
- }
+ bool shouldRepaint(CustomPainter oldDelegate) => false;
+ ///
+ ///
void _drawBarCode39(Canvas canvas, Size size) {
- final List binSet = [
- 0xa6d,
- 0xd2b,
- 0xb2b,
- 0xd95,
- 0xa6b,
- 0xd35,
- 0xb35,
- 0xa5b,
- 0xd2d,
- 0xb2d,
- 0xd4b,
- 0xb4b,
- 0xda5,
- 0xacb,
- 0xd65,
- 0xb65,
- 0xa9b,
- 0xd4d,
- 0xb4d,
- 0xacd,
- 0xd53,
- 0xb53,
- 0xda9,
- 0xad3,
- 0xd69,
- 0xb69,
- 0xab3,
- 0xd59,
- 0xb59,
- 0xad9,
- 0xcab,
- 0x9ab,
- 0xcd5,
- 0x96b,
- 0xcb5,
- 0x9b5,
- 0x95b,
- 0xcad,
- 0x9ad,
- 0x925,
- 0x929,
- 0x949,
- 0xa49,
- 0x96d
+ const binSet = [
+ ...[0xa6d, 0xd2b, 0xb2b, 0xd95, 0xa6b, 0xd35, 0xb35, 0xa5b, 0xd2d, 0xb2d],
+ ...[0xd4b, 0xb4b, 0xda5, 0xacb, 0xd65, 0xb65, 0xa9b, 0xd4d, 0xb4d, 0xacd],
+ ...[0xd53, 0xb53, 0xda9, 0xad3, 0xd69, 0xb69, 0xab3, 0xd59, 0xb59, 0xad9],
+ ...[0xcab, 0x9ab, 0xcd5, 0x96b, 0xcb5, 0x9b5, 0x95b, 0xcad, 0x9ad, 0x925],
+ ...[0x929, 0x949, 0xa49, 0x96d]
];
- final data = params.data;
- final lineWidth = params.lineWidth;
- final hasText = params.withText;
+ const patterns = {
+ ...{'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7},
+ ...{'8': 8, '9': 9, 'A': 10, 'B': 11, 'C': 12, 'D': 13, 'E': 14},
+ ...{'F': 15, 'G': 16, 'H': 17, 'I': 18, 'J': 19, 'K': 20, 'L': 21},
+ ...{'M': 22, 'N': 23, 'O': 24, 'P': 25, 'Q': 26, 'R': 27, 'S': 28},
+ ...{'T': 29, 'U': 30, 'V': 31, 'W': 32, 'X': 33, 'Y': 34, 'Z': 35},
+ ...{'-': 36, '.': 37, ' ': 38, '\$': 39, '/': 40, '+': 41, '%': 42},
+ };
+
+ final data = params!.data;
+ final lineWidth = params!.lineWidth;
+ final hasText = params!.withText;
int codeValue = 0;
bool hasError = false;
- final painter = new Paint()..style = PaintingStyle.fill;
- double height = hasText ? size.height * 0.85 : size.height;
+ final painter = Paint()..style = PaintingStyle.fill;
+ final height = hasText ? size.height * 0.85 : size.height;
for (int i = 0; i < data.length; i++) {
- switch (data[i]) {
- case '0':
- codeValue = 0;
- break;
- case '1':
- codeValue = 1;
- break;
- case '2':
- codeValue = 2;
- break;
- case '3':
- codeValue = 3;
- break;
- case '4':
- codeValue = 4;
- break;
- case '5':
- codeValue = 5;
- break;
- case '6':
- codeValue = 6;
- break;
- case '7':
- codeValue = 7;
- break;
- case '8':
- codeValue = 8;
- break;
- case '9':
- codeValue = 9;
- break;
- case 'A':
- codeValue = 10;
- break;
- case 'B':
- codeValue = 11;
- break;
- case 'C':
- codeValue = 12;
- break;
- case 'D':
- codeValue = 13;
- break;
- case 'E':
- codeValue = 14;
- break;
- case 'F':
- codeValue = 15;
- break;
- case 'G':
- codeValue = 16;
- break;
- case 'H':
- codeValue = 17;
- break;
- case 'I':
- codeValue = 18;
- break;
- case 'J':
- codeValue = 19;
- break;
- case 'K':
- codeValue = 20;
- break;
- case 'L':
- codeValue = 21;
- break;
- case 'M':
- codeValue = 22;
- break;
- case 'N':
- codeValue = 23;
- break;
- case 'O':
- codeValue = 24;
- break;
- case 'P':
- codeValue = 25;
- break;
- case 'Q':
- codeValue = 26;
- break;
- case 'R':
- codeValue = 27;
- break;
- case 'S':
- codeValue = 28;
- break;
- case 'T':
- codeValue = 29;
- break;
- case 'U':
- codeValue = 30;
- break;
- case 'V':
- codeValue = 31;
- break;
- case 'W':
- codeValue = 32;
- break;
- case 'X':
- codeValue = 33;
- break;
- case 'Y':
- codeValue = 34;
- break;
- case 'Z':
- codeValue = 35;
- break;
- case '-':
- codeValue = 36;
- break;
- case '.':
- codeValue = 37;
- break;
- case ' ':
- codeValue = 38;
- break;
- case '\$':
- codeValue = 39;
- break;
- case '/':
- codeValue = 40;
- break;
- case '+':
- codeValue = 41;
- break;
- case '%':
- codeValue = 42;
- break;
- default:
- codeValue = 0;
- hasError = true;
- break;
+ codeValue = patterns[data[i]] ?? 0;
+
+ if (codeValue == 0) {
+ hasError = true;
}
if (hasError) {
- String errorMsg =
- "Invalid content for Code39. Please check https://en.wikipedia.org/wiki/Code_39 for reference.";
- if (this.onError != null) {
- this.onError(errorMsg);
- } else {
+ const errorMsg = 'Invalid content for Code39. Please check '
+ 'https://en.wikipedia.org/wiki/Code_39 for reference.';
+
+ if (onError != null) {
+ onError!(errorMsg);
+ }
+ //
+ else {
print(errorMsg);
}
+
return;
}
for (int j = 0; j < 12; j++) {
- Rect rect = new Rect.fromLTWH(
- 13 * lineWidth + 13 * i * lineWidth + j * lineWidth,
- 0.0,
- lineWidth,
- height);
+ final rect = Rect.fromLTWH(
+ 13 * lineWidth + 13 * i * lineWidth + j * lineWidth,
+ 0.0,
+ lineWidth,
+ height,
+ );
+
((0x800 & (binSet[codeValue] << j)) == 0x800)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
}
for (int i = 0; i < 12; i++) {
- Rect rect = new Rect.fromLTWH(i * lineWidth, 0.0, lineWidth, height);
+ final rect = Rect.fromLTWH(i * lineWidth, 0.0, lineWidth, height);
+
((0x800 & (binSet[43] << i)) == 0x800)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
for (int i = 0; i < 12; i++) {
- Rect rect = new Rect.fromLTWH(
- (13 + i) * lineWidth + 13 * (data.length) * lineWidth,
- 0.0,
- lineWidth,
- height);
+ final rect = Rect.fromLTWH(
+ (13 + i) * lineWidth + 13 * (data.length) * lineWidth,
+ 0.0,
+ lineWidth,
+ height,
+ );
+
((0x800 & (binSet[43] << i)) == 0x800)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
if (hasText) {
for (int i = 0; i < data.length; i++) {
- TextSpan span = new TextSpan(
- style: new TextStyle(color: Colors.black, fontSize: 15.0),
- text: data[i]);
- TextPainter textPainter = new TextPainter(
- text: span,
- textAlign: TextAlign.left,
- textDirection: TextDirection.ltr);
+ final span = TextSpan(
+ style: const TextStyle(color: Colors.black, fontSize: 15.0),
+ text: data[i],
+ );
+
+ final textPainter = TextPainter(
+ text: span,
+ textAlign: TextAlign.left,
+ textDirection: TextDirection.ltr,
+ );
+
textPainter.layout();
textPainter.paint(
canvas,
- new Offset(
+ Offset(
(size.width - data.length * 13 * lineWidth) / 2 +
13 * i * lineWidth,
height));
@@ -305,222 +192,66 @@ class BarCodePainter extends CustomPainter {
}
}
+ ///
+ ///
void _drawBarCode93(Canvas canvas, Size size) {
- List binSet = [
- 0x8a,
- 0xa4,
- 0xa2,
- 0xa1,
- 0x94,
- 0x92,
- 0x91,
- 0xa8,
- 0x89,
- 0x85,
- 0xd4,
- 0xd2,
- 0xd1,
- 0xca,
- 0xc9,
- 0xc5,
- 0xb4,
- 0xb2,
- 0xb1,
- 0x9a,
- 0x8d,
- 0xac,
- 0xa6,
- 0xa3,
- 0x96,
- 0x8b,
- 0xda,
- 0xd9,
- 0xd6,
- 0xd3,
- 0xcb,
- 0xcd,
- 0xb6,
- 0xb3,
- 0x9b,
- 0x9d,
- 0x97,
- 0xea,
- 0xe9,
- 0xe5,
- 0xb7,
- 0xbb,
- 0xd7,
- 0x93,
- 0xed,
- 0xeb,
- 0x99,
- 0xaf
+ const binSet = [
+ ...[0x8a, 0xa4, 0xa2, 0xa1, 0x94, 0x92, 0x91, 0xa8, 0x89, 0x85, 0xd4],
+ ...[0xd2, 0xd1, 0xca, 0xc9, 0xc5, 0xb4, 0xb2, 0xb1, 0x9a, 0x8d, 0xac],
+ ...[0xa6, 0xa3, 0x96, 0x8b, 0xda, 0xd9, 0xd6, 0xd3, 0xcb, 0xcd, 0xb6],
+ ...[0xb3, 0x9b, 0x9d, 0x97, 0xea, 0xe9, 0xe5, 0xb7, 0xbb, 0xd7, 0x93],
+ ...[0xed, 0xeb, 0x99, 0xaf]
];
- final data = params.data;
- final lineWidth = params.lineWidth;
- final hasText = params.withText;
+ const patterns = {
+ ...{'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7},
+ ...{'8': 8, '9': 9, 'A': 10, 'B': 11, 'C': 12, 'D': 13, 'E': 14},
+ ...{'F': 15, 'G': 16, 'H': 17, 'I': 18, 'J': 19, 'K': 20, 'L': 21},
+ ...{'M': 22, 'N': 23, 'O': 24, 'P': 25, 'Q': 26, 'R': 27, 'S': 28},
+ ...{'T': 29, 'U': 30, 'V': 31, 'W': 32, 'X': 33, 'Y': 34, 'Z': 35},
+ ...{'-': 36, '.': 37, ' ': 38, '\$': 39, '/': 40, '+': 41, '%': 42},
+ };
+
+ final data = params!.data;
+ final lineWidth = params!.lineWidth;
+ final hasText = params!.withText;
int codeValue = 0, checkCodeC, checkCodeK;
int sumC = 0, sumK = 0;
bool hasError = false;
- ByteData strValue = new ByteData(data.length);
- final painter = new Paint()..style = PaintingStyle.fill;
- double height = hasText ? size.height * 0.85 : size.height;
+ final strValue = ByteData(data.length);
+ final painter = Paint()..style = PaintingStyle.fill;
+ final height = hasText ? size.height * 0.85 : size.height;
for (int i = 0; i < 8; i++) {
- Rect rect = new Rect.fromLTWH(i * lineWidth, 0.0, lineWidth, height);
+ final rect = Rect.fromLTWH(i * lineWidth, 0.0, lineWidth, height);
+
((0x80 & (binSet[47] << i)) == 0x80)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
for (int i = 0; i < data.length; i++) {
- switch (data[i]) {
- case '0':
- codeValue = 0;
- break;
- case '1':
- codeValue = 1;
- break;
- case '2':
- codeValue = 2;
- break;
- case '3':
- codeValue = 3;
- break;
- case '4':
- codeValue = 4;
- break;
- case '5':
- codeValue = 5;
- break;
- case '6':
- codeValue = 6;
- break;
- case '7':
- codeValue = 7;
- break;
- case '8':
- codeValue = 8;
- break;
- case '9':
- codeValue = 9;
- break;
- case 'A':
- codeValue = 10;
- break;
- case 'B':
- codeValue = 11;
- break;
- case 'C':
- codeValue = 12;
- break;
- case 'D':
- codeValue = 13;
- break;
- case 'E':
- codeValue = 14;
- break;
- case 'F':
- codeValue = 15;
- break;
- case 'G':
- codeValue = 16;
- break;
- case 'H':
- codeValue = 17;
- break;
- case 'I':
- codeValue = 18;
- break;
- case 'J':
- codeValue = 19;
- break;
- case 'K':
- codeValue = 20;
- break;
- case 'L':
- codeValue = 21;
- break;
- case 'M':
- codeValue = 22;
- break;
- case 'N':
- codeValue = 23;
- break;
- case 'O':
- codeValue = 24;
- break;
- case 'P':
- codeValue = 25;
- break;
- case 'Q':
- codeValue = 26;
- break;
- case 'R':
- codeValue = 27;
- break;
- case 'S':
- codeValue = 28;
- break;
- case 'T':
- codeValue = 29;
- break;
- case 'U':
- codeValue = 30;
- break;
- case 'V':
- codeValue = 31;
- break;
- case 'W':
- codeValue = 32;
- break;
- case 'X':
- codeValue = 33;
- break;
- case 'Y':
- codeValue = 34;
- break;
- case 'Z':
- codeValue = 35;
- break;
- case '-':
- codeValue = 36;
- break;
- case '.':
- codeValue = 37;
- break;
- case ' ':
- codeValue = 38;
- break;
- case '\$':
- codeValue = 39;
- break;
- case '/':
- codeValue = 40;
- break;
- case '+':
- codeValue = 41;
- break;
- case '%':
- codeValue = 42;
- break;
- default:
- codeValue = 0;
- hasError = true;
- break;
+ codeValue = patterns[data[i]] ?? 0;
+
+ if (codeValue == 0) {
+ hasError = true;
}
if (hasError) {
- String errorMsg =
- "Invalid content for Code93. Please check https://en.wikipedia.org/wiki/Code_93 for reference.";
- if (this.onError != null) {
- this.onError(errorMsg);
- } else {
+ const errorMsg = 'Invalid content for Code93. Please check '
+ 'https://en.wikipedia.org/wiki/Code_93 for reference.';
+
+ if (onError != null) {
+ onError!(errorMsg);
+ }
+ //
+ else {
print(errorMsg);
}
+
return;
}
@@ -529,650 +260,319 @@ class BarCodePainter extends CustomPainter {
sumK += strValue.getUint8(i) * (data.length - i + 1);
for (int j = 0; j < 8; j++) {
- Rect rect = new Rect.fromLTWH(
- 9 * lineWidth + 9 * i * lineWidth + j * lineWidth,
- 0.0,
- lineWidth,
- height);
+ final rect = Rect.fromLTWH(
+ 9 * lineWidth + 9 * i * lineWidth + j * lineWidth,
+ 0.0,
+ lineWidth,
+ height,
+ );
+
((0x80 & (binSet[codeValue] << j)) == 0x80)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
}
checkCodeC = sumC % 47;
+
for (int i = 0; i < 8; i++) {
- Rect rect = new Rect.fromLTWH(
- 9 * lineWidth + (data.length * 9 + i) * lineWidth,
- 0.0,
- lineWidth,
- height);
+ final rect = Rect.fromLTWH(
+ 9 * lineWidth + (data.length * 9 + i) * lineWidth,
+ 0.0,
+ lineWidth,
+ height,
+ );
+
((0x80 & (binSet[checkCodeC] << i)) == 0x80)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
checkCodeK = (sumK + checkCodeC) % 47;
+
for (int i = 0; i < 8; i++) {
- Rect rect = new Rect.fromLTWH(
- 9 * lineWidth + ((data.length + 1) * 9 + i) * lineWidth,
- 0.0,
- lineWidth,
- height);
+ final rect = Rect.fromLTWH(
+ 9 * lineWidth + ((data.length + 1) * 9 + i) * lineWidth,
+ 0.0,
+ lineWidth,
+ height,
+ );
+
((0x80 & (binSet[checkCodeK] << i)) == 0x80)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
for (int i = 0; i < 8; i++) {
- Rect rect = new Rect.fromLTWH(
- 9 * lineWidth + ((data.length + 2) * 9 + i) * lineWidth,
- 0.0,
- lineWidth,
- height);
+ final rect = Rect.fromLTWH(
+ 9 * lineWidth + ((data.length + 2) * 9 + i) * lineWidth,
+ 0.0,
+ lineWidth,
+ height,
+ );
+
((0x80 & (binSet[47] << i)) == 0x80)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
for (int i = 0; i < 8; i++) {
- Rect rect = new Rect.fromLTWH(
- 9 * lineWidth + ((data.length + 3) * 9 + i) * lineWidth,
- 0.0,
- lineWidth,
- height);
+ final rect = Rect.fromLTWH(
+ 9 * lineWidth + ((data.length + 3) * 9 + i) * lineWidth,
+ 0.0,
+ lineWidth,
+ height,
+ );
+
((0x80 & (binSet[1] << i)) == 0x80)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
if (hasText) {
for (int i = 0; i < data.length; i++) {
- TextSpan span = new TextSpan(
- style: new TextStyle(color: Colors.black, fontSize: 15.0),
- text: data[i]);
- TextPainter textPainter = new TextPainter(
- text: span,
- textAlign: TextAlign.left,
- textDirection: TextDirection.ltr);
+ final span = TextSpan(
+ style: const TextStyle(color: Colors.black, fontSize: 15.0),
+ text: data[i],
+ );
+
+ final textPainter = TextPainter(
+ text: span,
+ textAlign: TextAlign.left,
+ textDirection: TextDirection.ltr,
+ );
+
textPainter.layout();
textPainter.paint(
- canvas,
- new Offset(
- (size.width - data.length * 8 * lineWidth) / 2 +
- 8 * i * lineWidth,
- height));
+ canvas,
+ Offset(
+ (size.width - data.length * 8 * lineWidth) / 2 +
+ 8 * i * lineWidth,
+ height),
+ );
}
}
}
+ ///
+ ///
void _drawBarCode128(Canvas canvas, Size size) {
- List code128 = [
- 0x6cc,
- 0x66c,
- 0x666,
- 0x498,
- 0x48c,
- 0x44c,
- 0x4c8,
- 0x4c4,
- 0x464,
- 0x648,
- 0x644,
- 0x624,
- 0x59c,
- 0x4dc,
- 0x4ce,
- 0x5cc,
- 0x4ec,
- 0x4e6,
- 0x672,
- 0x65c,
- 0x64e,
- 0x6e4,
- 0x674,
- 0x76e,
- 0x74c,
- 0x72c,
- 0x726,
- 0x764,
- 0x734,
- 0x732,
- 0x6d8,
- 0x6c6,
- 0x636,
- 0x518,
- 0x458,
- 0x446,
- 0x588,
- 0x468,
- 0x462,
- 0x688,
- 0x628,
- 0x622,
- 0x5b8,
- 0x58e,
- 0x46e,
- 0x5d8,
- 0x5c6,
- 0x476,
- 0x776,
- 0x68e,
- 0x62e,
- 0x6e8,
- 0x6e2,
- 0x6ee,
- 0x758,
- 0x746,
- 0x716,
- 0x768,
- 0x762,
- 0x71a,
- 0x77a,
- 0x642,
- 0x78a,
- 0x530,
- 0x50c,
- 0x4b0,
- 0x486,
- 0x42c,
- 0x426,
- 0x590,
- 0x584,
- 0x4d0,
- 0x4c2,
- 0x434,
- 0x432,
- 0x612,
- 0x650,
- 0x7ba,
- 0x614,
- 0x47a,
- 0x53c,
- 0x4bc,
- 0x49e,
- 0x5e4,
- 0x4f4,
- 0x4f2,
- 0x7a4,
- 0x794,
- 0x792,
- 0x6de,
- 0x6f6,
- 0x7b6,
- 0x578,
- 0x51e,
- 0x45e,
- 0x5e8,
- 0x5e2,
- 0x7a8,
- 0x7a2,
- 0x5de,
- 0x5ee,
- 0x75e,
- 0x7ae,
- 0x684,
- 0x690,
- 0x69c
+ const code128 = [
+ ...[0x6cc, 0x66c, 0x666, 0x498, 0x48c, 0x44c, 0x4c8, 0x4c4, 0x464, 0x648],
+ ...[0x644, 0x624, 0x59c, 0x4dc, 0x4ce, 0x5cc, 0x4ec, 0x4e6, 0x672, 0x65c],
+ ...[0x64e, 0x6e4, 0x674, 0x76e, 0x74c, 0x72c, 0x726, 0x764, 0x734, 0x732],
+ ...[0x6d8, 0x6c6, 0x636, 0x518, 0x458, 0x446, 0x588, 0x468, 0x462, 0x688],
+ ...[0x628, 0x622, 0x5b8, 0x58e, 0x46e, 0x5d8, 0x5c6, 0x476, 0x776, 0x68e],
+ ...[0x62e, 0x6e8, 0x6e2, 0x6ee, 0x758, 0x746, 0x716, 0x768, 0x762, 0x71a],
+ ...[0x77a, 0x642, 0x78a, 0x530, 0x50c, 0x4b0, 0x486, 0x42c, 0x426, 0x590],
+ ...[0x584, 0x4d0, 0x4c2, 0x434, 0x432, 0x612, 0x650, 0x7ba, 0x614, 0x47a],
+ ...[0x53c, 0x4bc, 0x49e, 0x5e4, 0x4f4, 0x4f2, 0x7a4, 0x794, 0x792, 0x6de],
+ ...[0x6f6, 0x7b6, 0x578, 0x51e, 0x45e, 0x5e8, 0x5e2, 0x7a8, 0x7a2, 0x5de],
+ ...[0x5ee, 0x75e, 0x7ae, 0x684, 0x690, 0x69c],
];
- final data = params.data;
- final lineWidth = params.lineWidth;
- final hasText = params.withText;
+ const patterns = {
+ ...{' ': 0, '!': 1, '"': 2, '#': 3, '\$': 4, '%': 5, '&': 6, '…': 7},
+ ...{'(': 8, ')': 9, '*': 10, '+': 11, ',': 12, '-': 13, '.': 14},
+ ...{'/': 15, '0': 16, '1': 17, '2': 18, '3': 19, '4': 20, '5': 21},
+ ...{'6': 22, '7': 23, '8': 24, '9': 25, ':': 26, ';': 27, '<': 28},
+ ...{'=': 29, '>': 30, '?': 31, '@': 32, 'A': 33, 'B': 34, 'C': 35},
+ ...{'D': 36, 'E': 37, 'F': 38, 'G': 39, 'H': 40, 'I': 41, 'J': 42},
+ ...{'K': 43, 'L': 44, 'M': 45, 'N': 46, 'O': 47, 'P': 48, 'Q': 49},
+ ...{'R': 50, 'S': 51, 'T': 52, 'U': 53, 'V': 54, 'W': 55, 'X': 56},
+ ...{'Y': 57, 'Z': 58, '[': 59, '、': 0, ']': 61, '^': 62, '_': 63},
+ ...{'`': 64, 'a': 65, 'b': 66, 'c': 67, 'd': 68, 'e': 69, 'f': 70},
+ ...{'g': 71, 'h': 72, 'i': 73, 'j': 74, 'k': 75, 'l': 76, 'm': 77},
+ ...{'n': 78, 'o': 79, 'p': 80, 'q': 81, 'r': 82, 's': 83, 't': 84},
+ ...{'u': 85, 'v': 86, 'w': 87, 'x': 88, 'y': 89, 'z': 90, '{': 91},
+ ...{'|': 92, '}': 93, '~': 94},
+ };
+
+ final data = params!.data;
+ final lineWidth = params!.lineWidth;
+ final hasText = params!.withText;
+
+ int codeValue;
+ int checkCode;
+ int sum = 0;
+
+ final strlen = data.length;
+ final strValue = ByteData(strlen);
+
+ const startValue = 0x690;
+ const endFlag = 0x18eb;
- int codeValue, checkCode, strlen = data.length;
- ByteData strValue = new ByteData(strlen);
- int sum = 0, startValue = 0x690, endFlag = 0x18eb;
bool hasError = false;
- final painter = new Paint()..style = PaintingStyle.fill;
- double height = hasText ? size.height * 0.85 : size.height;
+ final painter = Paint()..style = PaintingStyle.fill;
+ final height = hasText ? size.height * 0.85 : size.height;
for (int i = 0; i < 11; i++) {
- Rect rect = new Rect.fromLTWH(i * lineWidth, 0.0, lineWidth, height);
+ final rect = Rect.fromLTWH(i * lineWidth, 0.0, lineWidth, height);
+
((0x400 & (startValue << i)) == 0x400)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
for (int i = 0; i < strlen; i++) {
- switch (data[i]) {
- case ' ':
- codeValue = 0;
- break;
- case '!':
- codeValue = 1;
- break;
- case '"':
- codeValue = 2;
- break;
- case '#':
- codeValue = 3;
- break;
- case '\$':
- codeValue = 4;
- break;
- case '%':
- codeValue = 5;
- break;
- case '&':
- codeValue = 6;
- break;
- case '…':
- codeValue = 7;
- break;
- case '(':
- codeValue = 8;
- break;
- case ')':
- codeValue = 9;
- break;
- case '*':
- codeValue = 10;
- break;
- case '+':
- codeValue = 11;
- break;
- case ',':
- codeValue = 12;
- break;
- case '-':
- codeValue = 13;
- break;
- case '.':
- codeValue = 14;
- break;
- case '/':
- codeValue = 15;
- break;
- case '0':
- codeValue = 16;
- break;
- case '1':
- codeValue = 17;
- break;
- case '2':
- codeValue = 18;
- break;
- case '3':
- codeValue = 19;
- break;
- case '4':
- codeValue = 20;
- break;
- case '5':
- codeValue = 21;
- break;
- case '6':
- codeValue = 22;
- break;
- case '7':
- codeValue = 23;
- break;
- case '8':
- codeValue = 24;
- break;
- case '9':
- codeValue = 25;
- break;
- case ':':
- codeValue = 26;
- break;
- case ';':
- codeValue = 27;
- break;
- case '<':
- codeValue = 28;
- break;
- case '=':
- codeValue = 29;
- break;
- case '>':
- codeValue = 30;
- break;
- case '?':
- codeValue = 31;
- break;
- case '@':
- codeValue = 32;
- break;
- case 'A':
- codeValue = 33;
- break;
- case 'B':
- codeValue = 34;
- break;
- case 'C':
- codeValue = 35;
- break;
- case 'D':
- codeValue = 36;
- break;
- case 'E':
- codeValue = 37;
- break;
- case 'F':
- codeValue = 38;
- break;
- case 'G':
- codeValue = 39;
- break;
- case 'H':
- codeValue = 40;
- break;
- case 'I':
- codeValue = 41;
- break;
- case 'J':
- codeValue = 42;
- break;
- case 'K':
- codeValue = 43;
- break;
- case 'L':
- codeValue = 44;
- break;
- case 'M':
- codeValue = 45;
- break;
- case 'N':
- codeValue = 46;
- break;
- case 'O':
- codeValue = 47;
- break;
- case 'P':
- codeValue = 48;
- break;
- case 'Q':
- codeValue = 49;
- break;
- case 'R':
- codeValue = 50;
- break;
- case 'S':
- codeValue = 51;
- break;
- case 'T':
- codeValue = 52;
- break;
- case 'U':
- codeValue = 53;
- break;
- case 'V':
- codeValue = 54;
- break;
- case 'W':
- codeValue = 55;
- break;
- case 'X':
- codeValue = 56;
- break;
- case 'Y':
- codeValue = 57;
- break;
- case 'Z':
- codeValue = 58;
- break;
- case '[':
- codeValue = 59;
- break;
- case '、':
- codeValue = 60;
- break;
- case ']':
- codeValue = 61;
- break;
- case '^':
- codeValue = 62;
- break;
- case '_':
- codeValue = 63;
- break;
- case '`':
- codeValue = 64;
- break;
- case 'a':
- codeValue = 65;
- break;
- case 'b':
- codeValue = 66;
- break;
- case 'c':
- codeValue = 67;
- break;
- case 'd':
- codeValue = 68;
- break;
- case 'e':
- codeValue = 69;
- break;
- case 'f':
- codeValue = 70;
- break;
- case 'g':
- codeValue = 71;
- break;
- case 'h':
- codeValue = 72;
- break;
- case 'i':
- codeValue = 73;
- break;
- case 'j':
- codeValue = 74;
- break;
- case 'k':
- codeValue = 75;
- break;
- case 'l':
- codeValue = 76;
- break;
- case 'm':
- codeValue = 77;
- break;
- case 'n':
- codeValue = 78;
- break;
- case 'o':
- codeValue = 79;
- break;
- case 'p':
- codeValue = 80;
- break;
- case 'q':
- codeValue = 81;
- break;
- case 'r':
- codeValue = 82;
- break;
- case 's':
- codeValue = 83;
- break;
- case 't':
- codeValue = 84;
- break;
- case 'u':
- codeValue = 85;
- break;
- case 'v':
- codeValue = 86;
- break;
- case 'w':
- codeValue = 87;
- break;
- case 'x':
- codeValue = 88;
- break;
- case 'y':
- codeValue = 89;
- break;
- case 'z':
- codeValue = 90;
- break;
- case '{':
- codeValue = 91;
- break;
- case '|':
- codeValue = 92;
- break;
- case '}':
- codeValue = 93;
- break;
- case '~':
- codeValue = 94;
- break;
- default:
- hasError = true;
- break;
+ codeValue = patterns[data[i]] ?? 0;
+
+ if (codeValue == 0) {
+ hasError = true;
}
if (hasError) {
- String errorMsg =
- "Invalid content for Code128. Please check https://en.wikipedia.org/wiki/Code_128 for reference.";
- if (this.onError != null) {
- this.onError(errorMsg);
- } else {
+ const errorMsg = 'Invalid content for Code128. Please check '
+ 'https://en.wikipedia.org/wiki/Code_128 for reference.';
+
+ if (onError != null) {
+ onError!(errorMsg);
+ }
+ //
+ else {
print(errorMsg);
}
+
return;
}
strValue.setUint8(i, codeValue);
sum += strValue.getUint8(i) * (i + 1);
+
for (int j = 0; j < 11; j++) {
- Rect rect = new Rect.fromLTWH(
- 11 * lineWidth + 11 * i * lineWidth + j * lineWidth,
- 0.0,
- lineWidth,
- height);
+ final rect = Rect.fromLTWH(
+ 11 * lineWidth + 11 * i * lineWidth + j * lineWidth,
+ 0.0,
+ lineWidth,
+ height,
+ );
+
((0x400 & (code128[codeValue] << j)) == 0x400)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
}
checkCode = (sum + 104) % 103;
for (int i = 0; i < 11; i++) {
- Rect rect = new Rect.fromLTWH(
- 11 * lineWidth + (strlen * 11 + i) * lineWidth,
- 0.0,
- lineWidth,
- height);
+ final rect = Rect.fromLTWH(
+ 11 * lineWidth + (strlen * 11 + i) * lineWidth,
+ 0.0,
+ lineWidth,
+ height,
+ );
+
((0x400 & (code128[checkCode] << i)) == 0x400)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
for (int i = 0; i < 13; i++) {
- Rect rect = new Rect.fromLTWH(
- 22 * lineWidth + (strlen * 11 + i) * lineWidth,
- 0.0,
- lineWidth,
- height);
+ final rect = Rect.fromLTWH(
+ 22 * lineWidth + (strlen * 11 + i) * lineWidth,
+ 0.0,
+ lineWidth,
+ height,
+ );
+
((0x1000 & (endFlag << i)) == 0x1000)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
if (hasText) {
for (int i = 0; i < data.length; i++) {
- TextSpan span = new TextSpan(
- style: new TextStyle(color: Colors.black, fontSize: 15.0),
- text: data[i]);
- TextPainter textPainter = new TextPainter(
- text: span,
- textAlign: TextAlign.left,
- textDirection: TextDirection.ltr);
+ final span = TextSpan(
+ style: const TextStyle(color: Colors.black, fontSize: 15.0),
+ text: data[i],
+ );
+
+ final textPainter = TextPainter(
+ text: span,
+ textAlign: TextAlign.left,
+ textDirection: TextDirection.ltr,
+ );
+
textPainter.layout();
textPainter.paint(
- canvas,
- new Offset(
- (size.width - data.length * 8 * lineWidth) / 2 +
- 8 * i * lineWidth,
- height));
+ canvas,
+ Offset(
+ (size.width - data.length * 8 * lineWidth) / 2 +
+ 8 * i * lineWidth,
+ height),
+ );
}
}
}
+ ///
+ ///
void _drawBarCodeEAN13(Canvas canvas, Size size) {
- List codeA = [
- 0x0d,
- 0x19,
- 0x13,
- 0x3d,
- 0x23,
- 0x31,
- 0x2f,
- 0x3b,
- 0x37,
- 0x0b
+ const codeA = [
+ ...[0x0d, 0x19, 0x13, 0x3d, 0x23],
+ ...[0x31, 0x2f, 0x3b, 0x37, 0x0b]
];
- List codeB = [
- 0x27,
- 0x33,
- 0x1b,
- 0x21,
- 0x1d,
- 0x39,
- 0x05,
- 0x11,
- 0x09,
- 0x17
+
+ const codeB = [
+ ...[0x27, 0x33, 0x1b, 0x21, 0x1d],
+ ...[0x39, 0x05, 0x11, 0x09, 0x17]
];
- List codeC = [
- 0x72,
- 0x66,
- 0x6c,
- 0x42,
- 0x5c,
- 0x4e,
- 0x50,
- 0x44,
- 0x48,
- 0x74
+
+ const codeC = [
+ ...[0x72, 0x66, 0x6c, 0x42, 0x5c],
+ ...[0x4e, 0x50, 0x44, 0x48, 0x74]
];
- List flagCode = [
- 0x00,
- 0x0b,
- 0x0d,
- 0x0e,
- 0x13,
- 0x19,
- 0x1c,
- 0x15,
- 0x17,
- 0x1a
+
+ const flagCode = [
+ ...[0x00, 0x0b, 0x0d, 0x0e, 0x13],
+ ...[0x19, 0x1c, 0x15, 0x17, 0x1a]
];
- final data = params.data;
- final lineWidth = params.lineWidth;
- final hasText = params.withText;
+ final data = params!.data;
+ final lineWidth = params!.lineWidth;
+ final hasText = params!.withText;
+
+ const startCodeSep = 0x05;
+ const midCodeSep = 0x0a;
+ const endCodeSep = 0x05;
- int startCodeSep = 0x05, midCodeSep = 0x0a, endCodeSep = 0x05;
- int tmpCode,
+ late int tmpCode,
tmpBarCode,
checkCode,
sum2nd,
sum3rd,
flagbit,
strlen = data.length;
- ByteData st = new ByteData(12);
+
bool hasError = false;
- final painter = new Paint()..style = PaintingStyle.fill;
- double height = hasText ? size.height * 0.85 : size.height;
+
+ final st = ByteData(12);
+ final painter = Paint()..style = PaintingStyle.fill;
+ final height = hasText ? size.height * 0.85 : size.height;
if (strlen > 12) {
strlen = 13;
- } else {
+ }
+ //
+ else {
hasError = true;
}
@@ -1184,52 +584,73 @@ class BarCodePainter extends CustomPainter {
}
if (hasError) {
- String errorMsg =
- "Invalid content for code EAN13. Please check https://en.wikipedia.org/wiki/International_Article_Number for reference.";
- if (this.onError != null) {
- this.onError(errorMsg);
- } else {
+ const errorMsg = 'Invalid content for code EAN13. Please check '
+ 'https://en.wikipedia.org/wiki/International_Article_Number for reference.';
+
+ if (onError != null) {
+ onError!(errorMsg);
+ }
+ //
+ else {
print(errorMsg);
}
+
return;
}
for (int j = 0; j < 3; j++) {
- Rect rect = new Rect.fromLTWH(11 * lineWidth + j * lineWidth, 0.0,
- lineWidth, hasText ? height * 1.08 : height);
+ final rect = Rect.fromLTWH(
+ 11 * lineWidth + j * lineWidth,
+ 0.0,
+ lineWidth,
+ hasText ? height * 1.08 : height,
+ );
+
((0x01 & (startCodeSep >> j)) == 0x01)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
for (int i = 0; i < 7; i++) {
tmpCode = data.codeUnitAt(i) - 48;
+
if (i == 0) {
flagbit = tmpCode;
- } else {
+ }
+ //
+ else {
if ((0x20 & (flagCode[flagbit] << (i - 1))) == 0) {
for (int j = 0; j < 7; j++) {
- Rect rect = new Rect.fromLTWH(
- 14 * lineWidth + 7 * (i - 1) * lineWidth + j * lineWidth,
- 0.0,
- lineWidth,
- height);
+ final rect = Rect.fromLTWH(
+ 14 * lineWidth + 7 * (i - 1) * lineWidth + j * lineWidth,
+ 0.0,
+ lineWidth,
+ height,
+ );
+
((0x40 & (codeA[tmpCode] << j)) == 0x40)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
- } else {
+ }
+ //
+ else {
for (int n = 0; n < 7; n++) {
- Rect rect = new Rect.fromLTWH(
- 14 * lineWidth + 7 * (i - 1) * lineWidth + n * lineWidth,
- 0.0,
- lineWidth,
- height);
+ final rect = Rect.fromLTWH(
+ 14 * lineWidth + 7 * (i - 1) * lineWidth + n * lineWidth,
+ 0.0,
+ lineWidth,
+ height,
+ );
+
((0x40 & (codeB[tmpCode] << n)) == 0x40)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
}
@@ -1237,152 +658,192 @@ class BarCodePainter extends CustomPainter {
}
for (int i = 0; i < 5; i++) {
- Rect rect = new Rect.fromLTWH(56 * lineWidth + i * lineWidth, 0.0,
- lineWidth, hasText ? height * 1.08 : height);
+ final rect = Rect.fromLTWH(
+ 56 * lineWidth + i * lineWidth,
+ 0.0,
+ lineWidth,
+ hasText ? height * 1.08 : height,
+ );
+
((0x01 & (midCodeSep >> i)) == 0x01)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
for (int i = 0; i < 5; i++) {
tmpBarCode = data.codeUnitAt(i + 7) - 48;
+
for (int j = 0; j < 7; j++) {
- Rect rect = new Rect.fromLTWH(
- 61 * lineWidth + j * lineWidth + 7 * i * lineWidth,
- 0.0,
- lineWidth,
- height);
+ final rect = Rect.fromLTWH(
+ 61 * lineWidth + j * lineWidth + 7 * i * lineWidth,
+ 0.0,
+ lineWidth,
+ height,
+ );
+
((0x40 & (codeC[tmpBarCode] << j)) == 0x40)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
}
- sum3rd = st.getUint8(0) +
- st.getUint8(2) +
- st.getUint8(4) +
- st.getUint8(6) +
- st.getUint8(8) +
- st.getUint8(10);
- sum2nd = st.getUint8(1) +
- st.getUint8(3) +
- st.getUint8(5) +
- st.getUint8(7) +
- st.getUint8(9) +
- st.getUint8(11);
+ sum3rd = (st.getUint8(0) + st.getUint8(2) + st.getUint8(4)) +
+ (st.getUint8(6) + st.getUint8(8) + st.getUint8(10));
+
+ sum2nd = (st.getUint8(1) + st.getUint8(3) + st.getUint8(5)) +
+ (st.getUint8(7) + st.getUint8(9) + st.getUint8(11));
+
if ((sum2nd * 3 + sum3rd) % 10 == 0) {
checkCode = 0;
- } else {
+ }
+ //
+ else {
checkCode = 10 - (sum2nd * 3 + sum3rd) % 10;
}
for (int i = 0; i < 7; i++) {
- Rect rect = new Rect.fromLTWH(
- 96 * lineWidth + i * lineWidth, 0.0, lineWidth, height);
+ final rect = Rect.fromLTWH(
+ 96 * lineWidth + i * lineWidth,
+ 0.0,
+ lineWidth,
+ height,
+ );
+
((0x40 & (codeC[checkCode] << i)) == 0x40)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
for (int i = 0; i < 3; i++) {
- Rect rect = new Rect.fromLTWH(103 * lineWidth + i * lineWidth, 0.0,
- lineWidth, hasText ? height * 1.08 : height);
+ final rect = Rect.fromLTWH(
+ 103 * lineWidth + i * lineWidth,
+ 0.0,
+ lineWidth,
+ hasText ? height * 1.08 : height,
+ );
+
((0x01 & (endCodeSep >> i)) == 0x01)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
if (hasText) {
- (data.length > 13) ? strlen = 13 : strlen = data.length;
+ (data.length > 13) //
+ ? strlen = 13
+ : strlen = data.length;
+
for (int i = 0; i < strlen; i++) {
if (i == 0) {
- TextSpan span = new TextSpan(
- style: new TextStyle(color: Colors.black, fontSize: 15.0),
- text: data[i]);
- TextPainter textPainter = new TextPainter(
- text: span,
- textAlign: TextAlign.left,
- textDirection: TextDirection.ltr);
+ final span = TextSpan(
+ style: const TextStyle(color: Colors.black, fontSize: 15.0),
+ text: data[i],
+ );
+
+ final textPainter = TextPainter(
+ text: span,
+ textAlign: TextAlign.left,
+ textDirection: TextDirection.ltr,
+ );
+
textPainter.layout();
- textPainter.paint(canvas, new Offset(2 * lineWidth, height));
- } else if (i < 7) {
- TextSpan span = new TextSpan(
- style: new TextStyle(color: Colors.black, fontSize: 15.0),
- text: data[i]);
- TextPainter textPainter = new TextPainter(
- text: span,
- textAlign: TextAlign.left,
- textDirection: TextDirection.ltr);
+ textPainter.paint(canvas, Offset(2 * lineWidth, height));
+ }
+ //
+ else if (i < 7) {
+ final span = TextSpan(
+ style: const TextStyle(color: Colors.black, fontSize: 15.0),
+ text: data[i],
+ );
+
+ final textPainter = TextPainter(
+ text: span,
+ textAlign: TextAlign.left,
+ textDirection: TextDirection.ltr,
+ );
+
textPainter.layout();
- textPainter.paint(canvas,
- new Offset(13 * lineWidth + 7 * (i - 1) * lineWidth, height));
- } else if (i == 12) {
- TextSpan span = new TextSpan(
- style: new TextStyle(color: Colors.black, fontSize: 15.0),
- text: checkCode.toString());
- TextPainter textPainter = new TextPainter(
- text: span,
- textAlign: TextAlign.left,
- textDirection: TextDirection.ltr);
+ textPainter.paint(
+ canvas,
+ Offset(13 * lineWidth + 7 * (i - 1) * lineWidth, height),
+ );
+ }
+ //
+ else if (i == 12) {
+ final span = TextSpan(
+ style: const TextStyle(color: Colors.black, fontSize: 15.0),
+ text: checkCode.toString(),
+ );
+
+ final textPainter = TextPainter(
+ text: span,
+ textAlign: TextAlign.left,
+ textDirection: TextDirection.ltr,
+ );
+
textPainter.layout();
- textPainter.paint(canvas,
- new Offset(17 * lineWidth + 7 * (i - 1) * lineWidth, height));
- } else {
- TextSpan span = new TextSpan(
- style: new TextStyle(color: Colors.black, fontSize: 15.0),
- text: data[i]);
- TextPainter textPainter = new TextPainter(
- text: span,
- textAlign: TextAlign.left,
- textDirection: TextDirection.ltr);
+ textPainter.paint(
+ canvas,
+ Offset(17 * lineWidth + 7 * (i - 1) * lineWidth, height),
+ );
+ }
+ //
+ else {
+ final span = TextSpan(
+ style: const TextStyle(color: Colors.black, fontSize: 15.0),
+ text: data[i],
+ );
+
+ final textPainter = TextPainter(
+ text: span,
+ textAlign: TextAlign.left,
+ textDirection: TextDirection.ltr,
+ );
+
textPainter.layout();
- textPainter.paint(canvas,
- new Offset(17 * lineWidth + 7 * (i - 1) * lineWidth, height));
+ textPainter.paint(
+ canvas,
+ Offset(17 * lineWidth + 7 * (i - 1) * lineWidth, height),
+ );
}
}
}
}
+ ///
+ ///
void _drawBarCodeEAN8(Canvas canvas, Size size) {
- List codeA = [
- 0x0d,
- 0x19,
- 0x13,
- 0x3d,
- 0x23,
- 0x31,
- 0x2f,
- 0x3b,
- 0x37,
- 0x0b
+ const codeA = [
+ ...[0x0d, 0x19, 0x13, 0x3d, 0x23],
+ ...[0x31, 0x2f, 0x3b, 0x37, 0x0b]
];
- List codeC = [
- 0x72,
- 0x66,
- 0x6c,
- 0x42,
- 0x5c,
- 0x4e,
- 0x50,
- 0x44,
- 0x48,
- 0x74
+
+ const codeC = [
+ ...[0x72, 0x66, 0x6c, 0x42, 0x5c],
+ ...[0x4e, 0x50, 0x44, 0x48, 0x74]
];
- int startCodeSep = 0x05, midCodeSep = 0x0a, endCodeSep = 0x05;
- final data = params.data;
- final lineWidth = params.lineWidth;
- final hasText = params.withText;
+ const startCodeSep = 0x05;
+ const midCodeSep = 0x0a;
+ const endCodeSep = 0x05;
+
+ final data = params!.data;
+ final lineWidth = params!.lineWidth;
+ final hasText = params!.withText;
int tmpCode, tmpBarCode, checkCode, sum2nd, sum3rd, strlen = data.length;
- ByteData st = new ByteData(7);
bool hasError = false;
- final painter = new Paint()..style = PaintingStyle.fill;
- double height = hasText ? size.height * 0.85 : size.height;
+
+ final st = ByteData(7);
+ final painter = Paint()..style = PaintingStyle.fill;
+ final height = hasText ? size.height * 0.85 : size.height;
for (int i = 0; i < 7; i++) {
st.setUint8(i, data.codeUnitAt(i) - 48);
@@ -1392,19 +853,23 @@ class BarCodePainter extends CustomPainter {
}
if (hasError) {
- String errorMsg =
- "Invalid content for code EAN8. Please check https://en.wikipedia.org/wiki/EAN-8 for reference.";
- if (this.onError != null) {
- this.onError(errorMsg);
- } else {
+ const errorMsg = 'Invalid content for code EAN8. Please check '
+ 'https://en.wikipedia.org/wiki/EAN-8 for reference.';
+
+ if (onError != null) {
+ onError!(errorMsg);
+ }
+ //
+ else {
print(errorMsg);
}
+
return;
}
for (int i = 0; i < 3; i++) {
- Rect rect = new Rect.fromLTWH(7 * lineWidth + i * lineWidth, 0.0,
- lineWidth, hasText ? height * 1.08 : height);
+ final rect = Rect.fromLTWH(7 * lineWidth + i * lineWidth, 0.0, lineWidth,
+ hasText ? height * 1.08 : height);
((0x01 & (startCodeSep >> i)) == 0x01)
? painter.color = Colors.black
: painter.color = Colors.white;
@@ -1414,7 +879,7 @@ class BarCodePainter extends CustomPainter {
for (int i = 0; i < 4; i++) {
tmpCode = data.codeUnitAt(i) - 48;
for (int j = 0; j < 7; j++) {
- Rect rect = new Rect.fromLTWH(
+ final rect = Rect.fromLTWH(
10 * lineWidth + j * lineWidth + 7 * i * lineWidth,
0.0,
lineWidth,
@@ -1427,132 +892,171 @@ class BarCodePainter extends CustomPainter {
}
for (int i = 0; i < 5; i++) {
- Rect rect = new Rect.fromLTWH(
- 38 * lineWidth + i * lineWidth, 0.0, lineWidth, height);
+ final rect = Rect.fromLTWH(
+ 38 * lineWidth + i * lineWidth,
+ 0.0,
+ lineWidth,
+ height,
+ );
+
((0x01 & (midCodeSep >> i)) == 0x01)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
for (int i = 4; i < 7; i++) {
tmpBarCode = data.codeUnitAt(i) - 48;
for (int j = 0; j < 7; j++) {
- Rect rect = new Rect.fromLTWH(
- 43 * lineWidth + j * lineWidth + 7 * (i - 4) * lineWidth,
- 0.0,
- lineWidth,
- height);
+ final rect = Rect.fromLTWH(
+ 43 * lineWidth + j * lineWidth + 7 * (i - 4) * lineWidth,
+ 0.0,
+ lineWidth,
+ height,
+ );
+
((0x40 & (codeC[tmpBarCode] << j)) == 0x40)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
}
sum2nd = st.getUint8(6) + st.getUint8(4) + st.getUint8(2) + st.getUint8(0);
sum3rd = st.getUint8(5) + st.getUint8(3) + st.getUint8(1);
+
if ((sum3rd + sum2nd * 3) % 10 == 0) {
checkCode = 0;
- } else {
+ }
+ //
+ else {
checkCode = 10 - (sum3rd + sum2nd * 3) % 10;
}
for (int i = 0; i < 7; i++) {
- Rect rect = new Rect.fromLTWH(
- 64 * lineWidth + i * lineWidth, 0.0, lineWidth, height);
+ final rect = Rect.fromLTWH(
+ 64 * lineWidth + i * lineWidth,
+ 0.0,
+ lineWidth,
+ height,
+ );
+
((0x40 & (codeC[checkCode] << i)) == 0x40)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
for (int i = 0; i < 3; i++) {
- Rect rect = new Rect.fromLTWH(71 * lineWidth + i * lineWidth, 0.0,
- lineWidth, hasText ? height * 1.08 : height);
+ final rect = Rect.fromLTWH(
+ 71 * lineWidth + i * lineWidth,
+ 0.0,
+ lineWidth,
+ hasText ? height * 1.08 : height,
+ );
+
((0x01 & (endCodeSep >> i)) == 0x01)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
if (hasText) {
- strlen > 8 ? strlen = 8 : strlen = data.length;
+ strlen > 8 //
+ ? strlen = 8
+ : strlen = data.length;
+
for (int i = 0; i < strlen; i++) {
if (i < 4) {
- TextSpan span = new TextSpan(
- style: new TextStyle(color: Colors.black, fontSize: 15.0),
- text: data[i]);
- TextPainter textPainter = new TextPainter(
- text: span,
- textAlign: TextAlign.left,
- textDirection: TextDirection.ltr);
+ final span = TextSpan(
+ style: const TextStyle(color: Colors.black, fontSize: 15.0),
+ text: data[i],
+ );
+
+ final textPainter = TextPainter(
+ text: span,
+ textAlign: TextAlign.left,
+ textDirection: TextDirection.ltr,
+ );
+
textPainter.layout();
textPainter.paint(
- canvas, new Offset(11 * lineWidth + 7 * i * lineWidth, height));
- } else if (i == 7) {
- TextSpan span = new TextSpan(
- style: new TextStyle(color: Colors.black, fontSize: 15.0),
- text: checkCode.toString());
- TextPainter textPainter = new TextPainter(
- text: span,
- textAlign: TextAlign.left,
- textDirection: TextDirection.ltr);
+ canvas,
+ Offset(11 * lineWidth + 7 * i * lineWidth, height),
+ );
+ }
+ //
+ else if (i == 7) {
+ final span = TextSpan(
+ style: const TextStyle(color: Colors.black, fontSize: 15.0),
+ text: checkCode.toString(),
+ );
+
+ final textPainter = TextPainter(
+ text: span,
+ textAlign: TextAlign.left,
+ textDirection: TextDirection.ltr,
+ );
+
textPainter.layout();
textPainter.paint(
- canvas, new Offset(15 * lineWidth + 7 * i * lineWidth, height));
- } else {
- TextSpan span = new TextSpan(
- style: new TextStyle(color: Colors.black, fontSize: 15.0),
- text: data[i]);
- TextPainter textPainter = new TextPainter(
- text: span,
- textAlign: TextAlign.left,
- textDirection: TextDirection.ltr);
+ canvas,
+ Offset(15 * lineWidth + 7 * i * lineWidth, height),
+ );
+ }
+ //
+ else {
+ final span = TextSpan(
+ style: const TextStyle(color: Colors.black, fontSize: 15.0),
+ text: data[i],
+ );
+
+ final textPainter = TextPainter(
+ text: span,
+ textAlign: TextAlign.left,
+ textDirection: TextDirection.ltr,
+ );
+
textPainter.layout();
textPainter.paint(
- canvas, new Offset(15 * lineWidth + 7 * i * lineWidth, height));
+ canvas,
+ Offset(15 * lineWidth + 7 * i * lineWidth, height),
+ );
}
}
}
}
+ ///
+ ///
void _drawBarCodeUPCA(Canvas canvas, Size size) {
- List codeA = [
- 0x0d,
- 0x19,
- 0x13,
- 0x3d,
- 0x23,
- 0x31,
- 0x2f,
- 0x3b,
- 0x37,
- 0x0b
+ const codeA = [
+ ...[0x0d, 0x19, 0x13, 0x3d, 0x23],
+ ...[0x31, 0x2f, 0x3b, 0x37, 0x0b]
];
- List codeC = [
- 0x72,
- 0x66,
- 0x6c,
- 0x42,
- 0x5c,
- 0x4e,
- 0x50,
- 0x44,
- 0x48,
- 0x74
+
+ const codeC = [
+ ...[0x72, 0x66, 0x6c, 0x42, 0x5c],
+ ...[0x4e, 0x50, 0x44, 0x48, 0x74]
];
- int startCodeSep = 0x05, midCodeSep = 0x0a, endCodeSep = 0x05;
- final data = params.data;
- final lineWidth = params.lineWidth;
- final hasText = params.withText;
+ const startCodeSep = 0x05;
+ const midCodeSep = 0x0a;
+ const endCodeSep = 0x05;
+
+ final data = params!.data;
+ final lineWidth = params!.lineWidth;
+ final hasText = params!.withText;
int tmpCode, tmpBarCode, checkCode, sum2nd, sum3rd, strlen = data.length;
- ByteData st = new ByteData(11);
+ final st = ByteData(11);
bool hasError = false;
- final painter = new Paint()..style = PaintingStyle.fill;
- double height = hasText ? size.height * 0.85 : size.height;
+ final painter = Paint()..style = PaintingStyle.fill;
+ final height = hasText ? size.height * 0.85 : size.height;
for (int i = 0; i < 11; i++) {
st.setUint8(i, data.codeUnitAt(i) - 48);
@@ -1562,222 +1066,269 @@ class BarCodePainter extends CustomPainter {
}
if (hasError) {
- String errorMsg =
- "Invalid content for coe UPC-A. Please check https://en.wikipedia.org/wiki/Universal_Product_Code for reference.";
- if (this.onError != null) {
- this.onError(errorMsg);
- } else {
+ const errorMsg = 'Invalid content for coe UPC-A. Please check '
+ 'https://en.wikipedia.org/wiki/Universal_Product_Code for reference.';
+
+ if (onError != null) {
+ onError!(errorMsg);
+ }
+ //
+ else {
print(errorMsg);
}
+
return;
}
for (int i = 0; i < 3; i++) {
- Rect rect = new Rect.fromLTWH(9 * lineWidth + i * lineWidth, 0.0,
- lineWidth, hasText ? height * 1.08 : height);
+ final rect = Rect.fromLTWH(
+ 9 * lineWidth + i * lineWidth,
+ 0.0,
+ lineWidth,
+ hasText ? height * 1.08 : height,
+ );
+
((0x01 & (startCodeSep >> i)) == 0x01)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
for (int i = 0; i < 6; i++) {
tmpCode = data.codeUnitAt(i) - 48;
+
for (int j = 0; j < 7; j++) {
- Rect rect = new Rect.fromLTWH(
- 12 * lineWidth + 7 * i * lineWidth + j * lineWidth,
- 0.0,
- lineWidth,
- height);
+ final rect = Rect.fromLTWH(
+ 12 * lineWidth + 7 * i * lineWidth + j * lineWidth,
+ 0.0,
+ lineWidth,
+ height,
+ );
+
((0x40 & (codeA[tmpCode] << j)) == 0x40)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
}
for (int i = 0; i < 5; i++) {
- Rect rect = new Rect.fromLTWH(54 * lineWidth + i * lineWidth, 0.0,
- lineWidth, hasText ? height * 1.08 : height);
+ final rect = Rect.fromLTWH(
+ 54 * lineWidth + i * lineWidth,
+ 0.0,
+ lineWidth,
+ hasText ? height * 1.08 : height,
+ );
+
((0x01 & (midCodeSep >> i)) == 0x01)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
for (int i = 0; i < 5; i++) {
tmpBarCode = data.codeUnitAt(i + 6) - 48;
+
for (int j = 0; j < 7; j++) {
- Rect rect = new Rect.fromLTWH(
- 59 * lineWidth + j * lineWidth + 7 * i * lineWidth,
- 0.0,
- lineWidth,
- height);
+ final rect = Rect.fromLTWH(
+ 59 * lineWidth + j * lineWidth + 7 * i * lineWidth,
+ 0.0,
+ lineWidth,
+ height,
+ );
+
((0x40 & (codeC[tmpBarCode] << j)) == 0x40)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
}
- sum3rd = st.getUint8(0) +
- st.getUint8(2) +
- st.getUint8(4) +
- st.getUint8(6) +
- st.getUint8(8) +
- st.getUint8(10);
- sum2nd = st.getUint8(1) +
- st.getUint8(3) +
- st.getUint8(5) +
- st.getUint8(7) +
- st.getUint8(9);
+ sum3rd = (st.getUint8(0) + st.getUint8(2) + st.getUint8(4)) +
+ (st.getUint8(6) + st.getUint8(8) + st.getUint8(10));
+
+ sum2nd = (st.getUint8(1) + st.getUint8(3) + st.getUint8(5)) +
+ (st.getUint8(7) + st.getUint8(9));
+
if ((sum2nd + sum3rd * 3) % 10 == 0) {
checkCode = 0;
- } else {
+ }
+ //
+ else {
checkCode = 10 - (sum2nd + sum3rd * 3) % 10;
}
for (int i = 0; i < 7; i++) {
- Rect rect = new Rect.fromLTWH(
- 94 * lineWidth + i * lineWidth, 0.0, lineWidth, height);
+ final rect = Rect.fromLTWH(
+ 94 * lineWidth + i * lineWidth,
+ 0.0,
+ lineWidth,
+ height,
+ );
+
((0x40 & (codeC[checkCode] << i)) == 0x40)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
for (int i = 0; i < 3; i++) {
- Rect rect = new Rect.fromLTWH(101 * lineWidth + i * lineWidth, 0.0,
- lineWidth, hasText ? height * 1.08 : height);
+ final rect = Rect.fromLTWH(
+ 101 * lineWidth + i * lineWidth,
+ 0.0,
+ lineWidth,
+ hasText ? height * 1.08 : height,
+ );
+
((0x01 & (endCodeSep >> i)) == 0x01)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
if (hasText) {
- strlen > 12 ? strlen = 12 : strlen = data.length;
+ strlen > 12 //
+ ? strlen = 12
+ : strlen = data.length;
+
for (int i = 0; i < strlen; i++) {
if (i == 0) {
- TextSpan span = new TextSpan(
- style: new TextStyle(color: Colors.black, fontSize: 15.0),
- text: data[i]);
- TextPainter textPainter = new TextPainter(
- text: span,
- textAlign: TextAlign.left,
- textDirection: TextDirection.ltr);
+ final span = TextSpan(
+ style: const TextStyle(color: Colors.black, fontSize: 15.0),
+ text: data[i],
+ );
+
+ final textPainter = TextPainter(
+ text: span,
+ textAlign: TextAlign.left,
+ textDirection: TextDirection.ltr,
+ );
+
textPainter.layout();
- textPainter.paint(canvas, new Offset(3 * lineWidth, height));
- } else if (i < 6) {
- TextSpan span = new TextSpan(
- style: new TextStyle(color: Colors.black, fontSize: 15.0),
- text: data[i]);
- TextPainter textPainter = new TextPainter(
- text: span,
- textAlign: TextAlign.left,
- textDirection: TextDirection.ltr);
+ textPainter.paint(canvas, Offset(3 * lineWidth, height));
+ }
+ //
+ else if (i < 6) {
+ final span = TextSpan(
+ style: const TextStyle(color: Colors.black, fontSize: 15.0),
+ text: data[i],
+ );
+
+ final textPainter = TextPainter(
+ text: span,
+ textAlign: TextAlign.left,
+ textDirection: TextDirection.ltr,
+ );
+
textPainter.layout();
- textPainter.paint(canvas,
- new Offset(16 * lineWidth + 7 * (i - 1) * lineWidth, height));
- } else if (i < 11) {
- TextSpan span = new TextSpan(
- style: new TextStyle(color: Colors.black, fontSize: 15.0),
- text: data[i]);
- TextPainter textPainter = new TextPainter(
- text: span,
- textAlign: TextAlign.left,
- textDirection: TextDirection.ltr);
+ textPainter.paint(
+ canvas,
+ Offset(16 * lineWidth + 7 * (i - 1) * lineWidth, height),
+ );
+ }
+ //
+ else if (i < 11) {
+ final span = TextSpan(
+ style: const TextStyle(color: Colors.black, fontSize: 15.0),
+ text: data[i],
+ );
+
+ final textPainter = TextPainter(
+ text: span,
+ textAlign: TextAlign.left,
+ textDirection: TextDirection.ltr,
+ );
+
textPainter.layout();
- textPainter.paint(canvas,
- new Offset(26 * lineWidth + 7 * (i - 1) * lineWidth, height));
- } else {
- TextSpan span = new TextSpan(
- style: new TextStyle(color: Colors.black, fontSize: 15.0),
- text: checkCode.toString());
- TextPainter textPainter = new TextPainter(
- text: span,
- textAlign: TextAlign.left,
- textDirection: TextDirection.ltr);
+ textPainter.paint(
+ canvas,
+ Offset(26 * lineWidth + 7 * (i - 1) * lineWidth, height),
+ );
+ }
+ //
+ else {
+ final span = TextSpan(
+ style: const TextStyle(color: Colors.black, fontSize: 15.0),
+ text: checkCode.toString(),
+ );
+
+ final textPainter = TextPainter(
+ text: span,
+ textAlign: TextAlign.left,
+ textDirection: TextDirection.ltr,
+ );
+
textPainter.layout();
- textPainter.paint(canvas,
- new Offset(35 * lineWidth + 7 * (i - 1) * lineWidth, height));
+ textPainter.paint(
+ canvas,
+ Offset(35 * lineWidth + 7 * (i - 1) * lineWidth, height),
+ );
}
}
}
}
+ ///
+ ///
+ ///
void _drawBarCodeUPCE(Canvas canvas, Size size) {
- List codeA = [
- 0x0d,
- 0x19,
- 0x13,
- 0x3d,
- 0x23,
- 0x31,
- 0x2f,
- 0x3b,
- 0x37,
- 0x0b
+ const codeA = [
+ ...[0x0d, 0x19, 0x13, 0x3d, 0x23],
+ ...[0x31, 0x2f, 0x3b, 0x37, 0x0b]
];
- List codeB = [
- 0x27,
- 0x33,
- 0x1b,
- 0x21,
- 0x1d,
- 0x39,
- 0x05,
- 0x11,
- 0x09,
- 0x17
+
+ const codeB = [
+ ...[0x27, 0x33, 0x1b, 0x21, 0x1d],
+ ...[0x39, 0x05, 0x11, 0x09, 0x17]
];
- List checkCodeFlag = [
- 0x38,
- 0x34,
- 0x32,
- 0x31,
- 0x2c,
- 0x26,
- 0x23,
- 0x2a,
- 0x29,
- 0x25
+
+ const checkCodeFlag = [
+ ...[0x38, 0x34, 0x32, 0x31, 0x2c],
+ ...[0x26, 0x23, 0x2a, 0x29, 0x25]
];
- final data = params.data;
- final lineWidth = params.lineWidth;
- final hasText = params.withText;
+ final data = params!.data;
+ final lineWidth = params!.lineWidth;
+ final hasText = params!.withText;
- int startCodeSep = 0x05, endCodeSep = 0x15;
+ const startCodeSep = 0x05;
+ const endCodeSep = 0x15;
int tmpCode, checkCode, sum2nd, sum3rd, strlen;
- ByteData st = new ByteData(11);
+ final st = ByteData(11);
bool hasError = false;
- final painter = new Paint()..style = PaintingStyle.fill;
- double height = hasText ? size.height * 0.85 : size.height;
+ final painter = Paint()..style = PaintingStyle.fill;
+ final height = hasText ? size.height * 0.85 : size.height;
if (data.length != 8) {
hasError = true;
}
- String upce2upca;
+ late String upce2upca;
+
switch (data.codeUnitAt(6) - 48) {
case 0:
- upce2upca =
- data[0] + data[1] + data[2] + '00000' + data[3] + data[4] + data[5];
+ upce2upca = (data[0] + data[1] + data[2]) +
+ ('00000${data[3]}${data[4]}${data[5]}');
break;
case 1:
case 2:
- upce2upca =
- data[0] + data[1] + data[2] + data[6] + '00000' + data[4] + data[5];
+ upce2upca = (data[0] + data[1] + data[2]) +
+ ('${data[6]}00000${data[4]}${data[5]}');
break;
case 3:
- upce2upca =
- data[0] + data[1] + data[2] + data[3] + '00000' + data[4] + data[5];
+ upce2upca = (data[0] + data[1] + data[2]) +
+ ('${data[3]}00000${data[4]}${data[5]}');
break;
case 4:
- upce2upca =
- data[0] + data[1] + data[2] + data[3] + data[4] + '00000' + data[5];
+ upce2upca = (data[0] + data[1] + data[2]) +
+ ('${data[3]}${data[4]}00000${data[5]}');
break;
case 5:
case 6:
@@ -1785,13 +1336,8 @@ class BarCodePainter extends CustomPainter {
case 8:
case 9:
upce2upca = data[0] +
- data[1] +
- data[2] +
- data[3] +
- data[4] +
- data[5] +
- '0000' +
- data[6];
+ (data[1] + data[2] + data[3]) +
+ ('${data[4]}${data[5]}0000${data[6]}');
break;
default:
break;
@@ -1806,22 +1352,32 @@ class BarCodePainter extends CustomPainter {
}
if (hasError) {
- String errorMsg =
- "Invalid content for code UPCE. Please check https://en.wikipedia.org/wiki/Universal_Product_Code#UPC-E for reference.";
- if (this.onError != null) {
- this.onError(errorMsg);
- } else {
+ const errorMsg = 'Invalid content for code UPCE. Please check '
+ 'https://en.wikipedia.org/wiki/Universal_Product_Code#UPC-E for reference.';
+
+ if (onError != null) {
+ onError!(errorMsg);
+ }
+ //
+ else {
print(errorMsg);
}
+
return;
}
for (int i = 0; i < 3; i++) {
- Rect rect = new Rect.fromLTWH(8 * lineWidth + i * lineWidth, 0.0,
- lineWidth, hasText ? height * 1.08 : height);
+ final rect = Rect.fromLTWH(
+ 8 * lineWidth + i * lineWidth,
+ 0.0,
+ lineWidth,
+ hasText ? height * 1.08 : height,
+ );
+
((0x04 & (startCodeSep << i)) == 0x04)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
@@ -1831,89 +1387,129 @@ class BarCodePainter extends CustomPainter {
st.getUint8(6) +
st.getUint8(8) +
st.getUint8(10);
+
sum2nd = st.getUint8(1) +
st.getUint8(3) +
st.getUint8(5) +
st.getUint8(7) +
st.getUint8(9);
+
if ((sum2nd + sum3rd * 3) % 10 == 0) {
checkCode = 0;
- } else {
+ }
+ //
+ else {
checkCode = 10 - (sum2nd + sum3rd * 3) % 10;
}
for (int i = 0; i < 6; i++) {
tmpCode = data.codeUnitAt(i + 1) - 48;
+
if ((0x20 & (checkCodeFlag[checkCode] << i)) == 0x20) {
for (int j = 0; j < 7; j++) {
- Rect rect = new Rect.fromLTWH(
- 11 * lineWidth + 7 * i * lineWidth + j * lineWidth,
- 0.0,
- lineWidth,
- height);
+ final rect = Rect.fromLTWH(
+ 11 * lineWidth + 7 * i * lineWidth + j * lineWidth,
+ 0.0,
+ lineWidth,
+ height,
+ );
+
((0x40 & (codeB[tmpCode] << j)) == 0x40)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
- } else {
+ }
+ //
+ else {
for (int k = 0; k < 7; k++) {
- Rect rect = new Rect.fromLTWH(
- 11 * lineWidth + 7 * i * lineWidth + k * lineWidth,
- 0.0,
- lineWidth,
- height);
+ final rect = Rect.fromLTWH(
+ 11 * lineWidth + 7 * i * lineWidth + k * lineWidth,
+ 0.0,
+ lineWidth,
+ height,
+ );
+
((0x40 & (codeA[tmpCode] << k)) == 0x40)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
}
}
for (int i = 0; i < 6; i++) {
- Rect rect = new Rect.fromLTWH(53 * lineWidth + i * lineWidth, 0.0,
- lineWidth, hasText ? height * 1.08 : height);
+ final rect = Rect.fromLTWH(
+ 53 * lineWidth + i * lineWidth,
+ 0.0,
+ lineWidth,
+ hasText ? height * 1.08 : height,
+ );
+
((0x20 & (endCodeSep << i)) == 0x20)
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
if (hasText) {
- (data.length > 8) ? strlen = 8 : strlen = data.length;
+ (data.length > 8) //
+ ? strlen = 8
+ : strlen = data.length;
+
for (int i = 0; i < strlen; i++) {
if (i == 0) {
- TextSpan span = new TextSpan(
- style: new TextStyle(color: Colors.black, fontSize: 15.0),
- text: data[i]);
- TextPainter textPainter = new TextPainter(
- text: span,
- textAlign: TextAlign.left,
- textDirection: TextDirection.ltr);
+ final span = TextSpan(
+ style: const TextStyle(color: Colors.black, fontSize: 15.0),
+ text: data[i],
+ );
+
+ final textPainter = TextPainter(
+ text: span,
+ textAlign: TextAlign.left,
+ textDirection: TextDirection.ltr,
+ );
+
textPainter.layout();
- textPainter.paint(canvas, new Offset(2 * lineWidth, height));
- } else if (i < 7) {
- TextSpan span = new TextSpan(
- style: new TextStyle(color: Colors.black, fontSize: 15.0),
- text: data[i]);
- TextPainter textPainter = new TextPainter(
- text: span,
- textAlign: TextAlign.left,
- textDirection: TextDirection.ltr);
+ textPainter.paint(canvas, Offset(2 * lineWidth, height));
+ }
+ //
+ else if (i < 7) {
+ final span = TextSpan(
+ style: const TextStyle(color: Colors.black, fontSize: 15.0),
+ text: data[i],
+ );
+
+ final textPainter = TextPainter(
+ text: span,
+ textAlign: TextAlign.left,
+ textDirection: TextDirection.ltr,
+ );
+
textPainter.layout();
- textPainter.paint(canvas,
- new Offset(12 * lineWidth + 7 * (i - 1) * lineWidth, height));
- } else {
- TextSpan span = new TextSpan(
- style: new TextStyle(color: Colors.black, fontSize: 15.0),
- text: checkCode.toString());
- TextPainter textPainter = new TextPainter(
- text: span,
- textAlign: TextAlign.left,
- textDirection: TextDirection.ltr);
+ textPainter.paint(
+ canvas,
+ Offset(12 * lineWidth + 7 * (i - 1) * lineWidth, height),
+ );
+ }
+ //
+ else {
+ final span = TextSpan(
+ style: const TextStyle(color: Colors.black, fontSize: 15.0),
+ text: checkCode.toString(),
+ );
+
+ final textPainter = TextPainter(
+ text: span,
+ textAlign: TextAlign.left,
+ textDirection: TextDirection.ltr,
+ );
+
textPainter.layout();
- textPainter.paint(canvas, new Offset(60 * lineWidth, height));
+ textPainter.paint(canvas, Offset(60 * lineWidth, height));
}
}
}
@@ -1949,32 +1545,27 @@ class BarCodePainter extends CustomPainter {
/// 9 = 0b01010
///
const encodation = [
- 0x06,
- 0x11,
- 0x09,
- 0x18,
- 0x05,
- 0x14,
- 0x0c,
- 0x03,
- 0x12,
- 0x0a,
+ ...[0x06, 0x11, 0x09, 0x18, 0x05],
+ ...[0x14, 0x0c, 0x03, 0x12, 0x0a],
];
var cleanData = itfParams.data;
+
if (cleanData.length % 2 != 0) {
- cleanData = cleanData.padLeft(2 * (cleanData.length / 2).ceil(), "0");
+ cleanData = cleanData.padLeft(2 * (cleanData.length / 2).ceil(), '0');
}
- final fontSize = 15.0;
- final textPadding = 3.0;
+ const fontSize = 15.0;
+ const textPadding = 3.0;
final narrowWidth = itfParams.lineWidth;
final widedWidth = itfParams.lineWidth * itfParams.wideBarRatio;
final quietZoneWidth = itfParams.quietZoneRatio * narrowWidth;
final bearerBarWidth = itfParams.bearerBarRatio * narrowWidth;
- final height =
- itfParams.withText ? size.height - fontSize - textPadding : size.height;
+ final height = itfParams.withText //
+ ? size.height - fontSize - textPadding
+ : size.height;
+
double offsetX = 0;
final painter = Paint()..style = PaintingStyle.fill;
@@ -2003,18 +1594,21 @@ class BarCodePainter extends CustomPainter {
//if not a number return
if (v0 == null || v1 == null) {
- String errorMsg =
- "${cleanData[x]} or ${cleanData[x + 1]} is not a number.";
- if (this.onError != null) {
- this.onError(errorMsg);
- } else {
+ final errorMsg =
+ '${cleanData[x]} or ${cleanData[x + 1]} is not a number.';
+ if (onError != null) {
+ onError!(errorMsg);
+ }
+ //
+ else {
print(errorMsg);
}
+
return;
}
- var e0 = encodation[v0];
- var e1 = encodation[v1];
+ final e0 = encodation[v0];
+ final e1 = encodation[v1];
// print 1 char pair at a time
for (var y = 4; y >= 0; y--) {
@@ -2043,7 +1637,7 @@ class BarCodePainter extends CustomPainter {
/// Draw a bearer bar
///
- if (itfParams.withBearerBars ?? true) {
+ if (itfParams.withBearerBars) {
canvas.drawRect(Rect.fromLTWH(0, 0, offsetX, height), bearerPainter);
}
@@ -2052,21 +1646,24 @@ class BarCodePainter extends CustomPainter {
if (itfParams.withText) {
final labelContent = itfParams.altText ?? cleanData;
final labelText = itfParams.altText == null && labelContent.length == 14
- ? "${cleanData.substring(0, 1)} ${cleanData.substring(1, 3)} ${cleanData.substring(3, 8)} ${cleanData.substring(8, 13)} ${cleanData.substring(13)}"
+ ? '${cleanData.substring(0, 1)} ${cleanData.substring(1, 3)} ${cleanData.substring(3, 8)} ${cleanData.substring(8, 13)} ${cleanData.substring(13)}'
: labelContent;
+
final span = TextSpan(
- style: TextStyle(
+ style: const TextStyle(
color: Colors.black,
fontSize: fontSize,
letterSpacing: 5,
),
text: labelText,
);
+
final textPainter = TextPainter(
text: span,
textAlign: TextAlign.left,
textDirection: TextDirection.ltr,
);
+
textPainter.layout();
textPainter.paint(
canvas,
@@ -2078,91 +1675,91 @@ class BarCodePainter extends CustomPainter {
}
}
-// Codabar painter
-// referred JsBarcode
-// https://github.com/lindell/JsBarcode/blob/master/src/barcodes/codabar/index.js
+ /// Codabar painter
+ /// referred JsBarcode
+ /// https://github.com/lindell/JsBarcode/blob/master/src/barcodes/codabar/index.js
void _drawBarCodeCodabar(Canvas canvas, Size size) {
- final bitSet = {
- "0": "101010011",
- "1": "101011001",
- "2": "101001011",
- "3": "110010101",
- "4": "101101001",
- "5": "110101001",
- "6": "100101011",
- "7": "100101101",
- "8": "100110101",
- "9": "110100101",
- "-": "101001101",
- "\$": "101100101",
- ":": "1101011011",
- "/": "1101101011",
- ".": "1101101101",
- "+": "101100110011",
- "A": "1011001001",
- "B": "1001001011",
- "C": "1010010011",
- "D": "1010011001"
+ const bitSet = {
+ ...{'0': '101010011', '1': '101011001', '2': '101001011'},
+ ...{'3': '110010101', '4': '101101001', '5': '110101001'},
+ ...{'6': '100101011', '7': '100101101', '8': '100110101'},
+ ...{'9': '110100101', '-': '101001101', '\$': '101100101'},
+ ...{':': '1101011011', '/': '1101101011', '.': '1101101101'},
+ ...{'+': '101100110011', 'A': '1011001001', 'B': '1001001011'},
+ ...{'C': '1010010011', 'D': '1010011001'}
};
- final data = params.data;
- final lineWidth = params.lineWidth;
- final hasText = params.withText;
+ final data = params!.data;
+ final lineWidth = params!.lineWidth;
+ final hasText = params!.withText;
- //int codeValue = 0;
- String bitValue = '';
+ String? bitValue = '';
bool hasError = false;
- final painter = new Paint()..style = PaintingStyle.fill;
- double height = hasText ? size.height * 0.85 : size.height;
+ final painter = Paint()..style = PaintingStyle.fill;
+ final height = hasText ? size.height * 0.85 : size.height;
for (int i = 0; i < data.length; i++) {
if (bitSet.containsKey(data[i])) {
bitValue = bitSet[data[i]];
- } else {
+ }
+ //
+ else {
bitValue = '';
hasError = true;
}
if (hasError) {
- String errorMsg =
- "Invalid content for Coddabar. Please check https://en.wikipedia.org/wiki/Codabar for reference.";
- if (this.onError != null) {
- this.onError(errorMsg);
- } else {
+ const errorMsg = 'Invalid content for Coddabar. Please check '
+ 'https://en.wikipedia.org/wiki/Codabar for reference.';
+
+ if (onError != null) {
+ onError!(errorMsg);
+ }
+ //
+ else {
print(errorMsg);
}
+
return;
}
- for (int j = 0; j < bitValue.length; j++) {
- Rect rect = new Rect.fromLTWH(
- 13 * lineWidth + 13 * i * lineWidth + j * lineWidth,
- 0.0,
- lineWidth,
- height);
+ for (int j = 0; j < bitValue!.length; j++) {
+ final rect = Rect.fromLTWH(
+ 13 * lineWidth + 13 * i * lineWidth + j * lineWidth,
+ 0.0,
+ lineWidth,
+ height,
+ );
+
(bitValue[j] == '1')
? painter.color = Colors.black
: painter.color = Colors.white;
+
canvas.drawRect(rect, painter);
}
}
if (hasText) {
for (int i = 0; i < data.length; i++) {
- TextSpan span = new TextSpan(
- style: new TextStyle(color: Colors.black, fontSize: 15.0),
- text: data[i]);
- TextPainter textPainter = new TextPainter(
- text: span,
- textAlign: TextAlign.left,
- textDirection: TextDirection.ltr);
+ final span = TextSpan(
+ style: const TextStyle(color: Colors.black, fontSize: 15.0),
+ text: data[i],
+ );
+
+ final textPainter = TextPainter(
+ text: span,
+ textAlign: TextAlign.left,
+ textDirection: TextDirection.ltr,
+ );
+
textPainter.layout();
textPainter.paint(
- canvas,
- new Offset(
- (size.width - data.length * 13 * lineWidth) / 2 +
- 13 * i * lineWidth,
- height));
+ canvas,
+ Offset(
+ (size.width - data.length * 13 * lineWidth) / 2 +
+ 13 * i * lineWidth,
+ height),
+ );
}
}
}
diff --git a/lib/src/barcode_params.dart b/lib/src/barcode_params.dart
index 3220b2d..698cd81 100644
--- a/lib/src/barcode_params.dart
+++ b/lib/src/barcode_params.dart
@@ -1,95 +1,121 @@
-/*
- * Flutter BarCode Widget
- * Copyright (c) 2018 the BarCode Flutter authors.
- * See LICENSE for distribution and usage details.
- */
+///
+/// Flutter BarCode generator
+/// Copyright (c) 2018 the BarCode Flutter authors.
+/// See LICENSE for distribution and usage details.
+///
+library barcode_flutter_params;
+///
+///
+///
abstract class BarCodeParams {
- String data;
- bool withText;
- double lineWidth;
- double barHeight;
- double get barCodeWidth;
- String altText;
-
+ ///
BarCodeParams(
this.data,
this.withText,
this.lineWidth,
this.barHeight,
this.altText,
- ) : assert(data != null, "Data must be set for BarCodeParams");
+ );
+
+ ///
+ String data;
+
+ ///
+ bool withText;
+
+ ///
+ double lineWidth;
+
+ ///
+ double barHeight;
+
+ ///
+ double get barCodeWidth;
+
+ ///
+ String? altText;
}
+///
/// Params used for the EAN13 BarCode format
///
class EAN13BarCodeParams extends BarCodeParams {
+ ///
EAN13BarCodeParams(
String data, {
bool withText = false,
double lineWidth = 2.0,
double barHeight = 100.0,
- String altText,
+ String? altText,
}) : super(data, withText, lineWidth, barHeight, altText);
@override
- double get barCodeWidth => (lineWidth * 113);
+ double get barCodeWidth => lineWidth * 113;
}
+///
/// Params used for the EAN8 BarCode format
///
class EAN8BarCodeParams extends BarCodeParams {
+ ///
EAN8BarCodeParams(
String data, {
bool withText = false,
double lineWidth = 2.0,
double barHeight = 100.0,
- String altText,
+ String? altText,
}) : super(data, withText, lineWidth, barHeight, altText);
@override
- double get barCodeWidth => (lineWidth * 81);
+ double get barCodeWidth => lineWidth * 81;
}
+///
/// Params used for the Code39 BarCode format
///
class Code39BarCodeParams extends BarCodeParams {
+ ///
Code39BarCodeParams(
String data, {
bool withText = false,
double lineWidth = 2.0,
double barHeight = 100.0,
- String altText,
+ String? altText,
}) : super(data, withText, lineWidth, barHeight, altText);
@override
double get barCodeWidth => (data.length + 2) * 13 * lineWidth;
}
+///
/// Params used for the Code93 BarCode format
///
class Code93BarCodeParams extends BarCodeParams {
+ ///
Code93BarCodeParams(
String data, {
bool withText = false,
double lineWidth = 2.0,
double barHeight = 100.0,
- String altText,
+ String? altText,
}) : super(data, withText, lineWidth, barHeight, altText);
@override
double get barCodeWidth => (data.length + 5) * 9 * lineWidth - 3;
}
+///
/// Params used for the Code128 BarCode format
///
class Code128BarCodeParams extends BarCodeParams {
+ ///
Code128BarCodeParams(
String data, {
bool withText = false,
double lineWidth = 2.0,
double barHeight = 100.0,
- String altText,
+ String? altText,
}) : super(data, withText, lineWidth, barHeight, altText);
@override
@@ -97,39 +123,69 @@ class Code128BarCodeParams extends BarCodeParams {
(data.length + 2) * 11 * lineWidth + 13 * lineWidth;
}
+///
/// Params used for the UPCA BarCode format
///
class UPCABarCodeParams extends BarCodeParams {
+ ///
UPCABarCodeParams(
String data, {
bool withText = false,
double lineWidth = 2.0,
double barHeight = 100.0,
- String altText,
+ String? altText,
}) : super(data, withText, lineWidth, barHeight, altText);
@override
- double get barCodeWidth => (lineWidth * 113);
+ double get barCodeWidth => lineWidth * 113;
}
+///
/// Params used for the UPCE BarCode format
///
class UPCEBarCodeParams extends BarCodeParams {
+ ///
UPCEBarCodeParams(
String data, {
bool withText = false,
double lineWidth = 2.0,
double barHeight = 100.0,
- String altText,
+ String? altText,
}) : super(data, withText, lineWidth, barHeight, altText);
@override
- double get barCodeWidth => (lineWidth * 67);
+ double get barCodeWidth => lineWidth * 67;
}
+///
/// Params used for the ITF-14 BarCode format
///
class ITFBarCodeParams extends BarCodeParams {
+ ///
+ ITFBarCodeParams(
+ String data, {
+ bool withText = false,
+ double lineWidth = 2.0,
+ double barHeight = 100.0,
+ this.wideBarRatio = 2.5,
+ this.quietZoneRatio = 10.0,
+ this.bearerBarRatio = 3.0,
+ this.withBearerBars = true,
+ String? altText,
+ }) : assert(
+ wideBarRatio >= 2.25 && wideBarRatio <= 3.0,
+ 'wideBarRatio must be between 2.25 and 3.0',
+ ),
+ assert(
+ quietZoneRatio >= 10,
+ 'quietZoneRatio must be greater or equal to 10',
+ ),
+ assert(
+ bearerBarRatio >= 2,
+ 'bearerBarRatio must be greater or equal to 2',
+ ),
+ super(data, withText, lineWidth, barHeight, altText);
+
/// The width of the wide bars as a multiple of [lineWidth]
///
/// This must be in the range of 2.25 <=> 3.0
@@ -152,24 +208,6 @@ class ITFBarCodeParams extends BarCodeParams {
///
final bool withBearerBars;
- ITFBarCodeParams(
- String data, {
- bool withText = false,
- double lineWidth = 2.0,
- double barHeight = 100.0,
- this.wideBarRatio = 2.5,
- this.quietZoneRatio = 10.0,
- this.bearerBarRatio = 3.0,
- this.withBearerBars = true,
- String altText,
- }) : assert(wideBarRatio >= 2.25 && wideBarRatio <= 3.0,
- "wideBarRatio must be between 2.25 and 3.0"),
- assert(quietZoneRatio >= 10,
- "quietZoneRatio must be greater or equal to 10"),
- assert(bearerBarRatio >= 2,
- "bearerBarRatio must be greater or equal to 2"),
- super(data, withText, lineWidth, barHeight, altText);
-
@override
double get barCodeWidth =>
((data.length / 2).ceil() * (4 * wideBarRatio + 6) + wideBarRatio + 6) *
@@ -177,15 +215,17 @@ class ITFBarCodeParams extends BarCodeParams {
(2 * (lineWidth * quietZoneRatio));
}
+///
/// Params used for the Codabar BarCode format
///
class CodabarBarCodeParams extends BarCodeParams {
+ ///
CodabarBarCodeParams(
String data, {
bool withText = false,
double lineWidth = 2.0,
double barHeight = 100.0,
- String altText,
+ String? altText,
}) : super(data, withText, lineWidth, barHeight, altText);
@override
diff --git a/pubspec.yaml b/pubspec.yaml
index 9c34715..9dd70a8 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,15 +1,15 @@
name: barcode_flutter
description: >
Barcode flutter is a Flutter library for simple and fast Bar code rendering via a custom painter.
-version: 1.1.2
+version: 2.0.0
homepage: https://github.com/bigship/barcode.flutter
environment:
- sdk: ">=2.0.0-dev.58.0 < 3.0.0"
+ sdk: ">=3.0.0 <4.0.0"
dependencies:
flutter:
sdk: flutter
-flutter:
- uses-material-design: true
+dev_dependencies:
+ lints: ^2.0.1
\ No newline at end of file