├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── example ├── .gitignore ├── .idea │ ├── libraries │ │ ├── Dart_SDK.xml │ │ └── Flutter_for_Android.xml │ ├── modules.xml │ ├── runConfigurations │ │ └── main_dart.xml │ └── workspace.xml ├── .metadata ├── README.md ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── example │ │ │ │ └── MainActivity.java │ │ │ └── res │ │ │ ├── drawable │ │ │ └── launch_background.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── example.iml ├── example_android.iml ├── ios │ ├── .gitignore │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ ├── Flutter.podspec │ │ └── Release.xcconfig │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── Runner │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ └── LaunchImage.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ └── README.md │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── main.m ├── lib │ └── main.dart ├── pubspec.lock ├── pubspec.yaml └── test │ └── widget_test.dart ├── lib ├── barcode_flutter.dart └── src │ ├── barcode_enum.dart │ ├── barcode_image.dart │ ├── barcode_painter.dart │ └── barcode_params.dart └── pubspec.yaml /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://www.dartlang.org/guides/libraries/private-files 2 | 3 | # Files and directories created by pub 4 | .dart_tool/ 5 | .packages 6 | .pub/ 7 | build/ 8 | # If you're building an application, you may want to check-in your pubspec.lock 9 | pubspec.lock 10 | 11 | # Directory created by dartdoc 12 | # If you don't generate documentation locally you can remove this line. 13 | doc/api/ 14 | 15 | .vscode/ 16 | .flutter-plugins 17 | .gradle/ 18 | *.log 19 | android/local.properties 20 | Runner.build/ 21 | flutter_assets/ 22 | ios/Pods/ 23 | ios/Podfile.lock 24 | ios/build/ 25 | /ios/.symlinks/ 26 | android/key.properties 27 | .DS_STORE 28 | 29 | #these files dont seem to get generated on build which causes issues on ios 30 | !Debug.xcconfig 31 | !Release.xcconfig 32 | !AppFrameworkInfo.plist 33 | ios/Flutter/ 34 | 35 | example/ios/Flutter/flutter_export_environment.sh 36 | example/android/.idea/ 37 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.0.0 2 | - Initial release 3 | 4 | ## 1.0.1 5 | - Fix issue. Scanning problem when code128 contains character 'M' 6 | 7 | ## 1.0.2 8 | - Fix EAN8 code invalid checksum bug 9 | 10 | ## 1.1.0 11 | - Add BarCodeParams which allow custom params for each barcode type 12 | - Add ITF support 13 | - Fix issue #1, #9, #13 (See github page for details) 14 | 15 | ## 1.1.2 16 | - Add Codabar support 17 | - Fix wrong pattern for value 102 of Code128 ([#20](https://github.com/bigship/barcode.flutter/issues/20)) 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2018, Flutter barcode generator author (colinchen1984 at gmail dot com) 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | __Barcode Flutter is a Flutter library for simple and fast Barcode rendering via custom painter__ 2 | 3 | ![screenshot](https://i.ibb.co/58S2psy/barcode-flutter.png) 4 |
5 | 6 | # Update Notes 7 | 1.1.2 8 | - Add Codabar support 9 | - Fix wrong pattern for value 102 of Code128 ([#20](https://github.com/bigship/barcode.flutter/issues/20)) 10 | 11 | 1.1.0 12 | - Add ITF support 13 | - Add BarCodeParams class for future expandability 14 | 15 | 1.0.2 16 | - Fix EAN8 code invalid checksum bug 17 | 18 | 1.0.1 19 | - Fix issue. Scanning problem when code128 contains character 'M' 20 | 21 | 1.0.0 22 | - Initial release 23 | 24 | # Features 25 | - Supports code type: __Code39__, __Code93__, __Code128__, __EAN13__, __EAN8__, __UPCA__, __UPCE__ 26 | - Supports render with or without text label 27 | - Supports adjusting the bar width 28 | - No internet connection required 29 | 30 | # Installing 31 | You can install the package by adding the following lines to your `pubspec.yaml`: 32 | 33 | ```yaml 34 | dependencies: 35 | barcode_flutter: ^1.1.2 36 | ``` 37 | 38 | After adding the dependency to your `pubspec.yaml` you can run: `flutter packages get` or update your packages using your IDE. 39 | 40 | # Getting started 41 | To start, import the dependency in your code: 42 | 43 | ```dart 44 | import 'package:barcode_flutter/barcode_flutter.dart'; 45 | ``` 46 | 47 | Next, to reander a Barcode (Code39 for example), you can use the following code: 48 | ```dart 49 | BarCodeImage( 50 | params: Code39BarCodeParams( 51 | "1234ABCD", 52 | lineWidth: 2.0, // width for a single black/white bar (default: 2.0) 53 | barHeight: 90.0, // height for the entire widget (default: 100.0) 54 | withText: true, // Render with text label or not (default: false) 55 | ), 56 | onError: (error) { // Error handler 57 | print('error = $error'); 58 | }, 59 | ); 60 | ``` 61 | 62 | __NOTE__: You can only tweak the lineWidth parameter to change the entire widget's width. But value less than `2.0` will sometimes make the barcode scaner more difficult to recognize result correctly. `2.0` is a safe value for all code types. 63 | 64 | __Error handling__: You have to make sure the code strings provided are valid. If you are not sure about the data, maybe it comes from 65 | user input or something, then setup onError method, and put your error handling logic there. Sometimes the library will render parts of 66 | the barcode if the data is invalid, and if that happens, I can't guarantee that the result can be recognized by a barcode scaner. 67 | 68 | # Example 69 | See the `example` directory for a basic working example. 70 | 71 | # FAQ 72 | ## Has it been tested in production? Can I use it in production? 73 | Yep! I've test it both on Android and iOS devices. Feel free to test it with any barcode scanner. 74 | 75 | ## How about the other barcode types ? 76 | I've only implemented some most commonly used barcode types. But feel free to send PR to include more barcode types. 77 | 78 | ## License 79 | Barcode flutter is released under [BSD license](http://opensource.org/licenses/BSD-2-Clause). See `LICENSE` for details. 80 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .dart_tool/ 3 | 4 | .packages 5 | .pub/ 6 | 7 | build/ 8 | 9 | .flutter-plugins 10 | -------------------------------------------------------------------------------- /example/.idea/libraries/Dart_SDK.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /example/.idea/libraries/Flutter_for_Android.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /example/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /example/.idea/runConfigurations/main_dart.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /example/.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: c7ea3ca377e909469c68f2ab878a5bc53d3cf66b 8 | channel: beta 9 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # example 2 | 3 | A new Flutter project. 4 | 5 | ## Getting Started 6 | 7 | For help getting started with Flutter, view our online 8 | [documentation](https://flutter.io/). 9 | -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | *.class 3 | .gradle 4 | /local.properties 5 | /.idea/workspace.xml 6 | /.idea/libraries 7 | .DS_Store 8 | /build 9 | /captures 10 | GeneratedPluginRegistrant.java 11 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | apply plugin: 'com.android.application' 15 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 16 | 17 | android { 18 | compileSdkVersion 28 19 | 20 | lintOptions { 21 | disable 'InvalidPackage' 22 | } 23 | 24 | defaultConfig { 25 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 26 | applicationId "com.example.example" 27 | minSdkVersion 16 28 | targetSdkVersion 27 29 | versionCode 1 30 | versionName "1.0" 31 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 32 | } 33 | 34 | buildTypes { 35 | release { 36 | // TODO: Add your own signing config for the release build. 37 | // Signing with the debug keys for now, so `flutter run --release` works. 38 | signingConfig signingConfigs.debug 39 | } 40 | } 41 | } 42 | 43 | flutter { 44 | source '../..' 45 | } 46 | 47 | dependencies { 48 | testImplementation 'junit:junit:4.12' 49 | androidTestImplementation 'com.android.support.test:runner:1.0.1' 50 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 51 | } 52 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 15 | 19 | 26 | 30 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/example/example/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.example; 2 | 3 | import android.os.Bundle; 4 | import io.flutter.app.FlutterActivity; 5 | import io.flutter.plugins.GeneratedPluginRegistrant; 6 | 7 | public class MainActivity extends FlutterActivity { 8 | @Override 9 | protected void onCreate(Bundle savedInstanceState) { 10 | super.onCreate(savedInstanceState); 11 | GeneratedPluginRegistrant.registerWith(this); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigship/barcode.flutter/384eef94834e2814de650f74c2f11a4797ede4f5/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigship/barcode.flutter/384eef94834e2814de650f74c2f11a4797ede4f5/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigship/barcode.flutter/384eef94834e2814de650f74c2f11a4797ede4f5/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigship/barcode.flutter/384eef94834e2814de650f74c2f11a4797ede4f5/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigship/barcode.flutter/384eef94834e2814de650f74c2f11a4797ede4f5/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | google() 4 | jcenter() 5 | } 6 | 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:3.5.3' 9 | } 10 | } 11 | 12 | allprojects { 13 | repositories { 14 | google() 15 | jcenter() 16 | } 17 | } 18 | 19 | rootProject.buildDir = '../build' 20 | subprojects { 21 | project.buildDir = "${rootProject.buildDir}/${project.name}" 22 | } 23 | subprojects { 24 | project.evaluationDependsOn(':app') 25 | } 26 | 27 | task clean(type: Delete) { 28 | delete rootProject.buildDir 29 | } 30 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.enableR8=true 3 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigship/barcode.flutter/384eef94834e2814de650f74c2f11a4797ede4f5/example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Dec 31 09:19:52 EST 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 7 | -------------------------------------------------------------------------------- /example/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /example/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() 4 | 5 | def plugins = new Properties() 6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') 7 | if (pluginsFile.exists()) { 8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } 9 | } 10 | 11 | plugins.each { name, path -> 12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() 13 | include ":$name" 14 | project(":$name").projectDir = pluginDirectory 15 | } 16 | -------------------------------------------------------------------------------- /example/example.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /example/example_android.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vagrant/ 3 | .sconsign.dblite 4 | .svn/ 5 | 6 | .DS_Store 7 | *.swp 8 | profile 9 | 10 | DerivedData/ 11 | build/ 12 | GeneratedPluginRegistrant.h 13 | GeneratedPluginRegistrant.m 14 | 15 | .generated/ 16 | 17 | *.pbxuser 18 | *.mode1v3 19 | *.mode2v3 20 | *.perspectivev3 21 | 22 | !default.pbxuser 23 | !default.mode1v3 24 | !default.mode2v3 25 | !default.perspectivev3 26 | 27 | xcuserdata 28 | 29 | *.moved-aside 30 | 31 | *.pyc 32 | *sync/ 33 | Icon? 34 | .tags* 35 | 36 | /Flutter/app.flx 37 | /Flutter/app.zip 38 | /Flutter/flutter_assets/ 39 | /Flutter/App.framework 40 | /Flutter/Flutter.framework 41 | /Flutter/Generated.xcconfig 42 | /ServiceDefinitions.json 43 | 44 | Pods/ 45 | .symlinks/ 46 | -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/ios/Flutter/Flutter.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: This podspec is NOT to be published. It is only used as a local source! 3 | # 4 | 5 | Pod::Spec.new do |s| 6 | s.name = 'Flutter' 7 | s.version = '1.0.0' 8 | s.summary = 'High-performance, high-fidelity mobile apps.' 9 | s.description = <<-DESC 10 | Flutter provides an easy and productive way to build and deploy high-performance mobile apps for Android and iOS. 11 | DESC 12 | s.homepage = 'https://flutter.io' 13 | s.license = { :type => 'MIT' } 14 | s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' } 15 | s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s } 16 | s.ios.deployment_target = '8.0' 17 | s.vendored_frameworks = 'Flutter.framework' 18 | end 19 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 11 | 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; }; 12 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 13 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; 14 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 15 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; 16 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 17 | 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; }; 18 | 9740EEB51CF90195004384FC /* Generated.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB31CF90195004384FC /* Generated.xcconfig */; }; 19 | 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; 20 | 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; 21 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 22 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 23 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 24 | /* End PBXBuildFile section */ 25 | 26 | /* Begin PBXCopyFilesBuildPhase section */ 27 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 28 | isa = PBXCopyFilesBuildPhase; 29 | buildActionMask = 2147483647; 30 | dstPath = ""; 31 | dstSubfolderSpec = 10; 32 | files = ( 33 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, 34 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, 35 | ); 36 | name = "Embed Frameworks"; 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXCopyFilesBuildPhase section */ 40 | 41 | /* Begin PBXFileReference section */ 42 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 43 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 44 | 2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; }; 45 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 46 | 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; 47 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 48 | 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 49 | 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 50 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 51 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 52 | 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; 53 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 54 | 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 55 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 56 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 57 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 58 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 59 | /* End PBXFileReference section */ 60 | 61 | /* Begin PBXFrameworksBuildPhase section */ 62 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 63 | isa = PBXFrameworksBuildPhase; 64 | buildActionMask = 2147483647; 65 | files = ( 66 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, 67 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, 68 | ); 69 | runOnlyForDeploymentPostprocessing = 0; 70 | }; 71 | /* End PBXFrameworksBuildPhase section */ 72 | 73 | /* Begin PBXGroup section */ 74 | 9740EEB11CF90186004384FC /* Flutter */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | 2D5378251FAA1A9400D5DBA9 /* flutter_assets */, 78 | 3B80C3931E831B6300D905FE /* App.framework */, 79 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 80 | 9740EEBA1CF902C7004384FC /* Flutter.framework */, 81 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 82 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 83 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 84 | ); 85 | name = Flutter; 86 | sourceTree = ""; 87 | }; 88 | 97C146E51CF9000F007C117D = { 89 | isa = PBXGroup; 90 | children = ( 91 | 9740EEB11CF90186004384FC /* Flutter */, 92 | 97C146F01CF9000F007C117D /* Runner */, 93 | 97C146EF1CF9000F007C117D /* Products */, 94 | ); 95 | sourceTree = ""; 96 | }; 97 | 97C146EF1CF9000F007C117D /* Products */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | 97C146EE1CF9000F007C117D /* Runner.app */, 101 | ); 102 | name = Products; 103 | sourceTree = ""; 104 | }; 105 | 97C146F01CF9000F007C117D /* Runner */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */, 109 | 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */, 110 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 111 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 112 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 113 | 97C147021CF9000F007C117D /* Info.plist */, 114 | 97C146F11CF9000F007C117D /* Supporting Files */, 115 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 116 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 117 | ); 118 | path = Runner; 119 | sourceTree = ""; 120 | }; 121 | 97C146F11CF9000F007C117D /* Supporting Files */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | 97C146F21CF9000F007C117D /* main.m */, 125 | ); 126 | name = "Supporting Files"; 127 | sourceTree = ""; 128 | }; 129 | /* End PBXGroup section */ 130 | 131 | /* Begin PBXNativeTarget section */ 132 | 97C146ED1CF9000F007C117D /* Runner */ = { 133 | isa = PBXNativeTarget; 134 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 135 | buildPhases = ( 136 | 9740EEB61CF901F6004384FC /* Run Script */, 137 | 97C146EA1CF9000F007C117D /* Sources */, 138 | 97C146EB1CF9000F007C117D /* Frameworks */, 139 | 97C146EC1CF9000F007C117D /* Resources */, 140 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 141 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 142 | ); 143 | buildRules = ( 144 | ); 145 | dependencies = ( 146 | ); 147 | name = Runner; 148 | productName = Runner; 149 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 150 | productType = "com.apple.product-type.application"; 151 | }; 152 | /* End PBXNativeTarget section */ 153 | 154 | /* Begin PBXProject section */ 155 | 97C146E61CF9000F007C117D /* Project object */ = { 156 | isa = PBXProject; 157 | attributes = { 158 | LastUpgradeCheck = 0910; 159 | ORGANIZATIONNAME = "The Chromium Authors"; 160 | TargetAttributes = { 161 | 97C146ED1CF9000F007C117D = { 162 | CreatedOnToolsVersion = 7.3.1; 163 | DevelopmentTeam = VYAE492B4V; 164 | }; 165 | }; 166 | }; 167 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 168 | compatibilityVersion = "Xcode 3.2"; 169 | developmentRegion = English; 170 | hasScannedForEncodings = 0; 171 | knownRegions = ( 172 | en, 173 | Base, 174 | ); 175 | mainGroup = 97C146E51CF9000F007C117D; 176 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 177 | projectDirPath = ""; 178 | projectRoot = ""; 179 | targets = ( 180 | 97C146ED1CF9000F007C117D /* Runner */, 181 | ); 182 | }; 183 | /* End PBXProject section */ 184 | 185 | /* Begin PBXResourcesBuildPhase section */ 186 | 97C146EC1CF9000F007C117D /* Resources */ = { 187 | isa = PBXResourcesBuildPhase; 188 | buildActionMask = 2147483647; 189 | files = ( 190 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 191 | 9740EEB51CF90195004384FC /* Generated.xcconfig in Resources */, 192 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 193 | 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */, 194 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 195 | 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */, 196 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 197 | ); 198 | runOnlyForDeploymentPostprocessing = 0; 199 | }; 200 | /* End PBXResourcesBuildPhase section */ 201 | 202 | /* Begin PBXShellScriptBuildPhase section */ 203 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 204 | isa = PBXShellScriptBuildPhase; 205 | buildActionMask = 2147483647; 206 | files = ( 207 | ); 208 | inputPaths = ( 209 | ); 210 | name = "Thin Binary"; 211 | outputPaths = ( 212 | ); 213 | runOnlyForDeploymentPostprocessing = 0; 214 | shellPath = /bin/sh; 215 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; 216 | }; 217 | 9740EEB61CF901F6004384FC /* Run Script */ = { 218 | isa = PBXShellScriptBuildPhase; 219 | buildActionMask = 2147483647; 220 | files = ( 221 | ); 222 | inputPaths = ( 223 | ); 224 | name = "Run Script"; 225 | outputPaths = ( 226 | ); 227 | runOnlyForDeploymentPostprocessing = 0; 228 | shellPath = /bin/sh; 229 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 230 | }; 231 | /* End PBXShellScriptBuildPhase section */ 232 | 233 | /* Begin PBXSourcesBuildPhase section */ 234 | 97C146EA1CF9000F007C117D /* Sources */ = { 235 | isa = PBXSourcesBuildPhase; 236 | buildActionMask = 2147483647; 237 | files = ( 238 | 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */, 239 | 97C146F31CF9000F007C117D /* main.m in Sources */, 240 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 241 | ); 242 | runOnlyForDeploymentPostprocessing = 0; 243 | }; 244 | /* End PBXSourcesBuildPhase section */ 245 | 246 | /* Begin PBXVariantGroup section */ 247 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 248 | isa = PBXVariantGroup; 249 | children = ( 250 | 97C146FB1CF9000F007C117D /* Base */, 251 | ); 252 | name = Main.storyboard; 253 | sourceTree = ""; 254 | }; 255 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 256 | isa = PBXVariantGroup; 257 | children = ( 258 | 97C147001CF9000F007C117D /* Base */, 259 | ); 260 | name = LaunchScreen.storyboard; 261 | sourceTree = ""; 262 | }; 263 | /* End PBXVariantGroup section */ 264 | 265 | /* Begin XCBuildConfiguration section */ 266 | 97C147031CF9000F007C117D /* Debug */ = { 267 | isa = XCBuildConfiguration; 268 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 269 | buildSettings = { 270 | ALWAYS_SEARCH_USER_PATHS = NO; 271 | CLANG_ANALYZER_NONNULL = YES; 272 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 273 | CLANG_CXX_LIBRARY = "libc++"; 274 | CLANG_ENABLE_MODULES = YES; 275 | CLANG_ENABLE_OBJC_ARC = YES; 276 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 277 | CLANG_WARN_BOOL_CONVERSION = YES; 278 | CLANG_WARN_COMMA = YES; 279 | CLANG_WARN_CONSTANT_CONVERSION = YES; 280 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 281 | CLANG_WARN_EMPTY_BODY = YES; 282 | CLANG_WARN_ENUM_CONVERSION = YES; 283 | CLANG_WARN_INFINITE_RECURSION = YES; 284 | CLANG_WARN_INT_CONVERSION = YES; 285 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 286 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 287 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 288 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 289 | CLANG_WARN_STRICT_PROTOTYPES = YES; 290 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 291 | CLANG_WARN_UNREACHABLE_CODE = YES; 292 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 293 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 294 | COPY_PHASE_STRIP = NO; 295 | DEBUG_INFORMATION_FORMAT = dwarf; 296 | ENABLE_STRICT_OBJC_MSGSEND = YES; 297 | ENABLE_TESTABILITY = YES; 298 | GCC_C_LANGUAGE_STANDARD = gnu99; 299 | GCC_DYNAMIC_NO_PIC = NO; 300 | GCC_NO_COMMON_BLOCKS = YES; 301 | GCC_OPTIMIZATION_LEVEL = 0; 302 | GCC_PREPROCESSOR_DEFINITIONS = ( 303 | "DEBUG=1", 304 | "$(inherited)", 305 | ); 306 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 307 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 308 | GCC_WARN_UNDECLARED_SELECTOR = YES; 309 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 310 | GCC_WARN_UNUSED_FUNCTION = YES; 311 | GCC_WARN_UNUSED_VARIABLE = YES; 312 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 313 | MTL_ENABLE_DEBUG_INFO = YES; 314 | ONLY_ACTIVE_ARCH = YES; 315 | SDKROOT = iphoneos; 316 | TARGETED_DEVICE_FAMILY = "1,2"; 317 | }; 318 | name = Debug; 319 | }; 320 | 97C147041CF9000F007C117D /* Release */ = { 321 | isa = XCBuildConfiguration; 322 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 323 | buildSettings = { 324 | ALWAYS_SEARCH_USER_PATHS = NO; 325 | CLANG_ANALYZER_NONNULL = YES; 326 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 327 | CLANG_CXX_LIBRARY = "libc++"; 328 | CLANG_ENABLE_MODULES = YES; 329 | CLANG_ENABLE_OBJC_ARC = YES; 330 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 331 | CLANG_WARN_BOOL_CONVERSION = YES; 332 | CLANG_WARN_COMMA = YES; 333 | CLANG_WARN_CONSTANT_CONVERSION = YES; 334 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 335 | CLANG_WARN_EMPTY_BODY = YES; 336 | CLANG_WARN_ENUM_CONVERSION = YES; 337 | CLANG_WARN_INFINITE_RECURSION = YES; 338 | CLANG_WARN_INT_CONVERSION = YES; 339 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 340 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 341 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 342 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 343 | CLANG_WARN_STRICT_PROTOTYPES = YES; 344 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 345 | CLANG_WARN_UNREACHABLE_CODE = YES; 346 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 347 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 348 | COPY_PHASE_STRIP = NO; 349 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 350 | ENABLE_NS_ASSERTIONS = NO; 351 | ENABLE_STRICT_OBJC_MSGSEND = YES; 352 | GCC_C_LANGUAGE_STANDARD = gnu99; 353 | GCC_NO_COMMON_BLOCKS = YES; 354 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 355 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 356 | GCC_WARN_UNDECLARED_SELECTOR = YES; 357 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 358 | GCC_WARN_UNUSED_FUNCTION = YES; 359 | GCC_WARN_UNUSED_VARIABLE = YES; 360 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 361 | MTL_ENABLE_DEBUG_INFO = NO; 362 | SDKROOT = iphoneos; 363 | TARGETED_DEVICE_FAMILY = "1,2"; 364 | VALIDATE_PRODUCT = YES; 365 | }; 366 | name = Release; 367 | }; 368 | 97C147061CF9000F007C117D /* Debug */ = { 369 | isa = XCBuildConfiguration; 370 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 371 | buildSettings = { 372 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 373 | CURRENT_PROJECT_VERSION = 1; 374 | DEVELOPMENT_TEAM = VYAE492B4V; 375 | ENABLE_BITCODE = NO; 376 | FRAMEWORK_SEARCH_PATHS = ( 377 | "$(inherited)", 378 | "$(PROJECT_DIR)/Flutter", 379 | ); 380 | INFOPLIST_FILE = Runner/Info.plist; 381 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 382 | LIBRARY_SEARCH_PATHS = ( 383 | "$(inherited)", 384 | "$(PROJECT_DIR)/Flutter", 385 | ); 386 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example; 387 | PRODUCT_NAME = "$(TARGET_NAME)"; 388 | VERSIONING_SYSTEM = "apple-generic"; 389 | }; 390 | name = Debug; 391 | }; 392 | 97C147071CF9000F007C117D /* Release */ = { 393 | isa = XCBuildConfiguration; 394 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 395 | buildSettings = { 396 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 397 | CURRENT_PROJECT_VERSION = 1; 398 | DEVELOPMENT_TEAM = VYAE492B4V; 399 | ENABLE_BITCODE = NO; 400 | FRAMEWORK_SEARCH_PATHS = ( 401 | "$(inherited)", 402 | "$(PROJECT_DIR)/Flutter", 403 | ); 404 | INFOPLIST_FILE = Runner/Info.plist; 405 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 406 | LIBRARY_SEARCH_PATHS = ( 407 | "$(inherited)", 408 | "$(PROJECT_DIR)/Flutter", 409 | ); 410 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example; 411 | PRODUCT_NAME = "$(TARGET_NAME)"; 412 | VERSIONING_SYSTEM = "apple-generic"; 413 | }; 414 | name = Release; 415 | }; 416 | /* End XCBuildConfiguration section */ 417 | 418 | /* Begin XCConfigurationList section */ 419 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 420 | isa = XCConfigurationList; 421 | buildConfigurations = ( 422 | 97C147031CF9000F007C117D /* Debug */, 423 | 97C147041CF9000F007C117D /* Release */, 424 | ); 425 | defaultConfigurationIsVisible = 0; 426 | defaultConfigurationName = Release; 427 | }; 428 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 429 | isa = XCConfigurationList; 430 | buildConfigurations = ( 431 | 97C147061CF9000F007C117D /* Debug */, 432 | 97C147071CF9000F007C117D /* Release */, 433 | ); 434 | defaultConfigurationIsVisible = 0; 435 | defaultConfigurationName = Release; 436 | }; 437 | /* End XCConfigurationList section */ 438 | }; 439 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 440 | } 441 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 33 | 34 | 40 | 41 | 42 | 43 | 44 | 45 | 56 | 58 | 64 | 65 | 66 | 67 | 68 | 69 | 75 | 77 | 83 | 84 | 85 | 86 | 88 | 89 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : FlutterAppDelegate 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #include "AppDelegate.h" 2 | #include "GeneratedPluginRegistrant.h" 3 | 4 | @implementation AppDelegate 5 | 6 | - (BOOL)application:(UIApplication *)application 7 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 8 | [GeneratedPluginRegistrant registerWithRegistry:self]; 9 | // Override point for customization after application launch. 10 | return [super application:application didFinishLaunchingWithOptions:launchOptions]; 11 | } 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigship/barcode.flutter/384eef94834e2814de650f74c2f11a4797ede4f5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigship/barcode.flutter/384eef94834e2814de650f74c2f11a4797ede4f5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigship/barcode.flutter/384eef94834e2814de650f74c2f11a4797ede4f5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigship/barcode.flutter/384eef94834e2814de650f74c2f11a4797ede4f5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigship/barcode.flutter/384eef94834e2814de650f74c2f11a4797ede4f5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigship/barcode.flutter/384eef94834e2814de650f74c2f11a4797ede4f5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigship/barcode.flutter/384eef94834e2814de650f74c2f11a4797ede4f5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigship/barcode.flutter/384eef94834e2814de650f74c2f11a4797ede4f5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigship/barcode.flutter/384eef94834e2814de650f74c2f11a4797ede4f5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigship/barcode.flutter/384eef94834e2814de650f74c2f11a4797ede4f5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigship/barcode.flutter/384eef94834e2814de650f74c2f11a4797ede4f5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigship/barcode.flutter/384eef94834e2814de650f74c2f11a4797ede4f5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigship/barcode.flutter/384eef94834e2814de650f74c2f11a4797ede4f5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigship/barcode.flutter/384eef94834e2814de650f74c2f11a4797ede4f5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigship/barcode.flutter/384eef94834e2814de650f74c2f11a4797ede4f5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigship/barcode.flutter/384eef94834e2814de650f74c2f11a4797ede4f5/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigship/barcode.flutter/384eef94834e2814de650f74c2f11a4797ede4f5/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigship/barcode.flutter/384eef94834e2814de650f74c2f11a4797ede4f5/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | example 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /example/ios/Runner/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char* argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:barcode_flutter/barcode_flutter.dart'; 3 | 4 | void main() => runApp(MyApp()); 5 | 6 | class MyApp extends StatelessWidget { 7 | @override 8 | Widget build(BuildContext context) { 9 | return MaterialApp( 10 | title: 'Barcode Flutter Demo', 11 | theme: ThemeData( 12 | primarySwatch: Colors.blue, 13 | ), 14 | home: MyHomePage( 15 | barcodes: [ 16 | BarCodeItem( 17 | description: "Code39 with text", 18 | image: BarCodeImage( 19 | params: Code39BarCodeParams( 20 | "CODE39", 21 | withText: true, 22 | ), 23 | ), 24 | ), 25 | BarCodeItem( 26 | description: "Code39", 27 | image: BarCodeImage( 28 | params: Code39BarCodeParams( 29 | "CODE39", 30 | ), 31 | ), 32 | ), 33 | BarCodeItem( 34 | description: "Code39 with text", 35 | image: BarCodeImage( 36 | params: Code93BarCodeParams( 37 | "CODE93", 38 | withText: true, 39 | ), 40 | ), 41 | ), 42 | BarCodeItem( 43 | description: "Code93", 44 | image: BarCodeImage( 45 | params: Code93BarCodeParams( 46 | "CODE93", 47 | ), 48 | ), 49 | ), 50 | BarCodeItem( 51 | description: "Code128 with text", 52 | image: BarCodeImage( 53 | params: Code128BarCodeParams( 54 | "CODE128", 55 | withText: true, 56 | ), 57 | ), 58 | ), 59 | BarCodeItem( 60 | description: "Code128", 61 | image: BarCodeImage( 62 | params: Code128BarCodeParams( 63 | "CODE128", 64 | ), 65 | ), 66 | ), 67 | BarCodeItem( 68 | description: "EAN8 with text", 69 | image: BarCodeImage( 70 | params: EAN8BarCodeParams( 71 | "65833254", 72 | withText: true, 73 | ), 74 | ), 75 | ), 76 | BarCodeItem( 77 | description: "EAN8", 78 | image: BarCodeImage( 79 | params: EAN8BarCodeParams( 80 | "65833254", 81 | ), 82 | ), 83 | ), 84 | BarCodeItem( 85 | description: "EAN13 with text", 86 | image: BarCodeImage( 87 | params: EAN13BarCodeParams( 88 | "9501101530003", 89 | withText: true, 90 | ), 91 | ), 92 | ), 93 | BarCodeItem( 94 | description: "EAN13", 95 | image: BarCodeImage( 96 | params: EAN13BarCodeParams( 97 | "9501101530003", 98 | ), 99 | ), 100 | ), 101 | BarCodeItem( 102 | description: "UPCA with text", 103 | image: BarCodeImage( 104 | params: UPCABarCodeParams( 105 | "123456789012", 106 | withText: true, 107 | ), 108 | ), 109 | ), 110 | BarCodeItem( 111 | description: "UPCA", 112 | image: BarCodeImage( 113 | params: UPCABarCodeParams( 114 | "123456789012", 115 | ), 116 | ), 117 | ), 118 | BarCodeItem( 119 | description: "UPCE with text", 120 | image: BarCodeImage( 121 | params: UPCEBarCodeParams( 122 | "00123457", 123 | withText: true, 124 | ), 125 | ), 126 | ), 127 | BarCodeItem( 128 | description: "UPCE", 129 | image: BarCodeImage( 130 | params: UPCEBarCodeParams( 131 | "00123457", 132 | ), 133 | ), 134 | ), 135 | BarCodeItem( 136 | description: "ITF with text", 137 | image: BarCodeImage( 138 | params: ITFBarCodeParams( 139 | "133175398642265258", 140 | withText: true, 141 | ), 142 | ), 143 | ), 144 | BarCodeItem( 145 | description: "ITF", 146 | image: BarCodeImage( 147 | params: ITFBarCodeParams( 148 | "133175398642265258", 149 | ), 150 | ), 151 | ), 152 | BarCodeItem( 153 | description: "Codabar with text", 154 | image: BarCodeImage( 155 | params: CodabarBarCodeParams( 156 | "A123456789B", 157 | withText: true, 158 | ), 159 | ) 160 | ), 161 | BarCodeItem( 162 | description: "Codabar", 163 | image: BarCodeImage( 164 | params: CodabarBarCodeParams( 165 | "A123456789B", 166 | ), 167 | ) 168 | ) 169 | ], 170 | ), 171 | ); 172 | } 173 | } 174 | 175 | class MyHomePage extends StatefulWidget { 176 | MyHomePage({this.barcodes}); 177 | final List barcodes; 178 | final String title = "BarCode Flutter"; 179 | 180 | @override 181 | _MyHomePageState createState() => _MyHomePageState(); 182 | } 183 | 184 | class _MyHomePageState extends State { 185 | @override 186 | Widget build(BuildContext context) { 187 | return Scaffold( 188 | appBar: AppBar( 189 | title: Text(widget.title), 190 | ), 191 | body: ListView( 192 | children: widget.barcodes.map((element) { 193 | return Padding( 194 | padding: const EdgeInsets.all(10.0), 195 | child: Card( 196 | child: Column( 197 | children: [ 198 | Align( 199 | alignment: Alignment.centerLeft, 200 | child: Text( 201 | element.description, 202 | textAlign: TextAlign.left, 203 | style: TextStyle( 204 | fontWeight: FontWeight.bold, 205 | fontSize: 20.0, 206 | color: Colors.black45, 207 | ), 208 | ), 209 | ), 210 | Center( 211 | child: Container( 212 | padding: const EdgeInsets.all(10.0), 213 | child: element.image, 214 | ), 215 | ) 216 | ], 217 | ), 218 | ), 219 | ); 220 | }).toList(), 221 | ), 222 | ); 223 | } 224 | } 225 | 226 | class BarCodeItem { 227 | String description; 228 | BarCodeImage image; 229 | BarCodeItem({ 230 | this.image, 231 | this.description, 232 | }); 233 | } 234 | -------------------------------------------------------------------------------- /example/pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | archive: 5 | dependency: transitive 6 | description: 7 | name: archive 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "2.0.11" 11 | args: 12 | dependency: transitive 13 | description: 14 | name: args 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "1.5.2" 18 | async: 19 | dependency: transitive 20 | description: 21 | name: async 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "2.4.0" 25 | barcode_flutter: 26 | dependency: "direct main" 27 | description: 28 | path: ".." 29 | relative: true 30 | source: path 31 | version: "1.1.2" 32 | boolean_selector: 33 | dependency: transitive 34 | description: 35 | name: boolean_selector 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "1.0.5" 39 | charcode: 40 | dependency: transitive 41 | description: 42 | name: charcode 43 | url: "https://pub.dartlang.org" 44 | source: hosted 45 | version: "1.1.2" 46 | collection: 47 | dependency: transitive 48 | description: 49 | name: collection 50 | url: "https://pub.dartlang.org" 51 | source: hosted 52 | version: "1.14.11" 53 | convert: 54 | dependency: transitive 55 | description: 56 | name: convert 57 | url: "https://pub.dartlang.org" 58 | source: hosted 59 | version: "2.1.1" 60 | crypto: 61 | dependency: transitive 62 | description: 63 | name: crypto 64 | url: "https://pub.dartlang.org" 65 | source: hosted 66 | version: "2.1.3" 67 | cupertino_icons: 68 | dependency: "direct main" 69 | description: 70 | name: cupertino_icons 71 | url: "https://pub.dartlang.org" 72 | source: hosted 73 | version: "0.1.2" 74 | flutter: 75 | dependency: "direct main" 76 | description: flutter 77 | source: sdk 78 | version: "0.0.0" 79 | flutter_test: 80 | dependency: "direct dev" 81 | description: flutter 82 | source: sdk 83 | version: "0.0.0" 84 | image: 85 | dependency: transitive 86 | description: 87 | name: image 88 | url: "https://pub.dartlang.org" 89 | source: hosted 90 | version: "2.1.4" 91 | matcher: 92 | dependency: transitive 93 | description: 94 | name: matcher 95 | url: "https://pub.dartlang.org" 96 | source: hosted 97 | version: "0.12.6" 98 | meta: 99 | dependency: transitive 100 | description: 101 | name: meta 102 | url: "https://pub.dartlang.org" 103 | source: hosted 104 | version: "1.1.8" 105 | path: 106 | dependency: transitive 107 | description: 108 | name: path 109 | url: "https://pub.dartlang.org" 110 | source: hosted 111 | version: "1.6.4" 112 | pedantic: 113 | dependency: transitive 114 | description: 115 | name: pedantic 116 | url: "https://pub.dartlang.org" 117 | source: hosted 118 | version: "1.8.0+1" 119 | petitparser: 120 | dependency: transitive 121 | description: 122 | name: petitparser 123 | url: "https://pub.dartlang.org" 124 | source: hosted 125 | version: "2.4.0" 126 | quiver: 127 | dependency: transitive 128 | description: 129 | name: quiver 130 | url: "https://pub.dartlang.org" 131 | source: hosted 132 | version: "2.0.5" 133 | sky_engine: 134 | dependency: transitive 135 | description: flutter 136 | source: sdk 137 | version: "0.0.99" 138 | source_span: 139 | dependency: transitive 140 | description: 141 | name: source_span 142 | url: "https://pub.dartlang.org" 143 | source: hosted 144 | version: "1.5.5" 145 | stack_trace: 146 | dependency: transitive 147 | description: 148 | name: stack_trace 149 | url: "https://pub.dartlang.org" 150 | source: hosted 151 | version: "1.9.3" 152 | stream_channel: 153 | dependency: transitive 154 | description: 155 | name: stream_channel 156 | url: "https://pub.dartlang.org" 157 | source: hosted 158 | version: "2.0.0" 159 | string_scanner: 160 | dependency: transitive 161 | description: 162 | name: string_scanner 163 | url: "https://pub.dartlang.org" 164 | source: hosted 165 | version: "1.0.5" 166 | term_glyph: 167 | dependency: transitive 168 | description: 169 | name: term_glyph 170 | url: "https://pub.dartlang.org" 171 | source: hosted 172 | version: "1.1.0" 173 | test_api: 174 | dependency: transitive 175 | description: 176 | name: test_api 177 | url: "https://pub.dartlang.org" 178 | source: hosted 179 | version: "0.2.11" 180 | typed_data: 181 | dependency: transitive 182 | description: 183 | name: typed_data 184 | url: "https://pub.dartlang.org" 185 | source: hosted 186 | version: "1.1.6" 187 | vector_math: 188 | dependency: transitive 189 | description: 190 | name: vector_math 191 | url: "https://pub.dartlang.org" 192 | source: hosted 193 | version: "2.0.8" 194 | xml: 195 | dependency: transitive 196 | description: 197 | name: xml 198 | url: "https://pub.dartlang.org" 199 | source: hosted 200 | version: "3.5.0" 201 | sdks: 202 | dart: ">=2.4.0 <3.0.0" 203 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: barcode_flutter_demo 2 | description: Demo project for the Flutter Barcode library. 3 | 4 | dependencies: 5 | flutter: 6 | sdk: flutter 7 | barcode_flutter: 8 | path: .. 9 | 10 | # The following adds the Cupertino Icons font to your application. 11 | # Use with the CupertinoIcons class for iOS style icons. 12 | cupertino_icons: ^0.1.2 13 | 14 | dev_dependencies: 15 | flutter_test: 16 | sdk: flutter 17 | 18 | 19 | # For information on the generic Dart part of this file, see the 20 | # following page: https://www.dartlang.org/tools/pub/pubspec 21 | 22 | # The following section is specific to Flutter. 23 | flutter: 24 | 25 | # The following line ensures that the Material Icons font is 26 | # included with your application, so that you can use the icons in 27 | # the material Icons class. 28 | uses-material-design: true 29 | 30 | # To add assets to your application, add an assets section, like this: 31 | # assets: 32 | # - images/a_dot_burr.jpeg 33 | # - images/a_dot_ham.jpeg 34 | 35 | # An image asset can refer to one or more resolution-specific "variants", see 36 | # https://flutter.io/assets-and-images/#resolution-aware. 37 | 38 | # For details regarding adding assets from package dependencies, see 39 | # https://flutter.io/assets-and-images/#from-packages 40 | 41 | # To add custom fonts to your application, add a fonts section here, 42 | # in this "flutter" section. Each entry in this list should have a 43 | # "family" key with the font family name, and a "fonts" key with a 44 | # list giving the asset and other descriptors for the font. For 45 | # example: 46 | # fonts: 47 | # - family: Schyler 48 | # fonts: 49 | # - asset: fonts/Schyler-Regular.ttf 50 | # - asset: fonts/Schyler-Italic.ttf 51 | # style: italic 52 | # - family: Trajan Pro 53 | # fonts: 54 | # - asset: fonts/TrajanPro.ttf 55 | # - asset: fonts/TrajanPro_Bold.ttf 56 | # weight: 700 57 | # 58 | # For details regarding fonts from package dependencies, 59 | # see https://flutter.io/custom-fonts/#from-packages 60 | -------------------------------------------------------------------------------- /example/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // To perform an interaction with a widget in your test, use the WidgetTester utility that Flutter 3 | // provides. For example, you can send tap and scroll gestures. You can also use WidgetTester to 4 | // find child widgets in the widget tree, read text, and verify that the values of widget properties 5 | // are correct. 6 | 7 | import 'package:flutter/material.dart'; 8 | import 'package:flutter_test/flutter_test.dart'; 9 | 10 | import 'package:barcode_flutter_demo/main.dart'; 11 | 12 | void main() { 13 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 14 | // Build our app and trigger a frame. 15 | await tester.pumpWidget(new MyApp()); 16 | 17 | // Verify that our counter starts at 0. 18 | expect(find.text('0'), findsOneWidget); 19 | expect(find.text('1'), findsNothing); 20 | 21 | // Tap the '+' icon and trigger a frame. 22 | await tester.tap(find.byIcon(Icons.add)); 23 | await tester.pump(); 24 | 25 | // Verify that our counter has incremented. 26 | expect(find.text('0'), findsNothing); 27 | expect(find.text('1'), findsOneWidget); 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /lib/barcode_flutter.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Flutter BarCode generator 3 | * Copyright (c) 2018 the BarCode Flutter authors. 4 | * See LICENSE for distribution and usage details. 5 | */ 6 | 7 | export 'src/barcode_params.dart'; 8 | export 'src/barcode_image.dart'; 9 | export 'src/barcode_painter.dart'; 10 | export 'src/barcode_enum.dart'; 11 | -------------------------------------------------------------------------------- /lib/src/barcode_enum.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Flutter BarCode Widget 3 | * Copyright (c) 2018 the BarCode Flutter authors. 4 | * See LICENSE for distribution and usage details. 5 | */ 6 | 7 | enum BarCodeType { 8 | CodeEAN13, 9 | CodeEAN8, 10 | Code39, 11 | Code93, 12 | CodeUPCA, 13 | CodeUPCE, 14 | Code128, 15 | Codabar 16 | } 17 | -------------------------------------------------------------------------------- /lib/src/barcode_image.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Flutter BarCode generator 3 | * Copyright (c) 2018 the BarCode Flutter authors. 4 | * See LICENSE for distribution and usage details. 5 | */ 6 | 7 | import 'package:barcode_flutter/barcode_flutter.dart'; 8 | import 'package:barcode_flutter/src/barcode_enum.dart'; 9 | import 'package:flutter/widgets.dart'; 10 | import 'barcode_painter.dart'; 11 | import 'barcode_params.dart'; 12 | 13 | /// A barcode custom painter 14 | /// 15 | /// ## BarCodeParam Types 16 | /// ```dart 17 | /// EAN13 18 | /// EAN8 19 | /// Code39 20 | /// Code93 21 | /// Code128 22 | /// UPCA 23 | /// UPCE 24 | /// ITF 25 | /// Codabar 26 | /// ```` 27 | /// 28 | /// ### Basic usage 29 | /// ```dart 30 | /// BarCodeImage( 31 | /// ITFBarCodeParams( 32 | /// "15400141288763", 33 | /// ) 34 | /// ) 35 | /// ``` 36 | class BarCodeImage extends StatelessWidget { 37 | BarCodeImage({ 38 | @deprecated this.data, 39 | @deprecated this.codeType, 40 | @deprecated this.lineWidth = 2.0, 41 | @deprecated this.barHeight = 100.0, 42 | @deprecated this.hasText = false, 43 | BarCodeParams params, 44 | this.padding, 45 | this.backgroundColor, 46 | Color foregroundColor = const Color(0xFF000000), 47 | this.onError, 48 | }) : assert(params != null || (data != null && codeType != null), "params or data+codeType must be set"), 49 | assert( 50 | (params != null && data == null && codeType == null) || 51 | (params == null && data != null && codeType != null), 52 | "params and data+codeType cannot be set at the same time"), 53 | _painter = BarCodePainter( 54 | params ?? _getBarcodeParams(codeType, data, lineWidth, barHeight, hasText), foregroundColor, 55 | onError: onError); 56 | 57 | /// deprecated params 58 | final String data; 59 | final BarCodeType codeType; 60 | final double lineWidth; 61 | final double barHeight; 62 | final bool hasText; 63 | 64 | T get params => _painter.params; 65 | 66 | final BarCodePainter _painter; 67 | final Color backgroundColor; 68 | 69 | final EdgeInsets padding; 70 | final BarCodeError onError; 71 | 72 | static BarCodeParams _getBarcodeParams( 73 | BarCodeType type, String data, double lineWidth, double barHeight, bool hasText) { 74 | switch (type) { 75 | case BarCodeType.CodeEAN13: 76 | return EAN13BarCodeParams(data, withText: hasText, lineWidth: lineWidth, barHeight: barHeight); 77 | case BarCodeType.CodeEAN8: 78 | return EAN8BarCodeParams(data, withText: hasText, lineWidth: lineWidth, barHeight: barHeight); 79 | case BarCodeType.Code39: 80 | return Code39BarCodeParams(data, withText: hasText, lineWidth: lineWidth, barHeight: barHeight); 81 | case BarCodeType.Code93: 82 | return Code93BarCodeParams(data, withText: hasText, lineWidth: lineWidth, barHeight: barHeight); 83 | case BarCodeType.CodeUPCA: 84 | return UPCABarCodeParams(data, withText: hasText, lineWidth: lineWidth, barHeight: barHeight); 85 | case BarCodeType.CodeUPCE: 86 | return UPCEBarCodeParams(data, withText: hasText, lineWidth: lineWidth, barHeight: barHeight); 87 | case BarCodeType.Code128: 88 | return Code128BarCodeParams(data, withText: hasText, lineWidth: lineWidth, barHeight: barHeight); 89 | case BarCodeType.Codabar: 90 | return CodabarBarCodeParams(data, withText: hasText, lineWidth: lineWidth, barHeight: barHeight); 91 | } 92 | return null; 93 | } 94 | 95 | @override 96 | Widget build(BuildContext context) { 97 | return Container( 98 | width: params.barCodeWidth + (padding?.left ?? 0) + (padding?.right ?? 0), 99 | height: params.barHeight + (padding?.top ?? 0) + (padding?.bottom ?? 0), 100 | decoration: BoxDecoration( 101 | color: backgroundColor, 102 | ), 103 | padding: padding, 104 | child: CustomPaint( 105 | painter: _painter, 106 | ), 107 | ); 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /lib/src/barcode_painter.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Flutter BarCode generator 3 | * Copyright (c) 2018 the BarCode Flutter authors. 4 | * See LICENSE for distribution and usage details. 5 | */ 6 | 7 | import 'package:barcode_flutter/barcode_flutter.dart'; 8 | import 'package:flutter/material.dart'; 9 | import 'dart:typed_data'; 10 | 11 | typedef void BarCodeError(dynamic error); 12 | 13 | class BarCodePainter extends CustomPainter { 14 | BarCodePainter(this.params, this.color, {this.onError}); 15 | 16 | final BarCodeParams params; 17 | final Color color; 18 | final BarCodeError onError; 19 | 20 | @override 21 | void paint(Canvas canvas, Size size) { 22 | /// https://github.com/dart-lang/sdk/issues/2949 😭 23 | 24 | if (params is Code39BarCodeParams) { 25 | _drawBarCode39(canvas, size); 26 | } else if (params is Code93BarCodeParams) { 27 | _drawBarCode93(canvas, size); 28 | } else if (params is Code128BarCodeParams) { 29 | _drawBarCode128(canvas, size); 30 | } else if (params is EAN13BarCodeParams) { 31 | _drawBarCodeEAN13(canvas, size); 32 | } else if (params is EAN8BarCodeParams) { 33 | _drawBarCodeEAN8(canvas, size); 34 | } else if (params is UPCABarCodeParams) { 35 | _drawBarCodeUPCA(canvas, size); 36 | } else if (params is UPCEBarCodeParams) { 37 | _drawBarCodeUPCE(canvas, size); 38 | } else if (params is ITFBarCodeParams) { 39 | _drawBarCodeITF(canvas, size); 40 | } else if (params is CodabarBarCodeParams) { 41 | _drawBarCodeCodabar(canvas, size); 42 | } 43 | } 44 | 45 | @override 46 | bool shouldRepaint(CustomPainter oldDelegate) { 47 | return false; 48 | } 49 | 50 | void _drawBarCode39(Canvas canvas, Size size) { 51 | final List binSet = [ 52 | 0xa6d, 53 | 0xd2b, 54 | 0xb2b, 55 | 0xd95, 56 | 0xa6b, 57 | 0xd35, 58 | 0xb35, 59 | 0xa5b, 60 | 0xd2d, 61 | 0xb2d, 62 | 0xd4b, 63 | 0xb4b, 64 | 0xda5, 65 | 0xacb, 66 | 0xd65, 67 | 0xb65, 68 | 0xa9b, 69 | 0xd4d, 70 | 0xb4d, 71 | 0xacd, 72 | 0xd53, 73 | 0xb53, 74 | 0xda9, 75 | 0xad3, 76 | 0xd69, 77 | 0xb69, 78 | 0xab3, 79 | 0xd59, 80 | 0xb59, 81 | 0xad9, 82 | 0xcab, 83 | 0x9ab, 84 | 0xcd5, 85 | 0x96b, 86 | 0xcb5, 87 | 0x9b5, 88 | 0x95b, 89 | 0xcad, 90 | 0x9ad, 91 | 0x925, 92 | 0x929, 93 | 0x949, 94 | 0xa49, 95 | 0x96d 96 | ]; 97 | 98 | final data = params.data; 99 | final lineWidth = params.lineWidth; 100 | final hasText = params.withText; 101 | 102 | int codeValue = 0; 103 | bool hasError = false; 104 | final painter = new Paint()..style = PaintingStyle.fill; 105 | double height = hasText ? size.height * 0.85 : size.height; 106 | 107 | for (int i = 0; i < data.length; i++) { 108 | switch (data[i]) { 109 | case '0': 110 | codeValue = 0; 111 | break; 112 | case '1': 113 | codeValue = 1; 114 | break; 115 | case '2': 116 | codeValue = 2; 117 | break; 118 | case '3': 119 | codeValue = 3; 120 | break; 121 | case '4': 122 | codeValue = 4; 123 | break; 124 | case '5': 125 | codeValue = 5; 126 | break; 127 | case '6': 128 | codeValue = 6; 129 | break; 130 | case '7': 131 | codeValue = 7; 132 | break; 133 | case '8': 134 | codeValue = 8; 135 | break; 136 | case '9': 137 | codeValue = 9; 138 | break; 139 | case 'A': 140 | codeValue = 10; 141 | break; 142 | case 'B': 143 | codeValue = 11; 144 | break; 145 | case 'C': 146 | codeValue = 12; 147 | break; 148 | case 'D': 149 | codeValue = 13; 150 | break; 151 | case 'E': 152 | codeValue = 14; 153 | break; 154 | case 'F': 155 | codeValue = 15; 156 | break; 157 | case 'G': 158 | codeValue = 16; 159 | break; 160 | case 'H': 161 | codeValue = 17; 162 | break; 163 | case 'I': 164 | codeValue = 18; 165 | break; 166 | case 'J': 167 | codeValue = 19; 168 | break; 169 | case 'K': 170 | codeValue = 20; 171 | break; 172 | case 'L': 173 | codeValue = 21; 174 | break; 175 | case 'M': 176 | codeValue = 22; 177 | break; 178 | case 'N': 179 | codeValue = 23; 180 | break; 181 | case 'O': 182 | codeValue = 24; 183 | break; 184 | case 'P': 185 | codeValue = 25; 186 | break; 187 | case 'Q': 188 | codeValue = 26; 189 | break; 190 | case 'R': 191 | codeValue = 27; 192 | break; 193 | case 'S': 194 | codeValue = 28; 195 | break; 196 | case 'T': 197 | codeValue = 29; 198 | break; 199 | case 'U': 200 | codeValue = 30; 201 | break; 202 | case 'V': 203 | codeValue = 31; 204 | break; 205 | case 'W': 206 | codeValue = 32; 207 | break; 208 | case 'X': 209 | codeValue = 33; 210 | break; 211 | case 'Y': 212 | codeValue = 34; 213 | break; 214 | case 'Z': 215 | codeValue = 35; 216 | break; 217 | case '-': 218 | codeValue = 36; 219 | break; 220 | case '.': 221 | codeValue = 37; 222 | break; 223 | case ' ': 224 | codeValue = 38; 225 | break; 226 | case '\$': 227 | codeValue = 39; 228 | break; 229 | case '/': 230 | codeValue = 40; 231 | break; 232 | case '+': 233 | codeValue = 41; 234 | break; 235 | case '%': 236 | codeValue = 42; 237 | break; 238 | default: 239 | codeValue = 0; 240 | hasError = true; 241 | break; 242 | } 243 | 244 | if (hasError) { 245 | String errorMsg = 246 | "Invalid content for Code39. Please check https://en.wikipedia.org/wiki/Code_39 for reference."; 247 | if (this.onError != null) { 248 | this.onError(errorMsg); 249 | } else { 250 | print(errorMsg); 251 | } 252 | return; 253 | } 254 | 255 | for (int j = 0; j < 12; j++) { 256 | Rect rect = new Rect.fromLTWH( 257 | 13 * lineWidth + 13 * i * lineWidth + j * lineWidth, 258 | 0.0, 259 | lineWidth, 260 | height); 261 | ((0x800 & (binSet[codeValue] << j)) == 0x800) 262 | ? painter.color = Colors.black 263 | : painter.color = Colors.white; 264 | canvas.drawRect(rect, painter); 265 | } 266 | } 267 | 268 | for (int i = 0; i < 12; i++) { 269 | Rect rect = new Rect.fromLTWH(i * lineWidth, 0.0, lineWidth, height); 270 | ((0x800 & (binSet[43] << i)) == 0x800) 271 | ? painter.color = Colors.black 272 | : painter.color = Colors.white; 273 | canvas.drawRect(rect, painter); 274 | } 275 | 276 | for (int i = 0; i < 12; i++) { 277 | Rect rect = new Rect.fromLTWH( 278 | (13 + i) * lineWidth + 13 * (data.length) * lineWidth, 279 | 0.0, 280 | lineWidth, 281 | height); 282 | ((0x800 & (binSet[43] << i)) == 0x800) 283 | ? painter.color = Colors.black 284 | : painter.color = Colors.white; 285 | canvas.drawRect(rect, painter); 286 | } 287 | 288 | if (hasText) { 289 | for (int i = 0; i < data.length; i++) { 290 | TextSpan span = new TextSpan( 291 | style: new TextStyle(color: Colors.black, fontSize: 15.0), 292 | text: data[i]); 293 | TextPainter textPainter = new TextPainter( 294 | text: span, 295 | textAlign: TextAlign.left, 296 | textDirection: TextDirection.ltr); 297 | textPainter.layout(); 298 | textPainter.paint( 299 | canvas, 300 | new Offset( 301 | (size.width - data.length * 13 * lineWidth) / 2 + 302 | 13 * i * lineWidth, 303 | height)); 304 | } 305 | } 306 | } 307 | 308 | void _drawBarCode93(Canvas canvas, Size size) { 309 | List binSet = [ 310 | 0x8a, 311 | 0xa4, 312 | 0xa2, 313 | 0xa1, 314 | 0x94, 315 | 0x92, 316 | 0x91, 317 | 0xa8, 318 | 0x89, 319 | 0x85, 320 | 0xd4, 321 | 0xd2, 322 | 0xd1, 323 | 0xca, 324 | 0xc9, 325 | 0xc5, 326 | 0xb4, 327 | 0xb2, 328 | 0xb1, 329 | 0x9a, 330 | 0x8d, 331 | 0xac, 332 | 0xa6, 333 | 0xa3, 334 | 0x96, 335 | 0x8b, 336 | 0xda, 337 | 0xd9, 338 | 0xd6, 339 | 0xd3, 340 | 0xcb, 341 | 0xcd, 342 | 0xb6, 343 | 0xb3, 344 | 0x9b, 345 | 0x9d, 346 | 0x97, 347 | 0xea, 348 | 0xe9, 349 | 0xe5, 350 | 0xb7, 351 | 0xbb, 352 | 0xd7, 353 | 0x93, 354 | 0xed, 355 | 0xeb, 356 | 0x99, 357 | 0xaf 358 | ]; 359 | 360 | final data = params.data; 361 | final lineWidth = params.lineWidth; 362 | final hasText = params.withText; 363 | 364 | int codeValue = 0, checkCodeC, checkCodeK; 365 | int sumC = 0, sumK = 0; 366 | bool hasError = false; 367 | ByteData strValue = new ByteData(data.length); 368 | final painter = new Paint()..style = PaintingStyle.fill; 369 | double height = hasText ? size.height * 0.85 : size.height; 370 | 371 | for (int i = 0; i < 8; i++) { 372 | Rect rect = new Rect.fromLTWH(i * lineWidth, 0.0, lineWidth, height); 373 | ((0x80 & (binSet[47] << i)) == 0x80) 374 | ? painter.color = Colors.black 375 | : painter.color = Colors.white; 376 | canvas.drawRect(rect, painter); 377 | } 378 | 379 | for (int i = 0; i < data.length; i++) { 380 | switch (data[i]) { 381 | case '0': 382 | codeValue = 0; 383 | break; 384 | case '1': 385 | codeValue = 1; 386 | break; 387 | case '2': 388 | codeValue = 2; 389 | break; 390 | case '3': 391 | codeValue = 3; 392 | break; 393 | case '4': 394 | codeValue = 4; 395 | break; 396 | case '5': 397 | codeValue = 5; 398 | break; 399 | case '6': 400 | codeValue = 6; 401 | break; 402 | case '7': 403 | codeValue = 7; 404 | break; 405 | case '8': 406 | codeValue = 8; 407 | break; 408 | case '9': 409 | codeValue = 9; 410 | break; 411 | case 'A': 412 | codeValue = 10; 413 | break; 414 | case 'B': 415 | codeValue = 11; 416 | break; 417 | case 'C': 418 | codeValue = 12; 419 | break; 420 | case 'D': 421 | codeValue = 13; 422 | break; 423 | case 'E': 424 | codeValue = 14; 425 | break; 426 | case 'F': 427 | codeValue = 15; 428 | break; 429 | case 'G': 430 | codeValue = 16; 431 | break; 432 | case 'H': 433 | codeValue = 17; 434 | break; 435 | case 'I': 436 | codeValue = 18; 437 | break; 438 | case 'J': 439 | codeValue = 19; 440 | break; 441 | case 'K': 442 | codeValue = 20; 443 | break; 444 | case 'L': 445 | codeValue = 21; 446 | break; 447 | case 'M': 448 | codeValue = 22; 449 | break; 450 | case 'N': 451 | codeValue = 23; 452 | break; 453 | case 'O': 454 | codeValue = 24; 455 | break; 456 | case 'P': 457 | codeValue = 25; 458 | break; 459 | case 'Q': 460 | codeValue = 26; 461 | break; 462 | case 'R': 463 | codeValue = 27; 464 | break; 465 | case 'S': 466 | codeValue = 28; 467 | break; 468 | case 'T': 469 | codeValue = 29; 470 | break; 471 | case 'U': 472 | codeValue = 30; 473 | break; 474 | case 'V': 475 | codeValue = 31; 476 | break; 477 | case 'W': 478 | codeValue = 32; 479 | break; 480 | case 'X': 481 | codeValue = 33; 482 | break; 483 | case 'Y': 484 | codeValue = 34; 485 | break; 486 | case 'Z': 487 | codeValue = 35; 488 | break; 489 | case '-': 490 | codeValue = 36; 491 | break; 492 | case '.': 493 | codeValue = 37; 494 | break; 495 | case ' ': 496 | codeValue = 38; 497 | break; 498 | case '\$': 499 | codeValue = 39; 500 | break; 501 | case '/': 502 | codeValue = 40; 503 | break; 504 | case '+': 505 | codeValue = 41; 506 | break; 507 | case '%': 508 | codeValue = 42; 509 | break; 510 | default: 511 | codeValue = 0; 512 | hasError = true; 513 | break; 514 | } 515 | 516 | if (hasError) { 517 | String errorMsg = 518 | "Invalid content for Code93. Please check https://en.wikipedia.org/wiki/Code_93 for reference."; 519 | if (this.onError != null) { 520 | this.onError(errorMsg); 521 | } else { 522 | print(errorMsg); 523 | } 524 | return; 525 | } 526 | 527 | strValue.setUint8(i, codeValue); 528 | sumC += strValue.getUint8(i) * (data.length - i); 529 | sumK += strValue.getUint8(i) * (data.length - i + 1); 530 | 531 | for (int j = 0; j < 8; j++) { 532 | Rect rect = new Rect.fromLTWH( 533 | 9 * lineWidth + 9 * i * lineWidth + j * lineWidth, 534 | 0.0, 535 | lineWidth, 536 | height); 537 | ((0x80 & (binSet[codeValue] << j)) == 0x80) 538 | ? painter.color = Colors.black 539 | : painter.color = Colors.white; 540 | canvas.drawRect(rect, painter); 541 | } 542 | } 543 | 544 | checkCodeC = sumC % 47; 545 | for (int i = 0; i < 8; i++) { 546 | Rect rect = new Rect.fromLTWH( 547 | 9 * lineWidth + (data.length * 9 + i) * lineWidth, 548 | 0.0, 549 | lineWidth, 550 | height); 551 | ((0x80 & (binSet[checkCodeC] << i)) == 0x80) 552 | ? painter.color = Colors.black 553 | : painter.color = Colors.white; 554 | canvas.drawRect(rect, painter); 555 | } 556 | 557 | checkCodeK = (sumK + checkCodeC) % 47; 558 | for (int i = 0; i < 8; i++) { 559 | Rect rect = new Rect.fromLTWH( 560 | 9 * lineWidth + ((data.length + 1) * 9 + i) * lineWidth, 561 | 0.0, 562 | lineWidth, 563 | height); 564 | ((0x80 & (binSet[checkCodeK] << i)) == 0x80) 565 | ? painter.color = Colors.black 566 | : painter.color = Colors.white; 567 | canvas.drawRect(rect, painter); 568 | } 569 | 570 | for (int i = 0; i < 8; i++) { 571 | Rect rect = new Rect.fromLTWH( 572 | 9 * lineWidth + ((data.length + 2) * 9 + i) * lineWidth, 573 | 0.0, 574 | lineWidth, 575 | height); 576 | ((0x80 & (binSet[47] << i)) == 0x80) 577 | ? painter.color = Colors.black 578 | : painter.color = Colors.white; 579 | canvas.drawRect(rect, painter); 580 | } 581 | 582 | for (int i = 0; i < 8; i++) { 583 | Rect rect = new Rect.fromLTWH( 584 | 9 * lineWidth + ((data.length + 3) * 9 + i) * lineWidth, 585 | 0.0, 586 | lineWidth, 587 | height); 588 | ((0x80 & (binSet[1] << i)) == 0x80) 589 | ? painter.color = Colors.black 590 | : painter.color = Colors.white; 591 | canvas.drawRect(rect, painter); 592 | } 593 | 594 | if (hasText) { 595 | for (int i = 0; i < data.length; i++) { 596 | TextSpan span = new TextSpan( 597 | style: new TextStyle(color: Colors.black, fontSize: 15.0), 598 | text: data[i]); 599 | TextPainter textPainter = new TextPainter( 600 | text: span, 601 | textAlign: TextAlign.left, 602 | textDirection: TextDirection.ltr); 603 | textPainter.layout(); 604 | textPainter.paint( 605 | canvas, 606 | new Offset( 607 | (size.width - data.length * 8 * lineWidth) / 2 + 608 | 8 * i * lineWidth, 609 | height)); 610 | } 611 | } 612 | } 613 | 614 | void _drawBarCode128(Canvas canvas, Size size) { 615 | List code128 = [ 616 | 0x6cc, 617 | 0x66c, 618 | 0x666, 619 | 0x498, 620 | 0x48c, 621 | 0x44c, 622 | 0x4c8, 623 | 0x4c4, 624 | 0x464, 625 | 0x648, 626 | 0x644, 627 | 0x624, 628 | 0x59c, 629 | 0x4dc, 630 | 0x4ce, 631 | 0x5cc, 632 | 0x4ec, 633 | 0x4e6, 634 | 0x672, 635 | 0x65c, 636 | 0x64e, 637 | 0x6e4, 638 | 0x674, 639 | 0x76e, 640 | 0x74c, 641 | 0x72c, 642 | 0x726, 643 | 0x764, 644 | 0x734, 645 | 0x732, 646 | 0x6d8, 647 | 0x6c6, 648 | 0x636, 649 | 0x518, 650 | 0x458, 651 | 0x446, 652 | 0x588, 653 | 0x468, 654 | 0x462, 655 | 0x688, 656 | 0x628, 657 | 0x622, 658 | 0x5b8, 659 | 0x58e, 660 | 0x46e, 661 | 0x5d8, 662 | 0x5c6, 663 | 0x476, 664 | 0x776, 665 | 0x68e, 666 | 0x62e, 667 | 0x6e8, 668 | 0x6e2, 669 | 0x6ee, 670 | 0x758, 671 | 0x746, 672 | 0x716, 673 | 0x768, 674 | 0x762, 675 | 0x71a, 676 | 0x77a, 677 | 0x642, 678 | 0x78a, 679 | 0x530, 680 | 0x50c, 681 | 0x4b0, 682 | 0x486, 683 | 0x42c, 684 | 0x426, 685 | 0x590, 686 | 0x584, 687 | 0x4d0, 688 | 0x4c2, 689 | 0x434, 690 | 0x432, 691 | 0x612, 692 | 0x650, 693 | 0x7ba, 694 | 0x614, 695 | 0x47a, 696 | 0x53c, 697 | 0x4bc, 698 | 0x49e, 699 | 0x5e4, 700 | 0x4f4, 701 | 0x4f2, 702 | 0x7a4, 703 | 0x794, 704 | 0x792, 705 | 0x6de, 706 | 0x6f6, 707 | 0x7b6, 708 | 0x578, 709 | 0x51e, 710 | 0x45e, 711 | 0x5e8, 712 | 0x5e2, 713 | 0x7a8, 714 | 0x7a2, 715 | 0x5de, 716 | 0x5ee, 717 | 0x75e, 718 | 0x7ae, 719 | 0x684, 720 | 0x690, 721 | 0x69c 722 | ]; 723 | 724 | final data = params.data; 725 | final lineWidth = params.lineWidth; 726 | final hasText = params.withText; 727 | 728 | int codeValue, checkCode, strlen = data.length; 729 | ByteData strValue = new ByteData(strlen); 730 | int sum = 0, startValue = 0x690, endFlag = 0x18eb; 731 | bool hasError = false; 732 | final painter = new Paint()..style = PaintingStyle.fill; 733 | double height = hasText ? size.height * 0.85 : size.height; 734 | 735 | for (int i = 0; i < 11; i++) { 736 | Rect rect = new Rect.fromLTWH(i * lineWidth, 0.0, lineWidth, height); 737 | ((0x400 & (startValue << i)) == 0x400) 738 | ? painter.color = Colors.black 739 | : painter.color = Colors.white; 740 | canvas.drawRect(rect, painter); 741 | } 742 | 743 | for (int i = 0; i < strlen; i++) { 744 | switch (data[i]) { 745 | case ' ': 746 | codeValue = 0; 747 | break; 748 | case '!': 749 | codeValue = 1; 750 | break; 751 | case '"': 752 | codeValue = 2; 753 | break; 754 | case '#': 755 | codeValue = 3; 756 | break; 757 | case '\$': 758 | codeValue = 4; 759 | break; 760 | case '%': 761 | codeValue = 5; 762 | break; 763 | case '&': 764 | codeValue = 6; 765 | break; 766 | case '…': 767 | codeValue = 7; 768 | break; 769 | case '(': 770 | codeValue = 8; 771 | break; 772 | case ')': 773 | codeValue = 9; 774 | break; 775 | case '*': 776 | codeValue = 10; 777 | break; 778 | case '+': 779 | codeValue = 11; 780 | break; 781 | case ',': 782 | codeValue = 12; 783 | break; 784 | case '-': 785 | codeValue = 13; 786 | break; 787 | case '.': 788 | codeValue = 14; 789 | break; 790 | case '/': 791 | codeValue = 15; 792 | break; 793 | case '0': 794 | codeValue = 16; 795 | break; 796 | case '1': 797 | codeValue = 17; 798 | break; 799 | case '2': 800 | codeValue = 18; 801 | break; 802 | case '3': 803 | codeValue = 19; 804 | break; 805 | case '4': 806 | codeValue = 20; 807 | break; 808 | case '5': 809 | codeValue = 21; 810 | break; 811 | case '6': 812 | codeValue = 22; 813 | break; 814 | case '7': 815 | codeValue = 23; 816 | break; 817 | case '8': 818 | codeValue = 24; 819 | break; 820 | case '9': 821 | codeValue = 25; 822 | break; 823 | case ':': 824 | codeValue = 26; 825 | break; 826 | case ';': 827 | codeValue = 27; 828 | break; 829 | case '<': 830 | codeValue = 28; 831 | break; 832 | case '=': 833 | codeValue = 29; 834 | break; 835 | case '>': 836 | codeValue = 30; 837 | break; 838 | case '?': 839 | codeValue = 31; 840 | break; 841 | case '@': 842 | codeValue = 32; 843 | break; 844 | case 'A': 845 | codeValue = 33; 846 | break; 847 | case 'B': 848 | codeValue = 34; 849 | break; 850 | case 'C': 851 | codeValue = 35; 852 | break; 853 | case 'D': 854 | codeValue = 36; 855 | break; 856 | case 'E': 857 | codeValue = 37; 858 | break; 859 | case 'F': 860 | codeValue = 38; 861 | break; 862 | case 'G': 863 | codeValue = 39; 864 | break; 865 | case 'H': 866 | codeValue = 40; 867 | break; 868 | case 'I': 869 | codeValue = 41; 870 | break; 871 | case 'J': 872 | codeValue = 42; 873 | break; 874 | case 'K': 875 | codeValue = 43; 876 | break; 877 | case 'L': 878 | codeValue = 44; 879 | break; 880 | case 'M': 881 | codeValue = 45; 882 | break; 883 | case 'N': 884 | codeValue = 46; 885 | break; 886 | case 'O': 887 | codeValue = 47; 888 | break; 889 | case 'P': 890 | codeValue = 48; 891 | break; 892 | case 'Q': 893 | codeValue = 49; 894 | break; 895 | case 'R': 896 | codeValue = 50; 897 | break; 898 | case 'S': 899 | codeValue = 51; 900 | break; 901 | case 'T': 902 | codeValue = 52; 903 | break; 904 | case 'U': 905 | codeValue = 53; 906 | break; 907 | case 'V': 908 | codeValue = 54; 909 | break; 910 | case 'W': 911 | codeValue = 55; 912 | break; 913 | case 'X': 914 | codeValue = 56; 915 | break; 916 | case 'Y': 917 | codeValue = 57; 918 | break; 919 | case 'Z': 920 | codeValue = 58; 921 | break; 922 | case '[': 923 | codeValue = 59; 924 | break; 925 | case '、': 926 | codeValue = 60; 927 | break; 928 | case ']': 929 | codeValue = 61; 930 | break; 931 | case '^': 932 | codeValue = 62; 933 | break; 934 | case '_': 935 | codeValue = 63; 936 | break; 937 | case '`': 938 | codeValue = 64; 939 | break; 940 | case 'a': 941 | codeValue = 65; 942 | break; 943 | case 'b': 944 | codeValue = 66; 945 | break; 946 | case 'c': 947 | codeValue = 67; 948 | break; 949 | case 'd': 950 | codeValue = 68; 951 | break; 952 | case 'e': 953 | codeValue = 69; 954 | break; 955 | case 'f': 956 | codeValue = 70; 957 | break; 958 | case 'g': 959 | codeValue = 71; 960 | break; 961 | case 'h': 962 | codeValue = 72; 963 | break; 964 | case 'i': 965 | codeValue = 73; 966 | break; 967 | case 'j': 968 | codeValue = 74; 969 | break; 970 | case 'k': 971 | codeValue = 75; 972 | break; 973 | case 'l': 974 | codeValue = 76; 975 | break; 976 | case 'm': 977 | codeValue = 77; 978 | break; 979 | case 'n': 980 | codeValue = 78; 981 | break; 982 | case 'o': 983 | codeValue = 79; 984 | break; 985 | case 'p': 986 | codeValue = 80; 987 | break; 988 | case 'q': 989 | codeValue = 81; 990 | break; 991 | case 'r': 992 | codeValue = 82; 993 | break; 994 | case 's': 995 | codeValue = 83; 996 | break; 997 | case 't': 998 | codeValue = 84; 999 | break; 1000 | case 'u': 1001 | codeValue = 85; 1002 | break; 1003 | case 'v': 1004 | codeValue = 86; 1005 | break; 1006 | case 'w': 1007 | codeValue = 87; 1008 | break; 1009 | case 'x': 1010 | codeValue = 88; 1011 | break; 1012 | case 'y': 1013 | codeValue = 89; 1014 | break; 1015 | case 'z': 1016 | codeValue = 90; 1017 | break; 1018 | case '{': 1019 | codeValue = 91; 1020 | break; 1021 | case '|': 1022 | codeValue = 92; 1023 | break; 1024 | case '}': 1025 | codeValue = 93; 1026 | break; 1027 | case '~': 1028 | codeValue = 94; 1029 | break; 1030 | default: 1031 | hasError = true; 1032 | break; 1033 | } 1034 | 1035 | if (hasError) { 1036 | String errorMsg = 1037 | "Invalid content for Code128. Please check https://en.wikipedia.org/wiki/Code_128 for reference."; 1038 | if (this.onError != null) { 1039 | this.onError(errorMsg); 1040 | } else { 1041 | print(errorMsg); 1042 | } 1043 | return; 1044 | } 1045 | 1046 | strValue.setUint8(i, codeValue); 1047 | sum += strValue.getUint8(i) * (i + 1); 1048 | for (int j = 0; j < 11; j++) { 1049 | Rect rect = new Rect.fromLTWH( 1050 | 11 * lineWidth + 11 * i * lineWidth + j * lineWidth, 1051 | 0.0, 1052 | lineWidth, 1053 | height); 1054 | ((0x400 & (code128[codeValue] << j)) == 0x400) 1055 | ? painter.color = Colors.black 1056 | : painter.color = Colors.white; 1057 | canvas.drawRect(rect, painter); 1058 | } 1059 | } 1060 | 1061 | checkCode = (sum + 104) % 103; 1062 | for (int i = 0; i < 11; i++) { 1063 | Rect rect = new Rect.fromLTWH( 1064 | 11 * lineWidth + (strlen * 11 + i) * lineWidth, 1065 | 0.0, 1066 | lineWidth, 1067 | height); 1068 | ((0x400 & (code128[checkCode] << i)) == 0x400) 1069 | ? painter.color = Colors.black 1070 | : painter.color = Colors.white; 1071 | canvas.drawRect(rect, painter); 1072 | } 1073 | 1074 | for (int i = 0; i < 13; i++) { 1075 | Rect rect = new Rect.fromLTWH( 1076 | 22 * lineWidth + (strlen * 11 + i) * lineWidth, 1077 | 0.0, 1078 | lineWidth, 1079 | height); 1080 | ((0x1000 & (endFlag << i)) == 0x1000) 1081 | ? painter.color = Colors.black 1082 | : painter.color = Colors.white; 1083 | canvas.drawRect(rect, painter); 1084 | } 1085 | 1086 | if (hasText) { 1087 | for (int i = 0; i < data.length; i++) { 1088 | TextSpan span = new TextSpan( 1089 | style: new TextStyle(color: Colors.black, fontSize: 15.0), 1090 | text: data[i]); 1091 | TextPainter textPainter = new TextPainter( 1092 | text: span, 1093 | textAlign: TextAlign.left, 1094 | textDirection: TextDirection.ltr); 1095 | textPainter.layout(); 1096 | textPainter.paint( 1097 | canvas, 1098 | new Offset( 1099 | (size.width - data.length * 8 * lineWidth) / 2 + 1100 | 8 * i * lineWidth, 1101 | height)); 1102 | } 1103 | } 1104 | } 1105 | 1106 | void _drawBarCodeEAN13(Canvas canvas, Size size) { 1107 | List codeA = [ 1108 | 0x0d, 1109 | 0x19, 1110 | 0x13, 1111 | 0x3d, 1112 | 0x23, 1113 | 0x31, 1114 | 0x2f, 1115 | 0x3b, 1116 | 0x37, 1117 | 0x0b 1118 | ]; 1119 | List codeB = [ 1120 | 0x27, 1121 | 0x33, 1122 | 0x1b, 1123 | 0x21, 1124 | 0x1d, 1125 | 0x39, 1126 | 0x05, 1127 | 0x11, 1128 | 0x09, 1129 | 0x17 1130 | ]; 1131 | List codeC = [ 1132 | 0x72, 1133 | 0x66, 1134 | 0x6c, 1135 | 0x42, 1136 | 0x5c, 1137 | 0x4e, 1138 | 0x50, 1139 | 0x44, 1140 | 0x48, 1141 | 0x74 1142 | ]; 1143 | List flagCode = [ 1144 | 0x00, 1145 | 0x0b, 1146 | 0x0d, 1147 | 0x0e, 1148 | 0x13, 1149 | 0x19, 1150 | 0x1c, 1151 | 0x15, 1152 | 0x17, 1153 | 0x1a 1154 | ]; 1155 | 1156 | final data = params.data; 1157 | final lineWidth = params.lineWidth; 1158 | final hasText = params.withText; 1159 | 1160 | int startCodeSep = 0x05, midCodeSep = 0x0a, endCodeSep = 0x05; 1161 | int tmpCode, 1162 | tmpBarCode, 1163 | checkCode, 1164 | sum2nd, 1165 | sum3rd, 1166 | flagbit, 1167 | strlen = data.length; 1168 | ByteData st = new ByteData(12); 1169 | bool hasError = false; 1170 | final painter = new Paint()..style = PaintingStyle.fill; 1171 | double height = hasText ? size.height * 0.85 : size.height; 1172 | 1173 | if (strlen > 12) { 1174 | strlen = 13; 1175 | } else { 1176 | hasError = true; 1177 | } 1178 | 1179 | for (int i = 0; i < 12; i++) { 1180 | st.setUint8(i, data.codeUnitAt(i) - 48); 1181 | if (st.getUint8(i) > 9) { 1182 | hasError = true; 1183 | } 1184 | } 1185 | 1186 | if (hasError) { 1187 | String errorMsg = 1188 | "Invalid content for code EAN13. Please check https://en.wikipedia.org/wiki/International_Article_Number for reference."; 1189 | if (this.onError != null) { 1190 | this.onError(errorMsg); 1191 | } else { 1192 | print(errorMsg); 1193 | } 1194 | return; 1195 | } 1196 | 1197 | for (int j = 0; j < 3; j++) { 1198 | Rect rect = new Rect.fromLTWH(11 * lineWidth + j * lineWidth, 0.0, 1199 | lineWidth, hasText ? height * 1.08 : height); 1200 | ((0x01 & (startCodeSep >> j)) == 0x01) 1201 | ? painter.color = Colors.black 1202 | : painter.color = Colors.white; 1203 | canvas.drawRect(rect, painter); 1204 | } 1205 | 1206 | for (int i = 0; i < 7; i++) { 1207 | tmpCode = data.codeUnitAt(i) - 48; 1208 | if (i == 0) { 1209 | flagbit = tmpCode; 1210 | } else { 1211 | if ((0x20 & (flagCode[flagbit] << (i - 1))) == 0) { 1212 | for (int j = 0; j < 7; j++) { 1213 | Rect rect = new Rect.fromLTWH( 1214 | 14 * lineWidth + 7 * (i - 1) * lineWidth + j * lineWidth, 1215 | 0.0, 1216 | lineWidth, 1217 | height); 1218 | ((0x40 & (codeA[tmpCode] << j)) == 0x40) 1219 | ? painter.color = Colors.black 1220 | : painter.color = Colors.white; 1221 | canvas.drawRect(rect, painter); 1222 | } 1223 | } else { 1224 | for (int n = 0; n < 7; n++) { 1225 | Rect rect = new Rect.fromLTWH( 1226 | 14 * lineWidth + 7 * (i - 1) * lineWidth + n * lineWidth, 1227 | 0.0, 1228 | lineWidth, 1229 | height); 1230 | ((0x40 & (codeB[tmpCode] << n)) == 0x40) 1231 | ? painter.color = Colors.black 1232 | : painter.color = Colors.white; 1233 | canvas.drawRect(rect, painter); 1234 | } 1235 | } 1236 | } 1237 | } 1238 | 1239 | for (int i = 0; i < 5; i++) { 1240 | Rect rect = new Rect.fromLTWH(56 * lineWidth + i * lineWidth, 0.0, 1241 | lineWidth, hasText ? height * 1.08 : height); 1242 | ((0x01 & (midCodeSep >> i)) == 0x01) 1243 | ? painter.color = Colors.black 1244 | : painter.color = Colors.white; 1245 | canvas.drawRect(rect, painter); 1246 | } 1247 | 1248 | for (int i = 0; i < 5; i++) { 1249 | tmpBarCode = data.codeUnitAt(i + 7) - 48; 1250 | for (int j = 0; j < 7; j++) { 1251 | Rect rect = new Rect.fromLTWH( 1252 | 61 * lineWidth + j * lineWidth + 7 * i * lineWidth, 1253 | 0.0, 1254 | lineWidth, 1255 | height); 1256 | ((0x40 & (codeC[tmpBarCode] << j)) == 0x40) 1257 | ? painter.color = Colors.black 1258 | : painter.color = Colors.white; 1259 | canvas.drawRect(rect, painter); 1260 | } 1261 | } 1262 | 1263 | sum3rd = st.getUint8(0) + 1264 | st.getUint8(2) + 1265 | st.getUint8(4) + 1266 | st.getUint8(6) + 1267 | st.getUint8(8) + 1268 | st.getUint8(10); 1269 | sum2nd = st.getUint8(1) + 1270 | st.getUint8(3) + 1271 | st.getUint8(5) + 1272 | st.getUint8(7) + 1273 | st.getUint8(9) + 1274 | st.getUint8(11); 1275 | if ((sum2nd * 3 + sum3rd) % 10 == 0) { 1276 | checkCode = 0; 1277 | } else { 1278 | checkCode = 10 - (sum2nd * 3 + sum3rd) % 10; 1279 | } 1280 | 1281 | for (int i = 0; i < 7; i++) { 1282 | Rect rect = new Rect.fromLTWH( 1283 | 96 * lineWidth + i * lineWidth, 0.0, lineWidth, height); 1284 | ((0x40 & (codeC[checkCode] << i)) == 0x40) 1285 | ? painter.color = Colors.black 1286 | : painter.color = Colors.white; 1287 | canvas.drawRect(rect, painter); 1288 | } 1289 | 1290 | for (int i = 0; i < 3; i++) { 1291 | Rect rect = new Rect.fromLTWH(103 * lineWidth + i * lineWidth, 0.0, 1292 | lineWidth, hasText ? height * 1.08 : height); 1293 | ((0x01 & (endCodeSep >> i)) == 0x01) 1294 | ? painter.color = Colors.black 1295 | : painter.color = Colors.white; 1296 | canvas.drawRect(rect, painter); 1297 | } 1298 | 1299 | if (hasText) { 1300 | (data.length > 13) ? strlen = 13 : strlen = data.length; 1301 | for (int i = 0; i < strlen; i++) { 1302 | if (i == 0) { 1303 | TextSpan span = new TextSpan( 1304 | style: new TextStyle(color: Colors.black, fontSize: 15.0), 1305 | text: data[i]); 1306 | TextPainter textPainter = new TextPainter( 1307 | text: span, 1308 | textAlign: TextAlign.left, 1309 | textDirection: TextDirection.ltr); 1310 | textPainter.layout(); 1311 | textPainter.paint(canvas, new Offset(2 * lineWidth, height)); 1312 | } else if (i < 7) { 1313 | TextSpan span = new TextSpan( 1314 | style: new TextStyle(color: Colors.black, fontSize: 15.0), 1315 | text: data[i]); 1316 | TextPainter textPainter = new TextPainter( 1317 | text: span, 1318 | textAlign: TextAlign.left, 1319 | textDirection: TextDirection.ltr); 1320 | textPainter.layout(); 1321 | textPainter.paint(canvas, 1322 | new Offset(13 * lineWidth + 7 * (i - 1) * lineWidth, height)); 1323 | } else if (i == 12) { 1324 | TextSpan span = new TextSpan( 1325 | style: new TextStyle(color: Colors.black, fontSize: 15.0), 1326 | text: checkCode.toString()); 1327 | TextPainter textPainter = new TextPainter( 1328 | text: span, 1329 | textAlign: TextAlign.left, 1330 | textDirection: TextDirection.ltr); 1331 | textPainter.layout(); 1332 | textPainter.paint(canvas, 1333 | new Offset(17 * lineWidth + 7 * (i - 1) * lineWidth, height)); 1334 | } else { 1335 | TextSpan span = new TextSpan( 1336 | style: new TextStyle(color: Colors.black, fontSize: 15.0), 1337 | text: data[i]); 1338 | TextPainter textPainter = new TextPainter( 1339 | text: span, 1340 | textAlign: TextAlign.left, 1341 | textDirection: TextDirection.ltr); 1342 | textPainter.layout(); 1343 | textPainter.paint(canvas, 1344 | new Offset(17 * lineWidth + 7 * (i - 1) * lineWidth, height)); 1345 | } 1346 | } 1347 | } 1348 | } 1349 | 1350 | void _drawBarCodeEAN8(Canvas canvas, Size size) { 1351 | List codeA = [ 1352 | 0x0d, 1353 | 0x19, 1354 | 0x13, 1355 | 0x3d, 1356 | 0x23, 1357 | 0x31, 1358 | 0x2f, 1359 | 0x3b, 1360 | 0x37, 1361 | 0x0b 1362 | ]; 1363 | List codeC = [ 1364 | 0x72, 1365 | 0x66, 1366 | 0x6c, 1367 | 0x42, 1368 | 0x5c, 1369 | 0x4e, 1370 | 0x50, 1371 | 0x44, 1372 | 0x48, 1373 | 0x74 1374 | ]; 1375 | int startCodeSep = 0x05, midCodeSep = 0x0a, endCodeSep = 0x05; 1376 | 1377 | final data = params.data; 1378 | final lineWidth = params.lineWidth; 1379 | final hasText = params.withText; 1380 | 1381 | int tmpCode, tmpBarCode, checkCode, sum2nd, sum3rd, strlen = data.length; 1382 | ByteData st = new ByteData(7); 1383 | bool hasError = false; 1384 | final painter = new Paint()..style = PaintingStyle.fill; 1385 | double height = hasText ? size.height * 0.85 : size.height; 1386 | 1387 | for (int i = 0; i < 7; i++) { 1388 | st.setUint8(i, data.codeUnitAt(i) - 48); 1389 | if (st.getUint8(i) > 9) { 1390 | hasError = true; 1391 | } 1392 | } 1393 | 1394 | if (hasError) { 1395 | String errorMsg = 1396 | "Invalid content for code EAN8. Please check https://en.wikipedia.org/wiki/EAN-8 for reference."; 1397 | if (this.onError != null) { 1398 | this.onError(errorMsg); 1399 | } else { 1400 | print(errorMsg); 1401 | } 1402 | return; 1403 | } 1404 | 1405 | for (int i = 0; i < 3; i++) { 1406 | Rect rect = new Rect.fromLTWH(7 * lineWidth + i * lineWidth, 0.0, 1407 | lineWidth, hasText ? height * 1.08 : height); 1408 | ((0x01 & (startCodeSep >> i)) == 0x01) 1409 | ? painter.color = Colors.black 1410 | : painter.color = Colors.white; 1411 | canvas.drawRect(rect, painter); 1412 | } 1413 | 1414 | for (int i = 0; i < 4; i++) { 1415 | tmpCode = data.codeUnitAt(i) - 48; 1416 | for (int j = 0; j < 7; j++) { 1417 | Rect rect = new Rect.fromLTWH( 1418 | 10 * lineWidth + j * lineWidth + 7 * i * lineWidth, 1419 | 0.0, 1420 | lineWidth, 1421 | height); 1422 | ((0x40 & (codeA[tmpCode] << j)) == 0x40) 1423 | ? painter.color = Colors.black 1424 | : painter.color = Colors.white; 1425 | canvas.drawRect(rect, painter); 1426 | } 1427 | } 1428 | 1429 | for (int i = 0; i < 5; i++) { 1430 | Rect rect = new Rect.fromLTWH( 1431 | 38 * lineWidth + i * lineWidth, 0.0, lineWidth, height); 1432 | ((0x01 & (midCodeSep >> i)) == 0x01) 1433 | ? painter.color = Colors.black 1434 | : painter.color = Colors.white; 1435 | canvas.drawRect(rect, painter); 1436 | } 1437 | 1438 | for (int i = 4; i < 7; i++) { 1439 | tmpBarCode = data.codeUnitAt(i) - 48; 1440 | for (int j = 0; j < 7; j++) { 1441 | Rect rect = new Rect.fromLTWH( 1442 | 43 * lineWidth + j * lineWidth + 7 * (i - 4) * lineWidth, 1443 | 0.0, 1444 | lineWidth, 1445 | height); 1446 | ((0x40 & (codeC[tmpBarCode] << j)) == 0x40) 1447 | ? painter.color = Colors.black 1448 | : painter.color = Colors.white; 1449 | canvas.drawRect(rect, painter); 1450 | } 1451 | } 1452 | 1453 | sum2nd = st.getUint8(6) + st.getUint8(4) + st.getUint8(2) + st.getUint8(0); 1454 | sum3rd = st.getUint8(5) + st.getUint8(3) + st.getUint8(1); 1455 | if ((sum3rd + sum2nd * 3) % 10 == 0) { 1456 | checkCode = 0; 1457 | } else { 1458 | checkCode = 10 - (sum3rd + sum2nd * 3) % 10; 1459 | } 1460 | 1461 | for (int i = 0; i < 7; i++) { 1462 | Rect rect = new Rect.fromLTWH( 1463 | 64 * lineWidth + i * lineWidth, 0.0, lineWidth, height); 1464 | ((0x40 & (codeC[checkCode] << i)) == 0x40) 1465 | ? painter.color = Colors.black 1466 | : painter.color = Colors.white; 1467 | canvas.drawRect(rect, painter); 1468 | } 1469 | 1470 | for (int i = 0; i < 3; i++) { 1471 | Rect rect = new Rect.fromLTWH(71 * lineWidth + i * lineWidth, 0.0, 1472 | lineWidth, hasText ? height * 1.08 : height); 1473 | ((0x01 & (endCodeSep >> i)) == 0x01) 1474 | ? painter.color = Colors.black 1475 | : painter.color = Colors.white; 1476 | canvas.drawRect(rect, painter); 1477 | } 1478 | 1479 | if (hasText) { 1480 | strlen > 8 ? strlen = 8 : strlen = data.length; 1481 | for (int i = 0; i < strlen; i++) { 1482 | if (i < 4) { 1483 | TextSpan span = new TextSpan( 1484 | style: new TextStyle(color: Colors.black, fontSize: 15.0), 1485 | text: data[i]); 1486 | TextPainter textPainter = new TextPainter( 1487 | text: span, 1488 | textAlign: TextAlign.left, 1489 | textDirection: TextDirection.ltr); 1490 | textPainter.layout(); 1491 | textPainter.paint( 1492 | canvas, new Offset(11 * lineWidth + 7 * i * lineWidth, height)); 1493 | } else if (i == 7) { 1494 | TextSpan span = new TextSpan( 1495 | style: new TextStyle(color: Colors.black, fontSize: 15.0), 1496 | text: checkCode.toString()); 1497 | TextPainter textPainter = new TextPainter( 1498 | text: span, 1499 | textAlign: TextAlign.left, 1500 | textDirection: TextDirection.ltr); 1501 | textPainter.layout(); 1502 | textPainter.paint( 1503 | canvas, new Offset(15 * lineWidth + 7 * i * lineWidth, height)); 1504 | } else { 1505 | TextSpan span = new TextSpan( 1506 | style: new TextStyle(color: Colors.black, fontSize: 15.0), 1507 | text: data[i]); 1508 | TextPainter textPainter = new TextPainter( 1509 | text: span, 1510 | textAlign: TextAlign.left, 1511 | textDirection: TextDirection.ltr); 1512 | textPainter.layout(); 1513 | textPainter.paint( 1514 | canvas, new Offset(15 * lineWidth + 7 * i * lineWidth, height)); 1515 | } 1516 | } 1517 | } 1518 | } 1519 | 1520 | void _drawBarCodeUPCA(Canvas canvas, Size size) { 1521 | List codeA = [ 1522 | 0x0d, 1523 | 0x19, 1524 | 0x13, 1525 | 0x3d, 1526 | 0x23, 1527 | 0x31, 1528 | 0x2f, 1529 | 0x3b, 1530 | 0x37, 1531 | 0x0b 1532 | ]; 1533 | List codeC = [ 1534 | 0x72, 1535 | 0x66, 1536 | 0x6c, 1537 | 0x42, 1538 | 0x5c, 1539 | 0x4e, 1540 | 0x50, 1541 | 0x44, 1542 | 0x48, 1543 | 0x74 1544 | ]; 1545 | int startCodeSep = 0x05, midCodeSep = 0x0a, endCodeSep = 0x05; 1546 | 1547 | final data = params.data; 1548 | final lineWidth = params.lineWidth; 1549 | final hasText = params.withText; 1550 | 1551 | int tmpCode, tmpBarCode, checkCode, sum2nd, sum3rd, strlen = data.length; 1552 | ByteData st = new ByteData(11); 1553 | bool hasError = false; 1554 | final painter = new Paint()..style = PaintingStyle.fill; 1555 | double height = hasText ? size.height * 0.85 : size.height; 1556 | 1557 | for (int i = 0; i < 11; i++) { 1558 | st.setUint8(i, data.codeUnitAt(i) - 48); 1559 | if (st.getUint8(i) > 9) { 1560 | hasError = true; 1561 | } 1562 | } 1563 | 1564 | if (hasError) { 1565 | String errorMsg = 1566 | "Invalid content for coe UPC-A. Please check https://en.wikipedia.org/wiki/Universal_Product_Code for reference."; 1567 | if (this.onError != null) { 1568 | this.onError(errorMsg); 1569 | } else { 1570 | print(errorMsg); 1571 | } 1572 | return; 1573 | } 1574 | 1575 | for (int i = 0; i < 3; i++) { 1576 | Rect rect = new Rect.fromLTWH(9 * lineWidth + i * lineWidth, 0.0, 1577 | lineWidth, hasText ? height * 1.08 : height); 1578 | ((0x01 & (startCodeSep >> i)) == 0x01) 1579 | ? painter.color = Colors.black 1580 | : painter.color = Colors.white; 1581 | canvas.drawRect(rect, painter); 1582 | } 1583 | 1584 | for (int i = 0; i < 6; i++) { 1585 | tmpCode = data.codeUnitAt(i) - 48; 1586 | for (int j = 0; j < 7; j++) { 1587 | Rect rect = new Rect.fromLTWH( 1588 | 12 * lineWidth + 7 * i * lineWidth + j * lineWidth, 1589 | 0.0, 1590 | lineWidth, 1591 | height); 1592 | ((0x40 & (codeA[tmpCode] << j)) == 0x40) 1593 | ? painter.color = Colors.black 1594 | : painter.color = Colors.white; 1595 | canvas.drawRect(rect, painter); 1596 | } 1597 | } 1598 | 1599 | for (int i = 0; i < 5; i++) { 1600 | Rect rect = new Rect.fromLTWH(54 * lineWidth + i * lineWidth, 0.0, 1601 | lineWidth, hasText ? height * 1.08 : height); 1602 | ((0x01 & (midCodeSep >> i)) == 0x01) 1603 | ? painter.color = Colors.black 1604 | : painter.color = Colors.white; 1605 | canvas.drawRect(rect, painter); 1606 | } 1607 | 1608 | for (int i = 0; i < 5; i++) { 1609 | tmpBarCode = data.codeUnitAt(i + 6) - 48; 1610 | for (int j = 0; j < 7; j++) { 1611 | Rect rect = new Rect.fromLTWH( 1612 | 59 * lineWidth + j * lineWidth + 7 * i * lineWidth, 1613 | 0.0, 1614 | lineWidth, 1615 | height); 1616 | ((0x40 & (codeC[tmpBarCode] << j)) == 0x40) 1617 | ? painter.color = Colors.black 1618 | : painter.color = Colors.white; 1619 | canvas.drawRect(rect, painter); 1620 | } 1621 | } 1622 | 1623 | sum3rd = st.getUint8(0) + 1624 | st.getUint8(2) + 1625 | st.getUint8(4) + 1626 | st.getUint8(6) + 1627 | st.getUint8(8) + 1628 | st.getUint8(10); 1629 | sum2nd = st.getUint8(1) + 1630 | st.getUint8(3) + 1631 | st.getUint8(5) + 1632 | st.getUint8(7) + 1633 | st.getUint8(9); 1634 | if ((sum2nd + sum3rd * 3) % 10 == 0) { 1635 | checkCode = 0; 1636 | } else { 1637 | checkCode = 10 - (sum2nd + sum3rd * 3) % 10; 1638 | } 1639 | 1640 | for (int i = 0; i < 7; i++) { 1641 | Rect rect = new Rect.fromLTWH( 1642 | 94 * lineWidth + i * lineWidth, 0.0, lineWidth, height); 1643 | ((0x40 & (codeC[checkCode] << i)) == 0x40) 1644 | ? painter.color = Colors.black 1645 | : painter.color = Colors.white; 1646 | canvas.drawRect(rect, painter); 1647 | } 1648 | 1649 | for (int i = 0; i < 3; i++) { 1650 | Rect rect = new Rect.fromLTWH(101 * lineWidth + i * lineWidth, 0.0, 1651 | lineWidth, hasText ? height * 1.08 : height); 1652 | ((0x01 & (endCodeSep >> i)) == 0x01) 1653 | ? painter.color = Colors.black 1654 | : painter.color = Colors.white; 1655 | canvas.drawRect(rect, painter); 1656 | } 1657 | 1658 | if (hasText) { 1659 | strlen > 12 ? strlen = 12 : strlen = data.length; 1660 | for (int i = 0; i < strlen; i++) { 1661 | if (i == 0) { 1662 | TextSpan span = new TextSpan( 1663 | style: new TextStyle(color: Colors.black, fontSize: 15.0), 1664 | text: data[i]); 1665 | TextPainter textPainter = new TextPainter( 1666 | text: span, 1667 | textAlign: TextAlign.left, 1668 | textDirection: TextDirection.ltr); 1669 | textPainter.layout(); 1670 | textPainter.paint(canvas, new Offset(3 * lineWidth, height)); 1671 | } else if (i < 6) { 1672 | TextSpan span = new TextSpan( 1673 | style: new TextStyle(color: Colors.black, fontSize: 15.0), 1674 | text: data[i]); 1675 | TextPainter textPainter = new TextPainter( 1676 | text: span, 1677 | textAlign: TextAlign.left, 1678 | textDirection: TextDirection.ltr); 1679 | textPainter.layout(); 1680 | textPainter.paint(canvas, 1681 | new Offset(16 * lineWidth + 7 * (i - 1) * lineWidth, height)); 1682 | } else if (i < 11) { 1683 | TextSpan span = new TextSpan( 1684 | style: new TextStyle(color: Colors.black, fontSize: 15.0), 1685 | text: data[i]); 1686 | TextPainter textPainter = new TextPainter( 1687 | text: span, 1688 | textAlign: TextAlign.left, 1689 | textDirection: TextDirection.ltr); 1690 | textPainter.layout(); 1691 | textPainter.paint(canvas, 1692 | new Offset(26 * lineWidth + 7 * (i - 1) * lineWidth, height)); 1693 | } else { 1694 | TextSpan span = new TextSpan( 1695 | style: new TextStyle(color: Colors.black, fontSize: 15.0), 1696 | text: checkCode.toString()); 1697 | TextPainter textPainter = new TextPainter( 1698 | text: span, 1699 | textAlign: TextAlign.left, 1700 | textDirection: TextDirection.ltr); 1701 | textPainter.layout(); 1702 | textPainter.paint(canvas, 1703 | new Offset(35 * lineWidth + 7 * (i - 1) * lineWidth, height)); 1704 | } 1705 | } 1706 | } 1707 | } 1708 | 1709 | void _drawBarCodeUPCE(Canvas canvas, Size size) { 1710 | List codeA = [ 1711 | 0x0d, 1712 | 0x19, 1713 | 0x13, 1714 | 0x3d, 1715 | 0x23, 1716 | 0x31, 1717 | 0x2f, 1718 | 0x3b, 1719 | 0x37, 1720 | 0x0b 1721 | ]; 1722 | List codeB = [ 1723 | 0x27, 1724 | 0x33, 1725 | 0x1b, 1726 | 0x21, 1727 | 0x1d, 1728 | 0x39, 1729 | 0x05, 1730 | 0x11, 1731 | 0x09, 1732 | 0x17 1733 | ]; 1734 | List checkCodeFlag = [ 1735 | 0x38, 1736 | 0x34, 1737 | 0x32, 1738 | 0x31, 1739 | 0x2c, 1740 | 0x26, 1741 | 0x23, 1742 | 0x2a, 1743 | 0x29, 1744 | 0x25 1745 | ]; 1746 | 1747 | final data = params.data; 1748 | final lineWidth = params.lineWidth; 1749 | final hasText = params.withText; 1750 | 1751 | int startCodeSep = 0x05, endCodeSep = 0x15; 1752 | int tmpCode, checkCode, sum2nd, sum3rd, strlen; 1753 | ByteData st = new ByteData(11); 1754 | 1755 | bool hasError = false; 1756 | final painter = new Paint()..style = PaintingStyle.fill; 1757 | double height = hasText ? size.height * 0.85 : size.height; 1758 | 1759 | if (data.length != 8) { 1760 | hasError = true; 1761 | } 1762 | 1763 | String upce2upca; 1764 | switch (data.codeUnitAt(6) - 48) { 1765 | case 0: 1766 | upce2upca = 1767 | data[0] + data[1] + data[2] + '00000' + data[3] + data[4] + data[5]; 1768 | break; 1769 | case 1: 1770 | case 2: 1771 | upce2upca = 1772 | data[0] + data[1] + data[2] + data[6] + '00000' + data[4] + data[5]; 1773 | break; 1774 | case 3: 1775 | upce2upca = 1776 | data[0] + data[1] + data[2] + data[3] + '00000' + data[4] + data[5]; 1777 | break; 1778 | case 4: 1779 | upce2upca = 1780 | data[0] + data[1] + data[2] + data[3] + data[4] + '00000' + data[5]; 1781 | break; 1782 | case 5: 1783 | case 6: 1784 | case 7: 1785 | case 8: 1786 | case 9: 1787 | upce2upca = data[0] + 1788 | data[1] + 1789 | data[2] + 1790 | data[3] + 1791 | data[4] + 1792 | data[5] + 1793 | '0000' + 1794 | data[6]; 1795 | break; 1796 | default: 1797 | break; 1798 | } 1799 | 1800 | for (int i = 0; i < 11; i++) { 1801 | st.setUint8(i, upce2upca.codeUnitAt(i) - 48); 1802 | if (st.getUint8(i) > 9) { 1803 | hasError = true; 1804 | break; 1805 | } 1806 | } 1807 | 1808 | if (hasError) { 1809 | String errorMsg = 1810 | "Invalid content for code UPCE. Please check https://en.wikipedia.org/wiki/Universal_Product_Code#UPC-E for reference."; 1811 | if (this.onError != null) { 1812 | this.onError(errorMsg); 1813 | } else { 1814 | print(errorMsg); 1815 | } 1816 | return; 1817 | } 1818 | 1819 | for (int i = 0; i < 3; i++) { 1820 | Rect rect = new Rect.fromLTWH(8 * lineWidth + i * lineWidth, 0.0, 1821 | lineWidth, hasText ? height * 1.08 : height); 1822 | ((0x04 & (startCodeSep << i)) == 0x04) 1823 | ? painter.color = Colors.black 1824 | : painter.color = Colors.white; 1825 | canvas.drawRect(rect, painter); 1826 | } 1827 | 1828 | sum3rd = st.getUint8(0) + 1829 | st.getUint8(2) + 1830 | st.getUint8(4) + 1831 | st.getUint8(6) + 1832 | st.getUint8(8) + 1833 | st.getUint8(10); 1834 | sum2nd = st.getUint8(1) + 1835 | st.getUint8(3) + 1836 | st.getUint8(5) + 1837 | st.getUint8(7) + 1838 | st.getUint8(9); 1839 | if ((sum2nd + sum3rd * 3) % 10 == 0) { 1840 | checkCode = 0; 1841 | } else { 1842 | checkCode = 10 - (sum2nd + sum3rd * 3) % 10; 1843 | } 1844 | 1845 | for (int i = 0; i < 6; i++) { 1846 | tmpCode = data.codeUnitAt(i + 1) - 48; 1847 | if ((0x20 & (checkCodeFlag[checkCode] << i)) == 0x20) { 1848 | for (int j = 0; j < 7; j++) { 1849 | Rect rect = new Rect.fromLTWH( 1850 | 11 * lineWidth + 7 * i * lineWidth + j * lineWidth, 1851 | 0.0, 1852 | lineWidth, 1853 | height); 1854 | ((0x40 & (codeB[tmpCode] << j)) == 0x40) 1855 | ? painter.color = Colors.black 1856 | : painter.color = Colors.white; 1857 | canvas.drawRect(rect, painter); 1858 | } 1859 | } else { 1860 | for (int k = 0; k < 7; k++) { 1861 | Rect rect = new Rect.fromLTWH( 1862 | 11 * lineWidth + 7 * i * lineWidth + k * lineWidth, 1863 | 0.0, 1864 | lineWidth, 1865 | height); 1866 | ((0x40 & (codeA[tmpCode] << k)) == 0x40) 1867 | ? painter.color = Colors.black 1868 | : painter.color = Colors.white; 1869 | canvas.drawRect(rect, painter); 1870 | } 1871 | } 1872 | } 1873 | 1874 | for (int i = 0; i < 6; i++) { 1875 | Rect rect = new Rect.fromLTWH(53 * lineWidth + i * lineWidth, 0.0, 1876 | lineWidth, hasText ? height * 1.08 : height); 1877 | ((0x20 & (endCodeSep << i)) == 0x20) 1878 | ? painter.color = Colors.black 1879 | : painter.color = Colors.white; 1880 | canvas.drawRect(rect, painter); 1881 | } 1882 | 1883 | if (hasText) { 1884 | (data.length > 8) ? strlen = 8 : strlen = data.length; 1885 | for (int i = 0; i < strlen; i++) { 1886 | if (i == 0) { 1887 | TextSpan span = new TextSpan( 1888 | style: new TextStyle(color: Colors.black, fontSize: 15.0), 1889 | text: data[i]); 1890 | TextPainter textPainter = new TextPainter( 1891 | text: span, 1892 | textAlign: TextAlign.left, 1893 | textDirection: TextDirection.ltr); 1894 | textPainter.layout(); 1895 | textPainter.paint(canvas, new Offset(2 * lineWidth, height)); 1896 | } else if (i < 7) { 1897 | TextSpan span = new TextSpan( 1898 | style: new TextStyle(color: Colors.black, fontSize: 15.0), 1899 | text: data[i]); 1900 | TextPainter textPainter = new TextPainter( 1901 | text: span, 1902 | textAlign: TextAlign.left, 1903 | textDirection: TextDirection.ltr); 1904 | textPainter.layout(); 1905 | textPainter.paint(canvas, 1906 | new Offset(12 * lineWidth + 7 * (i - 1) * lineWidth, height)); 1907 | } else { 1908 | TextSpan span = new TextSpan( 1909 | style: new TextStyle(color: Colors.black, fontSize: 15.0), 1910 | text: checkCode.toString()); 1911 | TextPainter textPainter = new TextPainter( 1912 | text: span, 1913 | textAlign: TextAlign.left, 1914 | textDirection: TextDirection.ltr); 1915 | textPainter.layout(); 1916 | textPainter.paint(canvas, new Offset(60 * lineWidth, height)); 1917 | } 1918 | } 1919 | } 1920 | } 1921 | 1922 | /// ITF painter 1923 | /// 1924 | /// Start pattern is 4 bits of (0, 0, 0, 0) 1925 | /// Stop pattern is 3 bits of (1, 0, 0) 1926 | /// 1927 | /// 0 bits are narrow bars, 1928 | /// 1 bits are wide bars 1929 | /// 1930 | /// Alternating bits are dark/light/dart/light etc.. 1931 | /// 1932 | /// The input data is split into groups of 2 digits, 1933 | /// these bit values are interleaved to form a 10 bit barcode segment 1934 | /// 1935 | /// More info can be found here in Section 5.3 here: https://www.gs1.org/sites/default/files/docs/barcodes/GS1_General_Specifications.pdf 1936 | void _drawBarCodeITF(Canvas canvas, Size size) { 1937 | final itfParams = params as ITFBarCodeParams; 1938 | 1939 | /// Wish this was added right now, https://github.com/dart-lang/language/issues/581 1940 | /// 0 = 0b00110, 1941 | /// 1 = 0b10001, 1942 | /// 2 = 0b01001, 1943 | /// 3 = 0b11000, 1944 | /// 4 = 0b00101, 1945 | /// 5 = 0b10100, 1946 | /// 6 = 0b01100, 1947 | /// 7 = 0b00011, 1948 | /// 8 = 0b10010, 1949 | /// 9 = 0b01010 1950 | /// 1951 | const encodation = [ 1952 | 0x06, 1953 | 0x11, 1954 | 0x09, 1955 | 0x18, 1956 | 0x05, 1957 | 0x14, 1958 | 0x0c, 1959 | 0x03, 1960 | 0x12, 1961 | 0x0a, 1962 | ]; 1963 | 1964 | var cleanData = itfParams.data; 1965 | if (cleanData.length % 2 != 0) { 1966 | cleanData = cleanData.padLeft(2 * (cleanData.length / 2).ceil(), "0"); 1967 | } 1968 | 1969 | final fontSize = 15.0; 1970 | final textPadding = 3.0; 1971 | 1972 | final narrowWidth = itfParams.lineWidth; 1973 | final widedWidth = itfParams.lineWidth * itfParams.wideBarRatio; 1974 | final quietZoneWidth = itfParams.quietZoneRatio * narrowWidth; 1975 | final bearerBarWidth = itfParams.bearerBarRatio * narrowWidth; 1976 | final height = 1977 | itfParams.withText ? size.height - fontSize - textPadding : size.height; 1978 | double offsetX = 0; 1979 | 1980 | final painter = Paint()..style = PaintingStyle.fill; 1981 | final bearerPainter = Paint() 1982 | ..style = PaintingStyle.stroke 1983 | ..strokeWidth = bearerBarWidth; 1984 | 1985 | //Reuse the bars 1986 | final narrowBar = Rect.fromPoints(Offset.zero, Offset(narrowWidth, height)); 1987 | final wideBar = Rect.fromPoints(Offset.zero, Offset(widedWidth, height)); 1988 | 1989 | /// Add quiet zone 1990 | /// 1991 | offsetX += quietZoneWidth; 1992 | 1993 | /// Draw the start pattern 1994 | /// 1995 | canvas.drawRect(narrowBar.translate(offsetX, 0), painter); 1996 | offsetX += narrowWidth + narrowWidth; 1997 | canvas.drawRect(narrowBar.translate(offsetX, 0), painter); 1998 | offsetX += narrowWidth + narrowWidth; 1999 | 2000 | for (var x = 0; x < cleanData.length; x += 2) { 2001 | final v0 = int.tryParse(cleanData[x]); 2002 | final v1 = int.tryParse(cleanData[x + 1]); 2003 | 2004 | //if not a number return 2005 | if (v0 == null || v1 == null) { 2006 | String errorMsg = 2007 | "${cleanData[x]} or ${cleanData[x + 1]} is not a number."; 2008 | if (this.onError != null) { 2009 | this.onError(errorMsg); 2010 | } else { 2011 | print(errorMsg); 2012 | } 2013 | return; 2014 | } 2015 | 2016 | var e0 = encodation[v0]; 2017 | var e1 = encodation[v1]; 2018 | 2019 | // print 1 char pair at a time 2020 | for (var y = 4; y >= 0; y--) { 2021 | final ye0 = (e0 >> y) & 1; 2022 | final ye1 = (e1 >> y) & 1; 2023 | 2024 | canvas.drawRect( 2025 | (ye0 == 0 ? narrowBar : wideBar).translate(offsetX, 0), painter); 2026 | offsetX += 2027 | ye0 == 0 ? narrowWidth : widedWidth; // push by dark bar width 2028 | offsetX += 2029 | ye1 == 0 ? narrowWidth : widedWidth; // push by light bar width 2030 | } 2031 | } 2032 | 2033 | /// Draw the end pattern 2034 | /// 2035 | canvas.drawRect(wideBar.translate(offsetX, 0), painter); 2036 | offsetX += widedWidth + narrowWidth; 2037 | canvas.drawRect(narrowBar.translate(offsetX, 0), painter); 2038 | offsetX += narrowWidth; 2039 | 2040 | /// Add quiet at end 2041 | /// 2042 | offsetX += quietZoneWidth; 2043 | 2044 | /// Draw a bearer bar 2045 | /// 2046 | if (itfParams.withBearerBars ?? true) { 2047 | canvas.drawRect(Rect.fromLTWH(0, 0, offsetX, height), bearerPainter); 2048 | } 2049 | 2050 | /// Draw the text 2051 | /// 2052 | if (itfParams.withText) { 2053 | final labelContent = itfParams.altText ?? cleanData; 2054 | final labelText = itfParams.altText == null && labelContent.length == 14 2055 | ? "${cleanData.substring(0, 1)} ${cleanData.substring(1, 3)} ${cleanData.substring(3, 8)} ${cleanData.substring(8, 13)} ${cleanData.substring(13)}" 2056 | : labelContent; 2057 | final span = TextSpan( 2058 | style: TextStyle( 2059 | color: Colors.black, 2060 | fontSize: fontSize, 2061 | letterSpacing: 5, 2062 | ), 2063 | text: labelText, 2064 | ); 2065 | final textPainter = TextPainter( 2066 | text: span, 2067 | textAlign: TextAlign.left, 2068 | textDirection: TextDirection.ltr, 2069 | ); 2070 | textPainter.layout(); 2071 | textPainter.paint( 2072 | canvas, 2073 | Offset( 2074 | (offsetX - textPainter.width) / 2, //center the text 2075 | height + textPadding, 2076 | ), 2077 | ); 2078 | } 2079 | } 2080 | 2081 | // Codabar painter 2082 | // referred JsBarcode 2083 | // https://github.com/lindell/JsBarcode/blob/master/src/barcodes/codabar/index.js 2084 | void _drawBarCodeCodabar(Canvas canvas, Size size) { 2085 | final bitSet = { 2086 | "0": "101010011", 2087 | "1": "101011001", 2088 | "2": "101001011", 2089 | "3": "110010101", 2090 | "4": "101101001", 2091 | "5": "110101001", 2092 | "6": "100101011", 2093 | "7": "100101101", 2094 | "8": "100110101", 2095 | "9": "110100101", 2096 | "-": "101001101", 2097 | "\$": "101100101", 2098 | ":": "1101011011", 2099 | "/": "1101101011", 2100 | ".": "1101101101", 2101 | "+": "101100110011", 2102 | "A": "1011001001", 2103 | "B": "1001001011", 2104 | "C": "1010010011", 2105 | "D": "1010011001" 2106 | }; 2107 | 2108 | final data = params.data; 2109 | final lineWidth = params.lineWidth; 2110 | final hasText = params.withText; 2111 | 2112 | //int codeValue = 0; 2113 | String bitValue = ''; 2114 | bool hasError = false; 2115 | final painter = new Paint()..style = PaintingStyle.fill; 2116 | double height = hasText ? size.height * 0.85 : size.height; 2117 | 2118 | for (int i = 0; i < data.length; i++) { 2119 | if (bitSet.containsKey(data[i])) { 2120 | bitValue = bitSet[data[i]]; 2121 | } else { 2122 | bitValue = ''; 2123 | hasError = true; 2124 | } 2125 | 2126 | if (hasError) { 2127 | String errorMsg = 2128 | "Invalid content for Coddabar. Please check https://en.wikipedia.org/wiki/Codabar for reference."; 2129 | if (this.onError != null) { 2130 | this.onError(errorMsg); 2131 | } else { 2132 | print(errorMsg); 2133 | } 2134 | return; 2135 | } 2136 | 2137 | for (int j = 0; j < bitValue.length; j++) { 2138 | Rect rect = new Rect.fromLTWH( 2139 | 13 * lineWidth + 13 * i * lineWidth + j * lineWidth, 2140 | 0.0, 2141 | lineWidth, 2142 | height); 2143 | (bitValue[j] == '1') 2144 | ? painter.color = Colors.black 2145 | : painter.color = Colors.white; 2146 | canvas.drawRect(rect, painter); 2147 | } 2148 | } 2149 | 2150 | if (hasText) { 2151 | for (int i = 0; i < data.length; i++) { 2152 | TextSpan span = new TextSpan( 2153 | style: new TextStyle(color: Colors.black, fontSize: 15.0), 2154 | text: data[i]); 2155 | TextPainter textPainter = new TextPainter( 2156 | text: span, 2157 | textAlign: TextAlign.left, 2158 | textDirection: TextDirection.ltr); 2159 | textPainter.layout(); 2160 | textPainter.paint( 2161 | canvas, 2162 | new Offset( 2163 | (size.width - data.length * 13 * lineWidth) / 2 + 2164 | 13 * i * lineWidth, 2165 | height)); 2166 | } 2167 | } 2168 | } 2169 | } 2170 | -------------------------------------------------------------------------------- /lib/src/barcode_params.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Flutter BarCode Widget 3 | * Copyright (c) 2018 the BarCode Flutter authors. 4 | * See LICENSE for distribution and usage details. 5 | */ 6 | 7 | abstract class BarCodeParams { 8 | String data; 9 | bool withText; 10 | double lineWidth; 11 | double barHeight; 12 | double get barCodeWidth; 13 | String altText; 14 | 15 | BarCodeParams( 16 | this.data, 17 | this.withText, 18 | this.lineWidth, 19 | this.barHeight, 20 | this.altText, 21 | ) : assert(data != null, "Data must be set for BarCodeParams"); 22 | } 23 | 24 | /// Params used for the EAN13 BarCode format 25 | /// 26 | class EAN13BarCodeParams extends BarCodeParams { 27 | EAN13BarCodeParams( 28 | String data, { 29 | bool withText = false, 30 | double lineWidth = 2.0, 31 | double barHeight = 100.0, 32 | String altText, 33 | }) : super(data, withText, lineWidth, barHeight, altText); 34 | 35 | @override 36 | double get barCodeWidth => (lineWidth * 113); 37 | } 38 | 39 | /// Params used for the EAN8 BarCode format 40 | /// 41 | class EAN8BarCodeParams extends BarCodeParams { 42 | EAN8BarCodeParams( 43 | String data, { 44 | bool withText = false, 45 | double lineWidth = 2.0, 46 | double barHeight = 100.0, 47 | String altText, 48 | }) : super(data, withText, lineWidth, barHeight, altText); 49 | 50 | @override 51 | double get barCodeWidth => (lineWidth * 81); 52 | } 53 | 54 | /// Params used for the Code39 BarCode format 55 | /// 56 | class Code39BarCodeParams extends BarCodeParams { 57 | Code39BarCodeParams( 58 | String data, { 59 | bool withText = false, 60 | double lineWidth = 2.0, 61 | double barHeight = 100.0, 62 | String altText, 63 | }) : super(data, withText, lineWidth, barHeight, altText); 64 | 65 | @override 66 | double get barCodeWidth => (data.length + 2) * 13 * lineWidth; 67 | } 68 | 69 | /// Params used for the Code93 BarCode format 70 | /// 71 | class Code93BarCodeParams extends BarCodeParams { 72 | Code93BarCodeParams( 73 | String data, { 74 | bool withText = false, 75 | double lineWidth = 2.0, 76 | double barHeight = 100.0, 77 | String altText, 78 | }) : super(data, withText, lineWidth, barHeight, altText); 79 | 80 | @override 81 | double get barCodeWidth => (data.length + 5) * 9 * lineWidth - 3; 82 | } 83 | 84 | /// Params used for the Code128 BarCode format 85 | /// 86 | class Code128BarCodeParams extends BarCodeParams { 87 | Code128BarCodeParams( 88 | String data, { 89 | bool withText = false, 90 | double lineWidth = 2.0, 91 | double barHeight = 100.0, 92 | String altText, 93 | }) : super(data, withText, lineWidth, barHeight, altText); 94 | 95 | @override 96 | double get barCodeWidth => 97 | (data.length + 2) * 11 * lineWidth + 13 * lineWidth; 98 | } 99 | 100 | /// Params used for the UPCA BarCode format 101 | /// 102 | class UPCABarCodeParams extends BarCodeParams { 103 | UPCABarCodeParams( 104 | String data, { 105 | bool withText = false, 106 | double lineWidth = 2.0, 107 | double barHeight = 100.0, 108 | String altText, 109 | }) : super(data, withText, lineWidth, barHeight, altText); 110 | 111 | @override 112 | double get barCodeWidth => (lineWidth * 113); 113 | } 114 | 115 | /// Params used for the UPCE BarCode format 116 | /// 117 | class UPCEBarCodeParams extends BarCodeParams { 118 | UPCEBarCodeParams( 119 | String data, { 120 | bool withText = false, 121 | double lineWidth = 2.0, 122 | double barHeight = 100.0, 123 | String altText, 124 | }) : super(data, withText, lineWidth, barHeight, altText); 125 | 126 | @override 127 | double get barCodeWidth => (lineWidth * 67); 128 | } 129 | 130 | /// Params used for the ITF-14 BarCode format 131 | /// 132 | class ITFBarCodeParams extends BarCodeParams { 133 | /// The width of the wide bars as a multiple of [lineWidth] 134 | /// 135 | /// This must be in the range of 2.25 <=> 3.0 136 | /// 137 | final double wideBarRatio; 138 | 139 | /// The width of the quiet zone as a multiple of [lineWidth] 140 | /// 141 | /// 10 is the minimum value 142 | /// 143 | final double quietZoneRatio; 144 | 145 | /// The width of the bearer bar as a multiple of [lineWidth] 146 | /// 147 | /// 2 is the minimum value 148 | /// 149 | final double bearerBarRatio; 150 | 151 | /// Whether or not to draw bearer bars, this should always be true 152 | /// 153 | final bool withBearerBars; 154 | 155 | ITFBarCodeParams( 156 | String data, { 157 | bool withText = false, 158 | double lineWidth = 2.0, 159 | double barHeight = 100.0, 160 | this.wideBarRatio = 2.5, 161 | this.quietZoneRatio = 10.0, 162 | this.bearerBarRatio = 3.0, 163 | this.withBearerBars = true, 164 | String altText, 165 | }) : assert(wideBarRatio >= 2.25 && wideBarRatio <= 3.0, 166 | "wideBarRatio must be between 2.25 and 3.0"), 167 | assert(quietZoneRatio >= 10, 168 | "quietZoneRatio must be greater or equal to 10"), 169 | assert(bearerBarRatio >= 2, 170 | "bearerBarRatio must be greater or equal to 2"), 171 | super(data, withText, lineWidth, barHeight, altText); 172 | 173 | @override 174 | double get barCodeWidth => 175 | ((data.length / 2).ceil() * (4 * wideBarRatio + 6) + wideBarRatio + 6) * 176 | lineWidth + 177 | (2 * (lineWidth * quietZoneRatio)); 178 | } 179 | 180 | /// Params used for the Codabar BarCode format 181 | /// 182 | class CodabarBarCodeParams extends BarCodeParams { 183 | CodabarBarCodeParams( 184 | String data, { 185 | bool withText = false, 186 | double lineWidth = 2.0, 187 | double barHeight = 100.0, 188 | String altText, 189 | }) : super(data, withText, lineWidth, barHeight, altText); 190 | 191 | @override 192 | double get barCodeWidth => (data.length + 2) * 13 * lineWidth; 193 | } 194 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: barcode_flutter 2 | description: > 3 | Barcode flutter is a Flutter library for simple and fast Bar code rendering via a custom painter. 4 | version: 1.1.2 5 | homepage: https://github.com/bigship/barcode.flutter 6 | 7 | environment: 8 | sdk: ">=2.0.0-dev.58.0 < 3.0.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | 14 | flutter: 15 | uses-material-design: true 16 | --------------------------------------------------------------------------------