diff --git a/Libraries.txt b/Libraries.txt index f51b658..36d7477 100644 --- a/Libraries.txt +++ b/Libraries.txt @@ -1,40 +1,10 @@ -Open Source libraries used in the Scanbot SDK Flutter Plugin version 7.1.1: +Open Source libraries used in the Scanbot SDK Flutter Plugin version 8.0.0: //------------------------------------------------------------- -collection 1.18.0 -Copyright 2015, the Dart project authors. +collection 1.19.1 -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of Google LLC nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -json_serializable +Copyright 2015, the Dart project authors. -version 6.6.1 -(https://github.com/dart-lang/json_serializable/blob/master/LICENSE) -Copyright 2017, the Dart project authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -45,40 +15,7 @@ met: copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -//------------------------------------------------------------- -json_annotation - -version 4.8.1 -(https://github.com/dart-lang/json_serializable/blob/master/LICENSE) -Copyright 2017, the Dart project authors. All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -97,9 +34,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //------------------------------------------------------------- logging -version 1.1.1 +version 1.3.0 + +Copyright 2013, the Dart project authors. -Copyright 2013, the Dart project authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -110,7 +48,7 @@ met: copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -129,8 +67,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //------------------------------------------------------------- lints -version 2.0.1 - +version 6.0.0 Copyright 2021, the Dart project authors. @@ -160,13 +97,13 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - //------------------------------------------------------------- -build_runner +ffi + +version 2.1.4 -version 2.3.3 +Copyright 2019, the Dart project authors. -Copyright 2016, the Dart project authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -177,7 +114,7 @@ met: copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -193,30 +130,9 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -//------------------------------------------------------------- -google-gson - -version 2.8.5 -(https://github.com/google/gson/blob/gson-parent-2.8.5/LICENSE) -Copyright 2008 Google Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - - ------------------------------------------------------------------------------------------------------------------------ -Open Source libraries used in the Scanbot SDK for Android version 7.1.2 +Open Source libraries used in the Scanbot SDK for Android version 8.0.1 CWAC-Camera @@ -302,7 +218,7 @@ limitations under the License. Kotlin Standard Library -Version 1.9.25 +Version 2.1.21 (https://github.com/JetBrains/kotlin) Copyright 2010-2018 JetBrains s.r.o. @@ -372,7 +288,7 @@ limitations under the License. Dagger -Version 2.50 +Version 2.56.2 (https://github.com/google/dagger) Copyright 2012 The Dagger Authors @@ -702,7 +618,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. expected -Version 1.1 +Version 1.1.0 (https://github.com/TartanLlama/expected) Creative Commons Legal Code @@ -833,7 +749,7 @@ express Statement of Purpose. flatbuffers Version 2.0.6 -(https://github.com/google/flatbuffers/tree/master) +(https://github.com/google/flatbuffers) Apache License @@ -1767,7 +1683,7 @@ This work is licensed under a [Creative Commons Attribution-ShareAlike 4.0 Inter JSON for Modern C++ -Version v3.11.3 +Version 3.11.3 (https://github.com/nlohmann/json) MIT License @@ -2177,7 +2093,7 @@ OF THIS SOFTWARE. libzueci -Version 1.0.0 +Version 1.0.1 (https://sourceforge.net/projects/libzueci/) A simple, standalone, BSD-3-Clause C library for converting UTF-8 to/from Extended Channel Interpretations, as @@ -2590,11 +2506,221 @@ Version 1.1.0h ++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + +snowflake-arctic-embed-xs + +Version eadfba3b +(https://huggingface.co/Snowflake/snowflake-arctic-embed-xs/tree/main) + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ spdlog -Version v1.15.2 +Version 1.15.2 (https://github.com/gabime/spdlog) The MIT License (MIT) @@ -3177,7 +3303,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. xtensor -Version 0.26.0-scanbot +Version 0.26.0 (https://github.com/doo/xtensor) Copyright (c) 2016, Johan Mabille, Sylvain Corlay and Wolf Vollprecht @@ -3489,10 +3615,10 @@ Version 1.1.0 See the License for the specific language governing permissions and limitations under the License. -Open Source libraries used in ScanbotSDK for iOS version 7.1.4: - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +Open Source libraries used in ScanbotSDK for iOS version 8.0.1: + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Boost C++ @@ -3790,7 +3916,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. expected -Version 1.1 +Version 1.1.0 (https://github.com/TartanLlama/expected) Creative Commons Legal Code @@ -3921,7 +4047,7 @@ express Statement of Purpose. flatbuffers Version 2.0.6 -(https://github.com/google/flatbuffers/tree/master) +(https://github.com/google/flatbuffers) Apache License @@ -4855,7 +4981,7 @@ This work is licensed under a [Creative Commons Attribution-ShareAlike 4.0 Inter JSON for Modern C++ -Version v3.11.3 +Version 3.11.3 (https://github.com/nlohmann/json) MIT License @@ -5265,7 +5391,7 @@ OF THIS SOFTWARE. libzueci -Version 1.0.0 +Version 1.0.1 (https://sourceforge.net/projects/libzueci/) A simple, standalone, BSD-3-Clause C library for converting UTF-8 to/from Extended Channel Interpretations, as @@ -5678,11 +5804,221 @@ Version 1.1.1t ++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + +snowflake-arctic-embed-xs + +Version eadfba3b +(https://huggingface.co/Snowflake/snowflake-arctic-embed-xs/tree/main) + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ spdlog -Version v1.15.2 +Version 1.15.2 (https://github.com/gabime/spdlog) The MIT License (MIT) @@ -6265,7 +6601,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. xtensor -Version 0.26.0-scanbot +Version 0.26.0 (https://github.com/doo/xtensor) Copyright (c) 2016, Johan Mabille, Sylvain Corlay and Wolf Vollprecht diff --git a/README.md b/README.md index 38ec35f..f4a840a 100644 --- a/README.md +++ b/README.md @@ -105,12 +105,6 @@ Through this feature, our SDK offers document detection and data capture capabil ## Additional information -### Free integration support - -Need help integrating or testing our Document Scanner SDK? We offer [free developer support](https://docs.scanbot.io/support/?utm_source=github.com&utm_medium=referral&utm_campaign=dev_sites) via Slack, MS Teams, or email. - -As a customer, you also get access to a dedicated support Slack or Microsoft Teams channel to talk directly to your Customer Success Manager and our engineers. - ### Trial license and pricing The Scanbot SDK examples will run for one minute per session without a license. After that, all functionalities and UI components will stop working. diff --git a/android/app/build.gradle b/android/app/build.gradle index 6eaf39f..d466ab4 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -7,15 +7,15 @@ plugins { android { namespace = "com.example.scanbot_sdk_example_flutter" - compileSdk = 35 + compileSdk = 36 compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 + sourceCompatibility JavaVersion.VERSION_21 + targetCompatibility JavaVersion.VERSION_21 } kotlinOptions { - jvmTarget = JavaVersion.VERSION_17 + jvmTarget = JavaVersion.VERSION_21 } defaultConfig { diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 351815b..a074af4 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -8,6 +8,7 @@ + diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index a6ca9e7..d31c8d1 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Fri May 10 16:38:24 CEST 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/android/settings.gradle b/android/settings.gradle index be7ad30..b72bea5 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -18,8 +18,8 @@ pluginManagement { plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" - id "com.android.application" version "8.3.2" apply false - id "org.jetbrains.kotlin.android" version "1.9.20" apply false + id "com.android.application" version "8.10.1" apply false + id "org.jetbrains.kotlin.android" version "2.1.21" apply false } include ":app" diff --git a/lib/classic_components/cropping_custom_ui.dart b/lib/classic_components/cropping_custom_ui.dart index 3827267..9306ad0 100644 --- a/lib/classic_components/cropping_custom_ui.dart +++ b/lib/classic_components/cropping_custom_ui.dart @@ -1,21 +1,22 @@ +import 'dart:math'; + import 'package:flutter/material.dart'; +import 'package:logging/logging.dart'; import 'package:scanbot_sdk/scanbot_sdk.dart'; -import 'package:scanbot_sdk/scanbot_sdk.dart' as sdk; -import '../storage/_legacy_pages_repository.dart'; import '../utility/utils.dart'; /// This screen demonstrates how to integrate the classical cropping component class CroppingScreenWidget extends StatefulWidget { - const CroppingScreenWidget({Key? key, required this.page}) : super(key: key); - final sdk.Page page; + const CroppingScreenWidget({Key? key, required this.documentImage}) + : super(key: key); + final ImageRef documentImage; @override _CroppingScreenWidgetState createState() => _CroppingScreenWidgetState(); } class _CroppingScreenWidgetState extends State { - final LegacyPageRepository _pageRepository = LegacyPageRepository(); - late sdk.Page currentPage; + late ImageRef currentPage; bool showProgressBar = false; bool doneButtonEnabled = true; CroppingController? croppingController; @@ -23,7 +24,7 @@ class _CroppingScreenWidgetState extends State { @override void initState() { super.initState(); - currentPage = widget.page; + currentPage = widget.documentImage; } @override @@ -36,36 +37,13 @@ class _CroppingScreenWidgetState extends State { if (showProgressBar) _buildProgressBar(), ], ), - floatingActionButton: _buildFloatingActionButton(), bottomNavigationBar: _buildBottomAppBar(), ); } - Widget _buildFloatingActionButton() { - return FloatingActionButton( - onPressed: _handleNextPage, - child: const Icon(Icons.navigate_next), - ); - } - - Future _handleNextPage() async { - setState(() { - showProgressBar = true; - }); - - final nextPage = await _pageRepository.nextPage(currentPage); - - setState(() { - showProgressBar = false; - currentPage = nextPage; - }); - } - AppBar _buildAppBar() { return AppBar( - iconTheme: const IconThemeData( - color: Colors.white, - ), + iconTheme: const IconThemeData(color: Colors.white), backgroundColor: ScanbotRedColor, title: const Text( 'Crop document', @@ -82,17 +60,14 @@ class _CroppingScreenWidgetState extends State { ), actions: [ if (doneButtonEnabled) - IconButton( - icon: const Icon(Icons.done), - onPressed: cropAndPop, - ), + IconButton(icon: const Icon(Icons.done), onPressed: cropAndPop), ], ); } Widget _buildCroppingWidget() { return ScanbotCroppingWidget( - page: currentPage, + documentImage: currentPage, onViewReady: (controller) { croppingController = controller; }, @@ -101,10 +76,13 @@ class _CroppingScreenWidgetState extends State { showProgressBar = isProcessing; }); }, + onError: (error) { + Logger.root.severe(error.toString()); + }, edgeColor: Colors.red, edgeColorOnLine: Colors.blue, anchorPointsColor: Colors.amberAccent, - borderInsets: sdk.Insets.all(16), + borderInsets: Insets.all(16), ); } @@ -125,7 +103,7 @@ class _CroppingScreenWidgetState extends State { children: [ _buildBottomBarButton('Reset', () => croppingController?.reset()), _buildBottomBarButton('Detect', () => croppingController?.detect()), - _buildBottomBarButton('Rotate Cw', _rotateImage), + _buildBottomBarButton('Rotate \u21BB', _rotateImage), ], ), ); @@ -134,10 +112,7 @@ class _CroppingScreenWidgetState extends State { Widget _buildBottomBarButton(String label, VoidCallback onPressed) { return TextButton( onPressed: doneButtonEnabled ? onPressed : null, - child: Text( - label, - style: const TextStyle(color: Colors.black), - ), + child: Text(label, style: const TextStyle(color: Colors.black)), ); } @@ -155,15 +130,6 @@ class _CroppingScreenWidgetState extends State { }); } - Future proceedImage( - sdk.Page page, CroppingPolygon croppingResult) async { - return await ScanbotSdk.cropAndRotatePage( - page, - croppingResult.polygon, - croppingResult.rotationTimesCw, - ); - } - Future cropAndPop() async { setState(() { showProgressBar = true; @@ -175,9 +141,38 @@ class _CroppingScreenWidgetState extends State { showProgressBar = false; }); - if (croppingResult != null) { - var newPage = await proceedImage(currentPage, croppingResult); - Navigator.of(context).pop(newPage); + if (croppingResult == null) { + Navigator.of(context).pop(); + return; + } + + final documentResult = await ScanbotSdk.document + .createDocumentFromImageRefs(images: [currentPage]); + + if (documentResult is! Ok) { + print(documentResult.toString()); + return; + } + + final document = documentResult.value; + + final modifiedDocumentResult = await ScanbotSdk.document.modifyPage( + document.uuid, + document.pages.first.uuid, + options: ModifyPageOptions( + rotation: ImageRotation.values[croppingResult.rotationTimesCw], + polygon: toPointList(croppingResult.polygon), + ), + ); + + if (modifiedDocumentResult is! Ok) { + print(modifiedDocumentResult.toString()); + return; } + + Navigator.of(context).pop(modifiedDocumentResult.value); } -} \ No newline at end of file +} + +List> toPointList(List polygon) => + polygon.map((p) => Point(p.x, p.y)).toList(); diff --git a/lib/classic_components/custom_ui_menu.dart b/lib/classic_components/custom_ui_menu.dart deleted file mode 100644 index d65f628..0000000 --- a/lib/classic_components/custom_ui_menu.dart +++ /dev/null @@ -1,64 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'package:scanbot_sdk/scanbot_sdk.dart'; -import 'package:scanbot_sdk/scanbot_sdk.dart' as scanbot_sdk; -import 'package:scanbot_sdk/scanbot_sdk_ui.dart'; - -import '../storage/_legacy_pages_repository.dart'; -import '../ui/menu_item_widget.dart'; -import '../ui/preview/_custom_ui_document_preview.dart'; -import '../utility/utils.dart'; - -import '../ui/preview/medical_certificate_preview.dart'; - -import 'document_custom_ui.dart'; -import 'medical_certificate_custom_ui.dart'; - -class CustomUiMenu extends StatelessWidget { - CustomUiMenu({Key? key}) : super(key: key); - - final LegacyPageRepository _pageRepository = LegacyPageRepository(); - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: ScanbotAppBar('Scanbot Custom UI Menu'), - body: ListView( - children: [ - MenuItemWidget(title: 'Scan Documents', onTap: () => _startDocumentsCustomUIScanner(context)), - MenuItemWidget(title: 'Scan Medical Certificate', onTap: () => _startMedicalCertificateCustomUIScanner(context)), - ], - ), - ); - } - - Future _startDocumentsCustomUIScanner(BuildContext context) async { - var result = await Navigator.of(context).push( - MaterialPageRoute(builder: (context) => const DocumentScannerWidget()), - ); - - if (result is List) { - _pageRepository.addPages(result); - await Navigator.of(context).push( - MaterialPageRoute(builder: (context) => CustomUiDocumentPreview()), - ); - } - } - - Future _startMedicalCertificateCustomUIScanner(BuildContext context) async { - var result = await Navigator.of(context).push( - MaterialPageRoute(builder: (context) => const MedicalCertificateScannerWidget()), - ); - - if (result is MedicalCertificateScanningResult) { - await Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => MedicalCertificatePreviewWidget(result)), - ); - } - } -} - - - - diff --git a/lib/classic_components/document_custom_ui.dart b/lib/classic_components/document_custom_ui.dart index d66331f..db654d4 100644 --- a/lib/classic_components/document_custom_ui.dart +++ b/lib/classic_components/document_custom_ui.dart @@ -1,16 +1,13 @@ import 'dart:async'; -import 'dart:io'; import 'package:flutter/material.dart'; import 'package:logging/logging.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:scanbot_sdk/scanbot_sdk.dart'; -import 'package:scanbot_sdk/scanbot_sdk.dart' as sdk; -import '../storage/_legacy_pages_repository.dart'; -import '../ui/pages_widget.dart'; -import '../ui/preview/_custom_ui_document_preview.dart'; +import '../ui/preview/document_preview.dart'; import '../utility/utils.dart'; +import 'cropping_custom_ui.dart'; /// This screen demonstrates how to integrate the classical barcode scanner component. class DocumentScannerWidget extends StatefulWidget { @@ -21,10 +18,6 @@ class DocumentScannerWidget extends StatefulWidget { } class _DocumentScannerWidgetState extends State { - /// Stream used to show live scanned results on top of the camera. - /// If not needed, scanning stops and returns the first result out of the screen. - final resultStream = StreamController(); - /// Stream to monitor the document detection status. final detectionStatusStream = StreamController(); @@ -34,18 +27,10 @@ class _DocumentScannerWidgetState extends State { bool autoSnappingEnabled = true; bool flashAvailable = false; bool showProgressBar = false; - bool licenseIsActive = true; - - late DocumentSnapTrigger generalSnapTrigger; - final LegacyPageRepository _pageRepository = LegacyPageRepository(); + SBException? licenseError; - /// Adds scanned pages to the repository and navigates to the preview screen. - void showPageResult(List pages) { - _pageRepository.addPages(pages); - Navigator.of(context).push( - MaterialPageRoute(builder: (context) => CustomUiDocumentPreview()), - ); - } + DocumentScannerCameraController controller = + DocumentScannerCameraController(); /// Checks camera permission and updates the state accordingly. void checkPermission() async { @@ -75,7 +60,6 @@ class _DocumentScannerWidgetState extends State { children: [ _buildCameraView(), _buildDetectionStatusStream(), - _buildScannedPagePreview(), if (showProgressBar) _buildProgressIndicator(), ], ), @@ -85,18 +69,13 @@ class _DocumentScannerWidgetState extends State { AppBar _buildAppBar() { return AppBar( - iconTheme: const IconThemeData( - color: Colors.white, - ), + iconTheme: const IconThemeData(color: Colors.white), backgroundColor: ScanbotRedColor, leading: GestureDetector( onTap: () { Navigator.of(context).pop(); }, - child: const Icon( - Icons.arrow_back, - color: Colors.white, - ), + child: const Icon(Icons.arrow_back, color: Colors.white), ), title: const Text( 'Scan Documents', @@ -113,7 +92,7 @@ class _DocumentScannerWidgetState extends State { List _buildAppBarActions() { return [ - if (permissionGranted && licenseIsActive) + if (permissionGranted && licenseError == null) IconButton( onPressed: () { if (mounted) { @@ -137,17 +116,15 @@ class _DocumentScannerWidgetState extends State { }); } }, - icon: Icon( - flashEnabled ? Icons.flash_on : Icons.flash_off, - ), + icon: Icon(flashEnabled ? Icons.flash_on : Icons.flash_off), ), ]; } /// Builds the view for the camera, handling different states. Widget _buildCameraView() { - if (!licenseIsActive) { - return _buildErrorMessage('License is no longer active'); + if (licenseError != null) { + return _buildErrorMessage(licenseError!.message); } if (!permissionGranted) { @@ -157,31 +134,37 @@ class _DocumentScannerWidgetState extends State { return Stack( children: [ DocumentScannerCamera( - snapListener: (page) { - resultStream.add(page); - showPageResult([page]); + controller: controller, + onSnappedDocumentResult: ( + ImageRef originalImage, + ImageRef? documentImage, + DocumentDetectionResult? detectionResult, + ) async { + await _startCustomCroppingScreen(originalImage); }, - errorListener: (error) { - if (mounted) { + onError: (error) { + if (error is InvalidLicenseException) { setState(() { - licenseIsActive = false; + licenseError = error; }); + } else { + Logger.root.severe(error.toString()); } - Logger.root.severe(error.toString()); }, - documentContourListener: (result) { - detectionStatusStream.add(result.detectionStatus); + onFrameDetectionResult: (result) { + detectionStatusStream.add(result.status); }, configuration: _buildDocumentCameraConfiguration(), - onCameraPreviewStarted: (snapTrigger, isFlashAvailable) { + onCameraPreviewStarted: (isFlashAvailable) { if (mounted) { setState(() { - generalSnapTrigger = snapTrigger; flashAvailable = isFlashAvailable; }); } }, onHeavyOperationProcessing: (show) { + if (showProgressBar == show) return; + setState(() { showProgressBar = show; }); @@ -194,9 +177,9 @@ class _DocumentScannerWidgetState extends State { alignment: Alignment.bottomCenter, child: Padding( padding: const EdgeInsets.all(24.0), - child: ShutterButton( + child: ShutterButtonView( onPressed: () { - generalSnapTrigger(); + controller.snapDocument(); }, autosnappingMode: autoSnappingEnabled, primaryColor: Colors.pink, @@ -210,13 +193,34 @@ class _DocumentScannerWidgetState extends State { ); } + Future _startCustomCroppingScreen(ImageRef documentImage) async { + if (!await checkLicenseStatus(context)) { + return; + } + + var documentData = await Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => + CroppingScreenWidget(documentImage: documentImage), + ), + ); + + if (documentData != null) { + await Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => DocumentPreview(documentData), + ), + ); + } + } + /// Builds the DocumentCameraConfiguration. DocumentCameraConfiguration _buildDocumentCameraConfiguration() { var documentClassicScannerConfiguration = DocumentClassicScannerConfiguration( autoSnapEnabled: autoSnappingEnabled, - acceptedSizeScore: 75, detectDocumentAfterSnap: false, + acceptedSizeScore: 75, autoSnapSensitivity: 0.5, ); @@ -243,7 +247,9 @@ class _DocumentScannerWidgetState extends State { return StreamBuilder( stream: detectionStatusStream.stream, builder: (context, snapshot) { - if (snapshot.data == null || !permissionGranted || !licenseIsActive) { + if (snapshot.data == null || + !permissionGranted || + licenseError != null) { return Container(); } return SizedBox( @@ -253,8 +259,8 @@ class _DocumentScannerWidgetState extends State { child: Wrap( children: [ DetectionStatusWidget( - status: - snapshot.data ?? DocumentDetectionStatus.ERROR_NOTHING_DETECTED, + status: snapshot.data ?? + DocumentDetectionStatus.ERROR_NOTHING_DETECTED, ), ], ), @@ -264,45 +270,13 @@ class _DocumentScannerWidgetState extends State { ); } - /// Builds the StreamBuilder for displaying scanned pages. - Widget _buildScannedPagePreview() { - return StreamBuilder( - stream: resultStream.stream, - builder: (context, snapshot) { - if (snapshot.data == null) { - return Container(); - } - return autoSnappingEnabled - ? SizedBox( - width: double.infinity, - height: double.infinity, - child: Align( - alignment: Alignment.bottomRight, - child: SizedBox( - width: 100, - height: 200, - child: FadeOutView( - key: Key(snapshot.data?.pageId ?? ""), - fadeDelay: const Duration(milliseconds: 500), - child: PagePreview(page: snapshot.data!), - ), - ), - ), - ) - : Container(); - }, - ); - } - /// Builds a progress indicator to show when a heavy operation is in progress. Widget _buildProgressIndicator() { return const Center( child: SizedBox( width: 100, height: 100, - child: CircularProgressIndicator( - strokeWidth: 10, - ), + child: CircularProgressIndicator(strokeWidth: 10), ), ); } @@ -314,10 +288,7 @@ class _DocumentScannerWidgetState extends State { width: double.infinity, height: double.infinity, alignment: Alignment.center, - child: Text( - message, - style: const TextStyle(fontSize: 16), - ), + child: Text(message, style: const TextStyle(fontSize: 16)), ); } } @@ -336,10 +307,7 @@ class DetectionStatusWidget extends StatelessWidget { color: Colors.green.withAlpha(150), borderRadius: const BorderRadiusDirectional.all(Radius.circular(5)), shape: BoxShape.rectangle, - border: Border.all( - color: Colors.green.withAlpha(150), - width: 1.0, - ), + border: Border.all(color: Colors.green.withAlpha(150), width: 1.0), ), child: Padding( padding: const EdgeInsets.all(8.0), @@ -352,32 +320,3 @@ class DetectionStatusWidget extends StatelessWidget { ); } } - -/// A widget to preview the scanned page. -class PagePreview extends StatelessWidget { - final sdk.Page page; - - const PagePreview({Key? key, required this.page}) : super(key: key); - - @override - Widget build(BuildContext context) { - var documentPreviewFile = File.fromUri(page.documentPreviewImageFileUri!); - var originalPreviewFile = File.fromUri(page.originalPreviewImageFileUri!); - var file = documentPreviewFile.existsSync() - ? documentPreviewFile - : originalPreviewFile; - var imageUri = documentPreviewFile.existsSync() - ? page.documentPreviewImageFileUri! - : page.originalPreviewImageFileUri!; - - if (file.existsSync()) { - return SizedBox( - height: 200, - child: shouldInitWithEncryption - ? EncryptedPageWidget(imageUri) - : PageWidget(imageUri), - ); - } - return Container(); - } -} diff --git a/lib/classic_components/medical_certificate_custom_ui.dart b/lib/classic_components/medical_certificate_custom_ui.dart deleted file mode 100644 index 639b67c..0000000 --- a/lib/classic_components/medical_certificate_custom_ui.dart +++ /dev/null @@ -1,232 +0,0 @@ -import 'dart:async'; -import 'package:flutter/material.dart'; -import 'package:flutter/material.dart' as material; -import 'package:logging/logging.dart'; -import 'package:permission_handler/permission_handler.dart'; -import 'package:scanbot_sdk/scanbot_sdk.dart'; -import 'package:scanbot_sdk_example_flutter/ui/preview/medical_certificate_preview.dart'; -import '../utility/utils.dart'; - -class MedicalCertificateScannerWidget extends StatefulWidget { - const MedicalCertificateScannerWidget({Key? key}) : super(key: key); - - @override - _MedicalCertificateScannerWidgetState createState() => - _MedicalCertificateScannerWidgetState(); -} - -class _MedicalCertificateScannerWidgetState - extends State { - bool permissionGranted = false; - bool flashEnabled = false; - bool flashAvailable = false; - bool showProgressBar = false; - bool licenseIsActive = true; - - @override - void initState() { - super.initState(); - _checkPermission(); // Check for camera permissions when initializing the widget - } - - // Check and request camera permissions - void _checkPermission() async { - final permissionResult = await [Permission.camera].request(); - setState(() { - permissionGranted = - permissionResult[Permission.camera]?.isGranted ?? false; - }); - } - - // Handle the scanning result and navigate to the result screen - Future _showResult(MedicalCertificateScanningResult scanningResult) async { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => MedicalCertificatePreviewWidget(scanningResult), - ), - ); - } - - // Configuration for the Medical Certificate Classic Scanner - MedicalCertificateClassicScannerConfiguration _buildScannerConfiguration() { - return MedicalCertificateClassicScannerConfiguration( - recognizePatientInfo: true, - recognizeBarcode: true, - captureHighResolutionImage: true, - ); - } - - // Configuration for the Finder (area to scan) - FinderConfiguration _buildFinderConfiguration() { - return FinderConfiguration( - // finderAspectRatio: sdk.AspectRatio(width: 3.0, height: 4.0), - onFinderRectChange: (left, top, right, bottom) { - // aligning some text view to the finder dynamically by calculating its position from finder changes - }, - topWidget: const Center( - child: Text( - 'Top hint text in centre', - style: TextStyle(color: Colors.white), - ), - ), - bottomWidget: const Align( - alignment: Alignment.topCenter, - child: Text( - 'Bottom hint text in topCenter', - style: TextStyle(color: Colors.white), - ), - ), - widget: Center( - child: Padding( - padding: const EdgeInsets.all(16), - child: material.AspectRatio( - aspectRatio: 4 / 3.0, - child: Container( - decoration: BoxDecoration( - border: Border.all( - width: 5, - color: Colors.lightBlue.withAlpha(155), - ), - borderRadius: const BorderRadius.all(Radius.circular(20)), - ), - ), - ), - ), - ), - decoration: BoxDecoration( - border: Border.all( - width: 5, - color: Colors.deepPurple, - ), - borderRadius: const BorderRadius.all(Radius.circular(20)), - ), - backgroundColor: Colors.amber.withAlpha(150), - ); - } - - // Configuration for the Medical Certificate Camera - MedicalCertificateCameraConfiguration _buildCameraConfiguration() { - return MedicalCertificateCameraConfiguration( - flashEnabled: flashEnabled, // Initial flash state - scannerConfiguration: - _buildScannerConfiguration(), // Scanner configuration - finder: _buildFinderConfiguration(), // Finder configuration - ); - } - - AppBar _buildAppBar() { - return AppBar( - iconTheme: const IconThemeData( - color: Colors.white, - ), - leading: GestureDetector( - onTap: () { - Navigator.of(context).pop(); - }, - child: const Icon( - Icons.arrow_back, - color: Colors.white, - ), - ), - backgroundColor: ScanbotRedColor, - title: const Text( - 'Scan Medical Certificate', - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w400, - color: Colors.white, - fontFamily: 'Roboto', - ), - ), - actions: [ - if (flashAvailable) - IconButton( - onPressed: () { - if (mounted) { - setState(() { - flashEnabled = !flashEnabled; - }); - } - }, - icon: Icon( - flashEnabled ? Icons.flash_on : Icons.flash_off, - color: Colors.white, - ), - ), - ], - ); - } - - // Error message display for permissions and license status - Widget _buildErrorMessage(String message) { - return Container( - color: Colors.white, - width: double.infinity, - height: double.infinity, - alignment: Alignment.center, - child: Text( - message, - style: const TextStyle(fontSize: 16), - ), - ); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: _buildAppBar(), - body: Container( - color: Colors.black, - child: Stack( - children: [ - // Show camera view if license is active and permissions are granted, otherwise show an error message - licenseIsActive - ? permissionGranted - ? MedicalCertificateScannerCamera( - configuration: _buildCameraConfiguration(), - onCameraPreviewStarted: (isFlashAvailable) { - if (mounted) { - setState(() { - flashAvailable = isFlashAvailable; - }); - } - }, - mcListener: (scanningResult) { - if (scanningResult.scanningSuccessful) { - _showResult(scanningResult); - } - }, - errorListener: (error) { - if (mounted) { - setState(() { - licenseIsActive = false; - }); - } - Logger.root.severe(error.toString()); - }, - onHeavyOperationProcessing: (show) { - setState(() { - showProgressBar = show; - }); - }, - ) - : _buildErrorMessage('Permissions not granted') - : _buildErrorMessage('License has expired'), - - // Show progress indicator if a heavy operation is in progress - if (showProgressBar) - const Center( - child: SizedBox( - width: 100, - height: 100, - child: CircularProgressIndicator( - strokeWidth: 10, - ), - ), - ), - ], - ), - ), - ); - } -} diff --git a/lib/data_capture/_legacy_use_cases.dart b/lib/data_capture/_legacy_use_cases.dart deleted file mode 100644 index b4c562c..0000000 --- a/lib/data_capture/_legacy_use_cases.dart +++ /dev/null @@ -1,158 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:logging/logging.dart'; -import 'package:scanbot_sdk/scanbot_sdk_ui.dart'; - -import '../ui/menu_item_widget.dart'; -import '../ui/preview/check_preview.dart'; -import '../ui/preview/ehic_preview.dart'; -import '../ui/preview/medical_certificate_preview.dart'; -import '../ui/preview/vin_preview.dart'; -import '../utility/utils.dart'; - -class LegacyDataCaptureUseCases extends StatelessWidget { - const LegacyDataCaptureUseCases({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const TitleItemWidget(title: 'Legacy Data Detectors'), - MenuItemWidget( - title: "Scan EHIC (European Health Insurance Card)", - onTap: () => startEhicScanner(context)), - MenuItemWidget( - title: "Scan VIN", onTap: () => startVINScanner(context)), - MenuItemWidget( - title: "Scan Check", onTap: () => startCheckScanner(context)), - MenuItemWidget( - title: "Scan Medical Certificate", - onTap: () => startMedicalCertificateScanner(context)), - - ], - ); - } - - Future startDetector({ - required BuildContext context, - required Future Function() scannerFunction, - required Future Function(BuildContext, T result) handleResult, - }) async { - if (!await checkLicenseStatus(context)) return; - - try { - final result = await scannerFunction(); - await handleResult(context, result); - } catch (e) { - Logger.root.severe(e); - } - } - - Future startVINScanner(BuildContext context) async { - var configuration = VinScannerScreenConfiguration(); - configuration.topBarBackgroundColor = ScanbotRedColor; - configuration.topBarButtonsActiveColor = Colors.white; - // Configure other parameters as needed. - - await startDetector>( - context: context, - scannerFunction: () => ScanbotSdkUi.startVinScanner(configuration), - handleResult: (context, result) async { - if (result.status == OperationStatus.OK) { - await Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => VinScannerResultPreview(scanningResult: result.data!)), - ); - } else { - await showAlertDialog( - context, "Operation Status: ${result.status.name}"); - } - }, - ); - } - - Future startCheckScanner(BuildContext context) async { - var configuration = CheckScannerScreenConfiguration(); - configuration.topBarBackgroundColor = ScanbotRedColor; - configuration.topBarButtonsActiveColor = Colors.white; - // Configure other parameters as needed. - - await startDetector>( - context: context, - scannerFunction: () => _runCheckScanner(configuration), - handleResult: (context, result) async { - if (result.status == OperationStatus.OK) { - await Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => CheckDocumentResultPreview(scanningResult: result.data!)), - ); - } else { - await showAlertDialog( - context, "Operation Status: ${result.status.name}"); - } - }, - ); - } - - Future> _runCheckScanner( - CheckScannerScreenConfiguration configuration) async { - /// You must use autorelease for result object - /// otherwise you'll get exception "AutoReleasable objects must be created within autorelease" - - return await autorelease(() async { - var checkScanningResult = await ScanbotSdkUi.startCheckScanner(configuration); - /// if you want to use image later, call encodeImages() to save in buffer - // checkScanningResult.data?.encodeImages(); - return checkScanningResult; - }); - } - - Future startMedicalCertificateScanner(BuildContext context) async { - var configuration = MedicalCertificateScannerConfiguration(); - configuration.returnCroppedDocumentImage = false; - configuration.topBarBackgroundColor = ScanbotRedColor; - configuration.topBarButtonsActiveColor = Colors.white; - // Configure other parameters as needed. - - await startDetector>( - context: context, - scannerFunction: () => - ScanbotSdkUi.startMedicalCertificateScanner(configuration), - handleResult: (context, result) async { - if (result.status == OperationStatus.OK) { - await Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => - MedicalCertificatePreviewWidget(result.data!)), - ); - } else { - await showAlertDialog( - context, "Operation Status: ${result.status.name}"); - } - }, - ); - } - - Future startEhicScanner(BuildContext context) async { - var configuration = HealthInsuranceCardScannerConfiguration(); - // Configure parameters as needed. - - await startDetector< - ResultWrapper>( - context: context, - scannerFunction: () => ScanbotSdkUi.startEhicScanner(configuration), - handleResult: (context, result) async { - if (result.status == OperationStatus.OK) { - await Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => - EuropeanHealthInsuranceCardResultPreview(result.data!)), - ); - } else { - await showAlertDialog( - context, "Operation Status: ${result.status.name}"); - } - }, - ); - } -} diff --git a/lib/data_capture/data_capture_sdk_menu.dart b/lib/data_capture/data_capture_sdk_menu.dart index 5725436..ad7512e 100644 --- a/lib/data_capture/data_capture_sdk_menu.dart +++ b/lib/data_capture/data_capture_sdk_menu.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import '../utility/utils.dart'; -import '_legacy_use_cases.dart'; import 'data_capture_use_cases.dart'; class DataCaptureSdkMenu extends StatelessWidget { @@ -11,13 +10,7 @@ class DataCaptureSdkMenu extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: ScanbotAppBar('Scanbot Data Capture SDK Menu'), - body: ListView( - children: const [ - DataCaptureUseCases(), - LegacyDataCaptureUseCases(), - ], - ), + body: ListView(children: const [DataCaptureUseCases()]), ); } } - diff --git a/lib/data_capture/data_capture_use_cases.dart b/lib/data_capture/data_capture_use_cases.dart index 25246c9..6557f87 100644 --- a/lib/data_capture/data_capture_use_cases.dart +++ b/lib/data_capture/data_capture_use_cases.dart @@ -1,14 +1,10 @@ import 'package:flutter/material.dart'; -import 'package:logging/logging.dart'; import 'package:scanbot_sdk/scanbot_sdk.dart'; -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; import 'package:scanbot_sdk_example_flutter/ui/preview/check_preview.dart'; import 'package:scanbot_sdk_example_flutter/ui/preview/credit_card_preview.dart'; import '../ui/menu_item_widget.dart'; -import '../ui/preview/ehic_preview.dart'; import '../ui/preview/extracted_document_data_preview.dart'; -import '../ui/preview/medical_certificate_preview.dart'; import '../ui/preview/mrz_document_preview.dart'; import '../ui/preview/text_pattern_preview.dart'; import '../ui/preview/vin_preview.dart'; @@ -23,49 +19,55 @@ class DataCaptureUseCases extends StatelessWidget { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const TitleItemWidget(title: 'Recognizers'), + const TitleItemWidget(title: 'Data Detectors on Still Images'), MenuItemWidget( - title: "Recognize MRZ from Still Image", - onTap: () => _recognizeMrzOnImage(context)), + title: "Scan MRZ from Still Image", + onTap: () => _scanMrzOnImage(context), + ), MenuItemWidget( - title: "Recognize Medical Certificate from Still Image", - onTap: () => _recognizeMedicalCertificateOnImage(context)), + title: "Extract Document Data from Still Image", + onTap: () => _extractDocumentDataFromImage(context), + ), MenuItemWidget( - title: "Recognize EHIC from Still Image", - onTap: () => _recognizeHealthInsuranceCardOnImage(context)), + title: "Scan Check from Still Image", + onTap: () => _scanCheckOnImage(context), + ), MenuItemWidget( - title: "Extract Document Data from Still Image", - onTap: () => _extractDocumentDataFromImage(context)), - MenuItemWidget( - title: "Recognize Check from Still Image", - onTap: () => _recognizeCheckOnImage(context)), - MenuItemWidget( - title: "Recognize Credit Card from Still Image", - onTap: () => _recognizeCreditCardOnImage(context)), + title: "Scan Credit Card from Still Image", + onTap: () => _scanCreditCardOnImage(context), + ), const TitleItemWidget(title: 'Data Detectors'), MenuItemWidget( - title: "Extract Document Data", - onTap: () => _startDocumentDataExtractorScanner(context)), + title: "Scan MRZ (Machine Readable Zone)", + onTap: () => startMRZScanner(context), + ), MenuItemWidget( - title: "Scan MRZ (Machine Readable Zone)", - onTap: () => startMRZScanner(context)), + title: "Extract Document Data", + onTap: () => _startDocumentDataExtractorScanner(context), + ), MenuItemWidget( - title: "Scan VIN", onTap: () => startVINScanner(context)), + title: "Scan VIN", + onTap: () => startVINScanner(context), + ), MenuItemWidget( - title: "Scan Check", onTap: () => startCheckScanner(context)), + title: "Scan Check", + onTap: () => startCheckScanner(context), + ), MenuItemWidget( - title: "Scan Text Data", - onTap: () => startTextDataScanner(context)), + title: "Scan Text Data", + onTap: () => startTextDataScanner(context), + ), MenuItemWidget( - title: "Scan Credit Scanner", - onTap: () => startCreditCardScanner(context)), + title: "Scan Credit Scanner", + onTap: () => startCreditCardScanner(context), + ), ], ); } - Future startRecognizer({ + Future scanOnImage({ required BuildContext context, - required Future Function(String path) scannerFunction, + required Future> Function(String path) scannerFunction, required Future Function(BuildContext, T result) handleResult, }) async { if (!await checkLicenseStatus(context)) return; @@ -73,53 +75,48 @@ class DataCaptureUseCases extends StatelessWidget { final dialog = ProgressDialog(context); dialog.style(message: 'Please wait...'); - try { - final response = await selectImageFromLibrary(); + final response = await selectImageFromLibrary(); - if (response != null && response.path.isNotEmpty) { - dialog.show(); + if (response != null && response.path.isNotEmpty) { + dialog.show(); - final result = await scannerFunction(response.path); - await handleResult(context, result); - await dialog.hide(); + final result = await scannerFunction(response.path); + if (result is Ok) { + await handleResult(context, result.value); + } else { + print(result.toString()); } - } catch (e) { - Logger.root.severe(e); - } finally { await dialog.hide(); } } - Future startDetector({ + Future startScanner({ required BuildContext context, required Future Function() scannerFunction, required Future Function(BuildContext, T result) handleResult, }) async { if (!await checkLicenseStatus(context)) return; - try { - final result = await scannerFunction(); - await handleResult(context, result); - } catch (e) { - Logger.root.severe(e); - } + final result = await scannerFunction(); + await handleResult(context, result); } - Future _recognizeMrzOnImage(BuildContext context) async { + Future _scanMrzOnImage(BuildContext context) async { var configuration = MrzScannerConfiguration(); configuration.incompleteResultHandling = MrzIncompleteResultHandling.REJECT; // Configure other parameters as needed. - await startRecognizer( + await scanOnImage( context: context, - scannerFunction: (path) => ScanbotSdk.recognizeOperations - .recognizeMrzOnImage(path, configuration), + scannerFunction: (path) => + ScanbotSdk.mrz.scanFromImageFileUri(path, configuration), handleResult: (context, result) async { if (result.success) { await Navigator.of(context).push( MaterialPageRoute( - builder: (context) => - MrzDocumentResultPreview(scannerResult: result)), + builder: (context) => + MrzDocumentResultPreview(scannerResult: result), + ), ); } else { await showAlertDialog(context, "Operation Status: ${result.success}"); @@ -128,186 +125,140 @@ class DataCaptureUseCases extends StatelessWidget { ); } - Future _recognizeMedicalCertificateOnImage(BuildContext context) async { - var configuration = MedicalCertificateScanningParameters(); - configuration.recognizePatientInfoBox = true; + Future _extractDocumentDataFromImage(BuildContext context) async { + var commonConfig = DocumentDataExtractorCommonConfiguration( + acceptedDocumentTypes: [ + DeIdCardFront.DOCUMENT_TYPE, + DeIdCardBack.DOCUMENT_TYPE, + DeHealthInsuranceCardFront.DOCUMENT_TYPE, + DePassport.DOCUMENT_TYPE, + DeResidencePermitFront.DOCUMENT_TYPE, + DeResidencePermitBack.DOCUMENT_TYPE, + EuropeanDriverLicenseFront.DOCUMENT_TYPE, + EuropeanDriverLicenseBack.DOCUMENT_TYPE, + EuropeanHealthInsuranceCard.DOCUMENT_TYPE, + ], + ); + + var configuration = DocumentDataExtractorConfiguration( + configurations: [commonConfig], + ); // Configure other parameters as needed. - await startRecognizer( + await scanOnImage( context: context, - scannerFunction: (path) => ScanbotSdk.recognizeOperations - .recognizeMedicalCertificateOnImage(path, configuration), + scannerFunction: (path) => ScanbotSdk.documentDataExtractor + .extractFromImageFileUri(path, configuration), handleResult: (context, result) async { - if (result.scanningSuccessful) { + if (result.document != null) { await Navigator.of(context).push( MaterialPageRoute( - builder: (context) => MedicalCertificatePreviewWidget(result)), + builder: (context) => + ExtractedDocumentDataPreview(scanningResult: result), + ), ); } else { await showAlertDialog( - context, "Operation Status: ${result.scanningSuccessful}"); + context, + "Operation Status: ${result.status.name}", + ); } }, ); } - Future _recognizeHealthInsuranceCardOnImage( - BuildContext context) async { - var configuration = EuropeanHealthInsuranceCardRecognizerConfiguration(); - configuration.maxExpirationYear = 2100; + Future _scanCheckOnImage(BuildContext context) async { + var configuration = CheckScannerConfiguration(); + configuration.documentDetectionMode = + CheckDocumentDetectionMode.DETECT_AND_CROP_DOCUMENT; // Configure other parameters as needed. - await startRecognizer( + await scanOnImage( context: context, - scannerFunction: (path) => ScanbotSdk.recognizeOperations - .recognizeHealthInsuranceCardOnImage(path, configuration), + scannerFunction: (path) => ScanbotSdk.check.scanFromImageFileUri( + path, + configuration, + ), handleResult: (context, result) async { if (result.status == - EuropeanHealthInsuranceCardRecognitionResultRecognitionStatus - .SUCCESS) { + CheckMagneticInkStripScanningStatus.ERROR_NOTHING_FOUND) { + await showAlertDialog( + context, + "Operation Status: ${result.status.name}", + ); + } else { await Navigator.of(context).push( MaterialPageRoute( - builder: (context) => - EuropeanHealthInsuranceCardResultPreview(result)), + builder: (context) => + CheckDocumentResultPreview(scanningResult: result), + ), ); - } else { - await showAlertDialog( - context, "Operation Status: ${result.status.name}"); } }, ); } - Future _extractDocumentDataFromImage(BuildContext context) async { - var commonConfig = DocumentDataExtractorCommonConfiguration(acceptedDocumentTypes: [ - DeIdCardFront.DOCUMENT_TYPE, - DeIdCardBack.DOCUMENT_TYPE, - DeHealthInsuranceCardFront.DOCUMENT_TYPE, - DePassport.DOCUMENT_TYPE, - DeResidencePermitFront.DOCUMENT_TYPE, - DeResidencePermitBack.DOCUMENT_TYPE, - EuropeanDriverLicenseFront.DOCUMENT_TYPE, - EuropeanDriverLicenseBack.DOCUMENT_TYPE, - EuropeanHealthInsuranceCard.DOCUMENT_TYPE, - ]); - - var configuration = DocumentDataExtractorConfiguration( - configurations: [commonConfig], - ); - // Configure other parameters as needed. - - await startRecognizer( - context: context, - scannerFunction: (path) => - _runDocumentDataRecognizer(configuration, path), - handleResult: (context, result) async { - if (result.document != null) { - await Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => ExtractedDocumentDataPreview(scanningResult: result)), - ); - } else { - await showAlertDialog( - context, "Operation Status: ${result.status.name}"); - } - }); - } - - Future _runDocumentDataRecognizer( - DocumentDataExtractorConfiguration configuration, String path) async { - /// You must use autorelease for result object - /// otherwise you'll get exception "AutoReleasable objects must be created within autorelease" - - return await autorelease(() async { - var extractedData = await ScanbotSdk.recognizeOperations.extractDocumentDataFromImage(path, configuration); - /// if you want to use image later, call encodeImages() to save in buffer - // extractedData.encodeImages(); - return extractedData; - }); - } - - Future _recognizeCheckOnImage(BuildContext context) async { - var configuration = CheckScannerConfiguration(); - configuration.documentDetectionMode = - CheckDocumentDetectionMode.DETECT_AND_CROP_DOCUMENT; + Future _scanCreditCardOnImage(BuildContext context) async { + var configuration = CreditCardScannerConfiguration(); + configuration.requireExpiryDate = true; // Configure other parameters as needed. - await startRecognizer( + await scanOnImage( context: context, - scannerFunction: (path) => _runCheckRecognize(configuration, path), + scannerFunction: (path) => + ScanbotSdk.creditCard.scanFromImageFileUri(path, configuration), handleResult: (context, result) async { - if (result.status == CheckMagneticInkStripScanningStatus.ERROR_NOTHING_FOUND) { - await showAlertDialog(context, "Operation Status: ${result.status.name}"); - } else { + if (result.scanningStatus != + CreditCardScanningStatus.ERROR_NOTHING_FOUND) { await Navigator.of(context).push( MaterialPageRoute( - builder: (context) => CheckDocumentResultPreview(scanningResult: result)), + builder: (context) => + CreditCardResultPreview(scanningResult: result), + ), + ); + } else { + await showAlertDialog( + context, + "Operation Status: ${result.scanningStatus.name}", ); } }, ); } - Future _runCheckRecognize( - CheckScannerConfiguration configuration, String path) async { - /// You must use autorelease for result object - /// otherwise you'll get exception "AutoReleasable objects must be created within autorelease" - - return await autorelease(() async { - var checkScanningResult = await ScanbotSdk.recognizeOperations.recognizeCheckOnImage(path, configuration); - /// if you want to use image later, call encodeImages() to save in buffer - // checkScanningResult.encodeImages(); - return checkScanningResult; - }); - } - - Future _recognizeCreditCardOnImage(BuildContext context) async { - var configuration = CreditCardScannerConfiguration(); - configuration.requireExpiryDate = true; - // Configure other parameters as needed. - - await startRecognizer( - context: context, - scannerFunction: (path) => ScanbotSdk.recognizeOperations - .recognizeCreditCardOnImage(path, configuration), - handleResult: (context, result) async { - if (result.scanningStatus != - CreditCardScanningStatus.ERROR_NOTHING_FOUND) { - await Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => - CreditCardResultPreview(scanningResult: result)), - ); - } else { - await showAlertDialog( - context, "Operation Status: ${result.scanningStatus.name}"); - } - }); - } - Future startVINScanner(BuildContext context) async { var configuration = VinScannerScreenConfiguration(); configuration.introScreen.explanation.text = - 'Quickly and securely scan the VIN by holding your device over the vehicle identification number or vehicle identification barcode' + - '\\nThe scanner will guide you to the optimal scanning position.' + + 'Quickly and securely scan the VIN by holding your device over the vehicle identification number or vehicle identification barcode' + '\\nThe scanner will guide you to the optimal scanning position.' 'Once the scan is complete, your VIN details will automatically be extracted and processed.'; // Configure the done button. E.g., the text or the background color. configuration.introScreen.doneButton.text = 'Start Scanning'; - configuration.introScreen.doneButton.background.fillColor = ScanbotColor('#C8193C'); + configuration.introScreen.doneButton.background.fillColor = ScanbotColor( + '#C8193C', + ); // Configure other parameters as needed. - await startDetector>( + await startScanner>( context: context, - scannerFunction: () => ScanbotSdkUiV2.startVINScanner(configuration), + scannerFunction: () => ScanbotSdk.vin.startScanner(configuration), handleResult: (context, result) async { - if (result.status == OperationStatus.OK) { - await Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => VinScannerResultPreview(uiResult: result.data!)), - ); - } else { - await showAlertDialog( - context, "Operation Status: ${result.status.name}"); + switch (result) { + case Ok(): + await Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => + VinScannerResultPreview(uiResult: result.value), + ), + ); + case Error(): + await showAlertDialog( + context, + title: "Error", + result.error.message, + ); + case Cancel(): + print("Operation was canceled"); } }, ); @@ -318,40 +269,32 @@ class DataCaptureUseCases extends StatelessWidget { configuration.viewFinder.overlayColor = ScanbotColor('#C8193C'); // Configure other parameters as needed. - await startDetector>( + await startScanner>( context: context, - scannerFunction: () => _runDocumentDataExtractor(configuration), + scannerFunction: () => + ScanbotSdk.documentDataExtractor.startExtractorScreen(configuration), handleResult: (context, result) async { - if (result.status == OperationStatus.OK) { - await Navigator.of(context).push( - MaterialPageRoute( + switch (result) { + case Ok(): + await Navigator.of(context).push( + MaterialPageRoute( builder: (context) => - ExtractedDocumentDataPreview(uiResult: result.data!)), - ); - } else { - await showAlertDialog( - context, "Operation Status: ${result.status.name}"); + ExtractedDocumentDataPreview(uiResult: result.value), + ), + ); + case Error(): + await showAlertDialog( + context, + title: "Error", + result.error.message, + ); + case Cancel(): + print("Operation was canceled"); } }, ); } - Future> - _runDocumentDataExtractor( - DocumentDataExtractorScreenConfiguration configuration) async { - /// You must use autorelease for result object - /// otherwise you'll get exception "AutoReleasable objects must be created within autorelease" - - return await autorelease(() async { - var extractedData = await ScanbotSdkUiV2.startDocumentDataExtractor(configuration); - /// if you want to use image later, call encodeImages() to save in buffer - // extractedData.data?.forEach((item) { - // item.encodeImages(); - // }); - return extractedData; - }); - } - Future startCheckScanner(BuildContext context) async { var configuration = CheckScannerScreenConfiguration(); // Modify behaviors @@ -361,36 +304,31 @@ class DataCaptureUseCases extends StatelessWidget { configuration.palette.sbColorOnPrimary = ScanbotColor('#FFFFFF'); // Configure other parameters as needed. - await startDetector>( + await startScanner>( context: context, - scannerFunction: () => _runCheckScanner(configuration), + scannerFunction: () => ScanbotSdk.check.startScanner(configuration), handleResult: (context, result) async { - if (result.status == OperationStatus.OK) { - await Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => CheckDocumentResultPreview(uiResult: result.data!)), - ); - } else { - await showAlertDialog( - context, "Operation Status: ${result.status.name}"); + switch (result) { + case Ok(): + await Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => + CheckDocumentResultPreview(uiResult: result.value), + ), + ); + case Error(): + await showAlertDialog( + context, + title: "Error", + result.error.message, + ); + case Cancel(): + print("Operation was canceled"); } }, ); } - Future> _runCheckScanner( - CheckScannerScreenConfiguration configuration) async { - /// You must use autorelease for result object - /// otherwise you'll get exception "AutoReleasable objects must be created within autorelease" - - return await autorelease(() async { - var checkScanningResult = await ScanbotSdkUiV2.startCheckScanner(configuration); - /// if you want to use image later, call encodeImages() to save in buffer - // checkScanningResult.data?.encodeImages(); - return checkScanningResult; - }); - } - Future startTextDataScanner(BuildContext context) async { var configuration = TextPatternScannerScreenConfiguration(); // Show the top user guidance @@ -399,20 +337,26 @@ class DataCaptureUseCases extends StatelessWidget { configuration.topUserGuidance.title.text = 'Customized title'; // Configure parameters as needed. - await startDetector>( + await startScanner>( context: context, - scannerFunction: () => - ScanbotSdkUiV2.startTextPatternScanner(configuration), + scannerFunction: () => ScanbotSdk.textPattern.startScanner(configuration), handleResult: (context, result) async { - if (result.status == OperationStatus.OK) { - await Navigator.of(context).push( - MaterialPageRoute( + switch (result) { + case Ok(): + await Navigator.of(context).push( + MaterialPageRoute( builder: (context) => - TextPatternScannerUiResultPreview(result.data!)), - ); - } else { - await showAlertDialog( - context, "Operation Status: ${result.status.name}"); + TextPatternScannerUiResultPreview(result.value), + ), + ); + case Error(): + await showAlertDialog( + context, + title: "Error", + result.error.message, + ); + case Cancel(): + print("Operation was canceled"); } }, ); @@ -428,20 +372,26 @@ class DataCaptureUseCases extends StatelessWidget { configuration.topBar.cancelButton.text = 'Cancel'; // Configure parameters as needed. - await startDetector>( + await startScanner>( context: context, - scannerFunction: () => - ScanbotSdkUiV2.startCreditCardScanner(configuration), + scannerFunction: () => ScanbotSdk.creditCard.startScanner(configuration), handleResult: (context, result) async { - if (result.status == OperationStatus.OK) { - await Navigator.of(context).push( - MaterialPageRoute( + switch (result) { + case Ok(): + await Navigator.of(context).push( + MaterialPageRoute( builder: (context) => - CreditCardResultPreview(uiResult: result.data!)), - ); - } else { - await showAlertDialog( - context, "Operation Status: ${result.status.name}"); + CreditCardResultPreview(uiResult: result.value), + ), + ); + case Error(): + await showAlertDialog( + context, + title: "Error", + result.error.message, + ); + case Cancel(): + print("Operation was canceled"); } }, ); @@ -453,19 +403,26 @@ class DataCaptureUseCases extends StatelessWidget { configuration.introScreen.showAutomatically = true; // Configure parameters as needed. - await startDetector>( + await startScanner>( context: context, - scannerFunction: () => ScanbotSdkUiV2.startMrzScanner(configuration), + scannerFunction: () => ScanbotSdk.mrz.startScanner(configuration), handleResult: (context, result) async { - if (result.status == OperationStatus.OK) { - await Navigator.of(context).push( - MaterialPageRoute( + switch (result) { + case Ok(): + await Navigator.of(context).push( + MaterialPageRoute( builder: (context) => - MrzDocumentResultPreview(uiResult: result.data!)), - ); - } else { - await showAlertDialog( - context, "Operation Status: ${result.status.name}"); + MrzDocumentResultPreview(uiResult: result.value), + ), + ); + case Error(): + await showAlertDialog( + context, + title: "Error", + result.error.message, + ); + case Cancel(): + print("Operation was canceled"); } }, ); diff --git a/lib/document/document_sdk_menu.dart b/lib/document/document_sdk_menu.dart index 8a736f7..b8511aa 100644 --- a/lib/document/document_sdk_menu.dart +++ b/lib/document/document_sdk_menu.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:logging/logging.dart'; import 'package:scanbot_sdk/scanbot_sdk.dart'; import '../ui/menu_item_widget.dart'; @@ -17,35 +16,54 @@ class DocumentSdkMenu extends StatelessWidget { children: [ const DocumentUseCasesWidget(), const TitleItemWidget(title: 'Other API'), - MenuItemWidget(title: 'Analyze document quality ', onTap: () => _analyzeDocumentQuality(context)), - MenuItemWidget(title: 'PerformOCR ', onTap: () => _performOCR(context)), + MenuItemWidget( + title: 'Analyze document quality', + onTap: () => _analyzeDocumentQuality(context), + ), + MenuItemWidget( + title: 'Perform OCR', + onTap: () => _performOCR(context), + ), ], ), ); } Future _analyzeDocumentQuality(BuildContext context) async { - try { - final response = await selectImageFromLibrary(); - if (response?.path.isNotEmpty ?? false) { - var result = await ScanbotSdk.analyzeDocumentQuality(response!.path, DocumentQualityAnalyzerConfiguration()); - await showAlertDialog(context, title: 'Document Quality', result.quality?.name ?? 'Unknown'); - } - } catch (e) { - Logger.root.severe(e); + final file = await selectImageFromLibrary(); + if (file == null || file.path.isEmpty) return; + + var result = await ScanbotSdk.document.analyzeQualityOnImageFileUri( + file.path, + DocumentQualityAnalyzerConfiguration(), + ); + if (result is Ok) { + await showAlertDialog( + context, + title: 'Document Quality', + result.value.quality?.name ?? 'Unknown', + ); + } else { + print(result.toString()); } } Future _performOCR(BuildContext context) async { - try { - final response = await selectImageFromLibrary(); - if (response?.path.isNotEmpty ?? false) { - var result = await ScanbotSdk.performOCR(PerformOCRArguments(imageFileUris: [response!.path])); - await showAlertDialog(context, title: 'OCR Result', result.plainText); - } - } catch (e) { - Logger.root.severe(e); + final file = await selectImageFromLibrary(); + if (file == null || file.path.isEmpty) return; + + var result = await ScanbotSdk.ocrEngine.recognizeOnImageFileUris([ + file.path, + ]); + + if (result is Ok) { + await showAlertDialog( + context, + title: 'OCR Result', + result.value.recognizedText, + ); + } else { + print(result.toString()); } } } - diff --git a/lib/document/document_use_cases.dart b/lib/document/document_use_cases.dart index 979c3a6..9df7cd1 100644 --- a/lib/document/document_use_cases.dart +++ b/lib/document/document_use_cases.dart @@ -1,6 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:image_picker/image_picker.dart'; -import 'package:logging/logging.dart'; import 'package:scanbot_sdk_example_flutter/snippets/document_sdk/multi_page_scanning_snippet.dart'; import 'package:scanbot_sdk_example_flutter/snippets/document_sdk/single_page_scanning_finder_snippet.dart'; import 'package:scanbot_sdk_example_flutter/snippets/document_sdk/single_page_scanning_snippet.dart'; @@ -10,7 +8,6 @@ import '../ui/preview/document_preview.dart'; import '../utility/utils.dart'; import 'package:scanbot_sdk/scanbot_sdk.dart'; -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; class DocumentUseCasesWidget extends StatelessWidget { const DocumentUseCasesWidget({Key? key}) : super(key: key); @@ -20,35 +17,46 @@ class DocumentUseCasesWidget extends StatelessWidget { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const TitleItemWidget(title: 'Document Scanners (RTU v2.0)'), - MenuItemWidget(title: 'Single Page Scanning', onTap: () => _startSinglePageScanning(context)), - MenuItemWidget(title: 'Single Page Scanning with Finder', onTap: () => _startSinglePageWithFinderScanning(context)), - MenuItemWidget(title: 'Multi Page Scanning with Finder', onTap: () => _startMultiPageScanning(context)), - MenuItemWidget(title: 'Create Document from Image', onTap: () => _createDocumentFromImage(context)), - MenuItemWidget(title: 'Clean stored documents', onTap: () => _cleanStoredDocuments(context)), + const TitleItemWidget(title: 'Document Scanners (RTU UI)'), + MenuItemWidget( + title: 'Single Page Scanning', + onTap: () => _startSinglePageScanning(context), + ), + MenuItemWidget( + title: 'Single Page Scanning with Finder', + onTap: () => _startSinglePageWithFinderScanning(context), + ), + MenuItemWidget( + title: 'Multi Page Scanning with Finder', + onTap: () => _startMultiPageScanning(context), + ), + MenuItemWidget( + title: 'Create Document from Image', + onTap: () => _createDocumentFromImage(context), + ), + MenuItemWidget( + title: 'Clean stored documents', + onTap: () => _cleanStoredDocuments(context), + ), ], ); } Future startScan({ required BuildContext context, - required Future> Function() scannerFunction, + required Future> Function() scannerFunction, }) async { if (!await checkLicenseStatus(context)) { return; } - try { - var result = await scannerFunction(); - if (result.status == OperationStatus.OK && - result.data != null) { - await Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => DocumentPreview(result.data!), - ), - ); - } - } catch (e) { - print(e); + + var result = await scannerFunction(); + if (result is Ok) { + await Navigator.of(context).push( + MaterialPageRoute(builder: (context) => DocumentPreview(result.value)), + ); + } else { + print(result.toString()); } } @@ -56,7 +64,7 @@ class DocumentUseCasesWidget extends StatelessWidget { await startScan( context: context, scannerFunction: () => - ScanbotSdkUiV2.startDocumentScanner(singlePageScanningFlow()), + ScanbotSdk.document.startScanner(singlePageScanningFlow()), ); } @@ -64,7 +72,7 @@ class DocumentUseCasesWidget extends StatelessWidget { await startScan( context: context, scannerFunction: () => - ScanbotSdkUiV2.startDocumentScanner(singlePageWithFinderScanningFlow()), + ScanbotSdk.document.startScanner(singlePageWithFinderScanningFlow()), ); } @@ -72,37 +80,37 @@ class DocumentUseCasesWidget extends StatelessWidget { await startScan( context: context, scannerFunction: () => - ScanbotSdkUiV2.startDocumentScanner(multiPageScanningFlow()), + ScanbotSdk.document.startScanner(multiPageScanningFlow()), ); } Future _cleanStoredDocuments(BuildContext context) async { - try { - await ScanbotSdk.document.deleteAllDocuments(); - await showAlertDialog(context, "Operation status: Success"); - } catch (e) { - Logger.root.severe(e); - await showAlertDialog(context, "Operation status: Error\n${e.toString()}"); - } + await ScanbotSdk.document.deleteAllDocuments(); + await showAlertDialog(context, "Operation status: Success"); } Future _createDocumentFromImage(BuildContext context) async { - try { - if (!await checkLicenseStatus(context)) { - return; - } + if (!await checkLicenseStatus(context)) { + return; + } + + final file = await selectImageFromLibrary(); + if (file == null || file.path.isEmpty) return; - final response = await selectImageFromLibrary(); - if (response?.path.isNotEmpty ?? false) { - var result = await ScanbotSdk.document.createDocument(CreateDocumentParams(imageFileUris: [response!.path])); + await autorelease(() async { + var imageRef = ImageRef.fromPath(file.path); + var result = await ScanbotSdk.document.createDocumentFromImageRefs( + images: [imageRef], + ); + if (result is Ok) { await Navigator.of(context).push( MaterialPageRoute( - builder: (context) => DocumentPreview(result), + builder: (context) => DocumentPreview(result.value), ), ); + } else { + print(result.toString()); } - } catch (e) { - Logger.root.severe(e); - } + }); } } diff --git a/lib/main.dart b/lib/main.dart index 1d995d9..06ea4bf 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,17 +1,14 @@ import 'dart:async'; import 'dart:convert'; -import 'dart:io'; import 'package:flutter/material.dart'; -import 'package:logging/logging.dart'; import 'package:path_provider/path_provider.dart'; +import 'package:scanbot_sdk_example_flutter/classic_components/document_custom_ui.dart'; -import 'storage/_legacy_pages_repository.dart'; import 'ui/menu_item_widget.dart'; import 'utility/utils.dart'; import 'data_capture/data_capture_sdk_menu.dart'; import 'document/document_sdk_menu.dart'; -import 'classic_components/custom_ui_menu.dart'; import 'package:scanbot_sdk/scanbot_sdk.dart'; @@ -26,61 +23,28 @@ void main() => runApp(MyApp()); const SCANBOT_SDK_LICENSE_KEY = ""; Future _initScanbotSdk() async { - // Consider adjusting this optional storageBaseDirectory - see the comments below. - final customStorageBaseDirectory = await getDemoStorageBaseDirectory(); - - var config = ScanbotSdkConfig( - loggingEnabled: true, - // Consider switching logging OFF in production. builds for security and performance reasons. - licenseKey: SCANBOT_SDK_LICENSE_KEY, - storageImageFormat: ImageFormat.JPG, - storageImageQuality: 80, - // Uncomment to use custom storage directory - // storageBaseDirectory: customStorageBaseDirectory, + var config = SdkConfiguration( + loggingEnabled: true, + // Consider disabling logging in production builds for security and performance reasons + licenseKey: SCANBOT_SDK_LICENSE_KEY, + // Uncomment to use the custom storage directory + // storageBaseDirectory: await getDemoStorageBaseDirectory(), ); - if(shouldInitWithEncryption) { + if (shouldInitWithEncryption) { config.fileEncryptionPassword = 'SomeSecretPa\$\$w0rdForFileEncryption'; config.fileEncryptionMode = FileEncryptionMode.AES256; } - try { - await ScanbotSdk.initScanbotSdk(config); - await LegacyPageRepository().loadPages(); - } catch (e) { - Logger.root.severe(e); - } + await ScanbotSdk.initialize(config); } Future getDemoStorageBaseDirectory() async { // !! Please note !! // It is strongly recommended to use the default (secure) storage location of the Scanbot SDK. - // However, for demo purposes we overwrite the "storageBaseDirectory" of the Scanbot SDK by a custom storage directory. - // - // On Android we use the "ExternalStorageDirectory" which is a public(!) folder. - // All image files and export files (PDF, TIFF, etc) created by the Scanbot SDK in this demo app will be stored - // in this public storage directory and will be accessible for every(!) app having external storage permissions! - // Again, this is only for demo purposes, which allows us to easily fetch and check the generated files - // via Android "adb" CLI tools, Android File Transfer app, Android Studio, etc. - // - // On iOS we use the "ApplicationDocumentsDirectory" which is accessible via iTunes file sharing. - // - // For more details about the storage system of the Scanbot SDK Flutter Plugin please see our docs: - // - https://scanbotsdk.github.io/documentation/flutter/ - // - // For more details about the file system on Android and iOS we also recommend to check out: - // - https://developer.android.com/guide/topics/data/data-storage - // - https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html - - Directory storageDirectory; - if (Platform.isAndroid) { - storageDirectory = (await getExternalStorageDirectory())!; - } else if (Platform.isIOS) { - storageDirectory = await getApplicationDocumentsDirectory(); - } else { - throw ('Unsupported platform'); - } + // However, for demo purposes we overwrite the "storageBaseDirectory" of the Scanbot SDK with a custom storage directory. + var storageDirectory = await getApplicationSupportDirectory(); return '${storageDirectory.path}/my-custom-storage'; } @@ -93,11 +57,6 @@ class MyApp extends StatefulWidget { } class _MyAppState extends State { - @override - void initState() { - super.initState(); - } - @override Widget build(BuildContext context) { return MaterialApp( @@ -122,11 +81,13 @@ class _MainPageWidgetState extends State { const TitleItemWidget(title: 'Document SDK API'), MenuItemWidget( title: 'Document SDK Menu', - startIcon: Icons.photo_camera, + startIcon: Icons.document_scanner, endIcon: Icons.arrow_forward, onTap: () { Navigator.of(context).push( - MaterialPageRoute(builder: (context) => const DocumentSdkMenu()), + MaterialPageRoute( + builder: (context) => const DocumentSdkMenu(), + ), ); }, ), @@ -136,30 +97,34 @@ class _MainPageWidgetState extends State { endIcon: Icons.arrow_forward, onTap: () { Navigator.of(context).push( - MaterialPageRoute(builder: (context) => const DataCaptureSdkMenu()), + MaterialPageRoute( + builder: (context) => const DataCaptureSdkMenu(), + ), ); }, ), MenuItemWidget( - title: 'Custom UI Menu', + title: 'Custom UI', startIcon: Icons.edit, endIcon: Icons.arrow_forward, onTap: () { Navigator.of(context).push( - MaterialPageRoute(builder: (context) => CustomUiMenu()), + MaterialPageRoute( + builder: (context) => const DocumentScannerWidget(), + ), ); }, ), const TitleItemWidget(title: 'Other SDK API'), MenuItemWidget( - title: 'getLicenseStatus()', + title: 'License Info', startIcon: Icons.phonelink_lock, onTap: () { _getLicenseStatus(); }, ), MenuItemWidget( - title: 'getOcrConfigs()', + title: 'Ocr Configs', startIcon: Icons.settings, onTap: () { _getOcrConfigs(); @@ -177,32 +142,32 @@ class _MainPageWidgetState extends State { ), ], ), - bottomNavigationBar: buildBottomNavigationBar(context) + bottomNavigationBar: buildBottomNavigationBar(context), ); } Future _getOcrConfigs() async { - try { - final result = await ScanbotSdk.getOcrConfigs(); - await showAlertDialog(context, jsonEncode(result), title: 'OCR Configs'); - } catch (e) { - Logger.root.severe(e); - await showAlertDialog(context, 'Error getting OCR configs'); + final result = await ScanbotSdk.getOcrConfigs(); + if (result is Ok) { + await showAlertDialog( + context, + jsonEncode(result.value), + title: 'OCR Configs', + ); + } else { + print(result.toString()); } } Future _getLicenseStatus() async { - try { - final result = await ScanbotSdk.getLicenseStatus(); - var status = " Status: ${result.licenseStatus.name}"; - - if (result.licenseExpirationDate != null) { - status += "\n ExpirationDate: ${result.licenseExpirationDate}"; - } - - await showAlertDialog(context, status, title: 'License Status'); - } catch (e) { - await showAlertDialog(context, "Error getting license status", title: "Info"); + final result = await ScanbotSdk.getLicenseInfo(); + if (result is Ok) { + var licenseInfo = "Status: ${result.value.licenseStatusMessage}\n" + "Expiration Date: ${result.value.expirationDateString}"; + + await showAlertDialog(context, licenseInfo, title: 'License Status'); + } else { + print(result.toString()); } } } diff --git a/lib/snippets/analytics.dart b/lib/snippets/analytics.dart index edbd93b..5cac9eb 100644 --- a/lib/snippets/analytics.dart +++ b/lib/snippets/analytics.dart @@ -10,4 +10,4 @@ Future analytics() async { ScanbotSdk.setAnalyticsSubscriber((analyticsEvent) { Logger.root.log(Level.INFO, analyticsEvent.name); }); -} \ No newline at end of file +} diff --git a/lib/snippets/classic_components/cropping_widget.dart b/lib/snippets/classic_components/cropping_widget.dart new file mode 100644 index 0000000..ebb56f3 --- /dev/null +++ b/lib/snippets/classic_components/cropping_widget.dart @@ -0,0 +1,22 @@ +import 'package:flutter/material.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; + +CroppingController? croppingController; + +ScanbotCroppingWidget buildCroppingWidget(ImageRef documentImage) { + return ScanbotCroppingWidget( + documentImage: + documentImage, // `ImageRef` document image object to be cropped + onViewReady: (controller) { + // Callback when the cropping view is ready + croppingController = controller; + }, + onHeavyOperationProcessing: (isProcessing) { + // Callback for handling long processing operations + }, + edgeColor: Colors.red, // Color of the cropping edges + edgeColorOnLine: Colors.blue, // Color when edges are on the line + anchorPointsColor: Colors.amberAccent, // Color of anchor points + borderInsets: Insets.all(16), // Insets for the cropping borders + ); +} diff --git a/lib/snippets/classic_components/document_scanner_camera.dart b/lib/snippets/classic_components/document_scanner_camera.dart new file mode 100644 index 0000000..0951f2c --- /dev/null +++ b/lib/snippets/classic_components/document_scanner_camera.dart @@ -0,0 +1,52 @@ +import 'package:flutter/material.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; + +DocumentScannerCamera buildDocumentScannerCamera() { + return DocumentScannerCamera( + configuration: DocumentCameraConfiguration( + flashEnabled: true, // Manages the initial flash state + scannerConfiguration: DocumentClassicScannerConfiguration( + autoSnapEnabled: true, // Enable or disable auto-snap + detectDocumentAfterSnap: true, // Detect document after snapping + autoSnapSensitivity: 0.5, // Sensitivity for auto-snap + ), + contourConfiguration: ContourConfiguration( + showPolygonInManualMode: false, // Hide contour polygon in manual mode + strokeOkColor: + Colors.red, // Color for contour strokes when detection is OK + fillOkColor: Colors.red + .withAlpha(150), // Fill color for contours when detection is OK + strokeColor: Colors + .blue, // Color for contour strokes when detection is in progress + fillColor: Colors.blue.withAlpha( + 150), // Fill color for contours when detection is in progress + cornerRadius: 35, // Radius for contour corners + strokeWidth: 10, // Width of contour strokes + autoSnapProgressStrokeColor: + Colors.greenAccent, // Color for auto-snap progress + autoSnapProgressEnabled: true, // Enable auto-snap progress indicator + autoSnapProgressStrokeWidth: + 5, // Width of the auto-snap progress stroke + ), + ), + onSnappedDocumentResult: ( + ImageRef originalImage, + ImageRef? documentImage, + DocumentDetectionResult? detectionResult, + ) async { + // Handle the original image and, if detectDocumentAfterSnap is enabled, the cropped image of the detected document along with the document detection result. + }, + onError: (error) { + // Handle errors such as licensing issues or camera errors + }, + onFrameDetectionResult: (result) { + // Handle document detection results + }, + onCameraPreviewStarted: (isFlashAvailable) { + // Perform any setup after the camera preview starts + }, + onHeavyOperationProcessing: (show) { + // Display a progress bar or loading indicator during long operations + }, + ); +} diff --git a/lib/snippets/data_capture_sdk/image_recognizers/recognize_check_on_image.dart b/lib/snippets/data_capture_sdk/image_recognizers/recognize_check_on_image.dart index 4a39f2b..c20335d 100644 --- a/lib/snippets/data_capture_sdk/image_recognizers/recognize_check_on_image.dart +++ b/lib/snippets/data_capture_sdk/image_recognizers/recognize_check_on_image.dart @@ -2,15 +2,22 @@ import 'package:scanbot_sdk/scanbot_sdk.dart'; Future recognizeCheckOnImage(String uriPath) async { var configuration = CheckScannerConfiguration(); - configuration.documentDetectionMode = CheckDocumentDetectionMode.DETECT_DOCUMENT; + configuration.documentDetectionMode = + CheckDocumentDetectionMode.DETECT_DOCUMENT; // Configure other parameters as needed. - CheckScanningResult result = await ScanbotSdk.recognizeOperations.recognizeCheckOnImage(uriPath, configuration); - if (result.status == CheckMagneticInkStripScanningStatus.SUCCESS) { - // ... + var result = await ScanbotSdk.check.scanFromImageFileUri( + uriPath, + configuration, + ); + if (result is Ok && + result.value.status == CheckMagneticInkStripScanningStatus.SUCCESS) { + /** Handle the result **/ + } else { + print(result.toString()); } } String formatCheckResult(CheckScanningResult result) { - return "CheckType FullName: ${result.check?.type.fullName}"; -} \ No newline at end of file + return "CheckType FullName: ${result.check?.type.fullName}"; +} diff --git a/lib/snippets/data_capture_sdk/image_recognizers/recognize_credit_card_on_image.dart b/lib/snippets/data_capture_sdk/image_recognizers/recognize_credit_card_on_image.dart index 6f079f0..5a07775 100644 --- a/lib/snippets/data_capture_sdk/image_recognizers/recognize_credit_card_on_image.dart +++ b/lib/snippets/data_capture_sdk/image_recognizers/recognize_credit_card_on_image.dart @@ -5,12 +5,18 @@ Future recognizeCreditCardOnImage(String uriPath) async { configuration.requireCardholderName = true; // Configure other parameters as needed. - CreditCardScanningResult result = await ScanbotSdk.recognizeOperations.recognizeCreditCardOnImage(uriPath, configuration); - if (result.scanningStatus == CreditCardScanningStatus.SUCCESS) { - // ... + var result = await ScanbotSdk.creditCard.scanFromImageFileUri( + uriPath, + configuration, + ); + if (result is Ok && + result.value.scanningStatus == CreditCardScanningStatus.SUCCESS) { + /** Handle the result **/ + } else { + print(result.toString()); } } String formatCheckResult(CreditCardScanningResult result) { return "CreditCard Type: ${result.creditCard?.type.fullName}"; -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/image_recognizers/recognize_document_data_on_image.dart b/lib/snippets/data_capture_sdk/image_recognizers/recognize_document_data_on_image.dart index 76d7085..cbee6f0 100644 --- a/lib/snippets/data_capture_sdk/image_recognizers/recognize_document_data_on_image.dart +++ b/lib/snippets/data_capture_sdk/image_recognizers/recognize_document_data_on_image.dart @@ -1,7 +1,8 @@ import 'package:scanbot_sdk/scanbot_sdk.dart'; Future extractDocumentData(String uriPath) async { - var commonConfig = DocumentDataExtractorCommonConfiguration(acceptedDocumentTypes: [ + var commonConfig = DocumentDataExtractorCommonConfiguration( + acceptedDocumentTypes: [ DeIdCardFront.DOCUMENT_TYPE, DeIdCardBack.DOCUMENT_TYPE, DeHealthInsuranceCardFront.DOCUMENT_TYPE, @@ -11,19 +12,26 @@ Future extractDocumentData(String uriPath) async { EuropeanHealthInsuranceCard.DOCUMENT_TYPE, EuropeanDriverLicenseFront.DOCUMENT_TYPE, EuropeanDriverLicenseBack.DOCUMENT_TYPE, - ]); + ], + ); - var configuration = DocumentDataExtractorConfiguration( - configurations: [commonConfig], - ); - // Configure other parameters as needed. + var configuration = DocumentDataExtractorConfiguration( + configurations: [commonConfig], + ); + // Configure other parameters as needed. - DocumentDataExtractionResult result = await ScanbotSdk.recognizeOperations.extractDocumentDataFromImage(uriPath, configuration); - if (result.status == DocumentDataExtractionStatus.SUCCESS) { - // ... + var result = await ScanbotSdk.documentDataExtractor.extractFromImageFileUri( + uriPath, + configuration, + ); + if (result is Ok && + result.value.status == DocumentDataExtractionStatus.OK) { + /** Handle the result **/ + } else { + print(result.toString()); } } String formatGenericDocumentResult(DocumentDataExtractionResult result) { - return "DocumentType: ${result.document?.type.fullName}"; -} \ No newline at end of file + return "DocumentType: ${result.document?.type.fullName}"; +} diff --git a/lib/snippets/data_capture_sdk/image_recognizers/recognize_ehic_on_image.dart b/lib/snippets/data_capture_sdk/image_recognizers/recognize_ehic_on_image.dart deleted file mode 100644 index e53f5c2..0000000 --- a/lib/snippets/data_capture_sdk/image_recognizers/recognize_ehic_on_image.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:scanbot_sdk/scanbot_sdk.dart'; - -Future _recognizeEhicOnImage(String uriPath) async { - var configuration = EuropeanHealthInsuranceCardRecognizerConfiguration(); - configuration.maxExpirationYear = 2100; - // Configure other parameters as needed. - - EuropeanHealthInsuranceCardRecognitionResult result = await ScanbotSdk.recognizeOperations.recognizeHealthInsuranceCardOnImage(uriPath, configuration); - if (result.status == EuropeanHealthInsuranceCardRecognitionResultRecognitionStatus.SUCCESS) { - // ... - } -} -String formatHealthInsuranceCardResult(EuropeanHealthInsuranceCardRecognitionResult result) { - return ''' -EHIC first field: ${result.fields.first.type} -Value: ${result.fields.first.value}" -'''; -} \ No newline at end of file diff --git a/lib/snippets/data_capture_sdk/image_recognizers/recognize_medical_certificate_on_image.dart b/lib/snippets/data_capture_sdk/image_recognizers/recognize_medical_certificate_on_image.dart deleted file mode 100644 index ddba6bf..0000000 --- a/lib/snippets/data_capture_sdk/image_recognizers/recognize_medical_certificate_on_image.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:scanbot_sdk/scanbot_sdk.dart'; - -Future recognizeMedicalDocumentOnImage(String uriPath) async { - var configuration = MedicalCertificateScanningParameters(); - configuration.recognizePatientInfoBox = true; - // Configure other parameters as needed. - - MedicalCertificateScanningResult result = await ScanbotSdk.recognizeOperations.recognizeMedicalCertificateOnImage(uriPath, configuration); - if (result.scanningSuccessful) { - // ... - } -} - -String formatMedicalCertificateResult(MedicalCertificateScanningResult result) { - return ''' -mcFormType: ${result.formType.name} -'''; -} \ No newline at end of file diff --git a/lib/snippets/data_capture_sdk/image_recognizers/recognize_mrz_on_image.dart b/lib/snippets/data_capture_sdk/image_recognizers/recognize_mrz_on_image.dart index b335ce0..b894fb4 100644 --- a/lib/snippets/data_capture_sdk/image_recognizers/recognize_mrz_on_image.dart +++ b/lib/snippets/data_capture_sdk/image_recognizers/recognize_mrz_on_image.dart @@ -1,20 +1,24 @@ import 'package:scanbot_sdk/scanbot_sdk.dart'; -Future _recognizeMrzDocumentOnImage(String uriPath) async { - var configuration = MrzScannerConfiguration(); +Future recognizeMrzDocumentOnImage(String uriPath) async { + var configuration = MrzScannerConfiguration(); configuration.incompleteResultHandling = MrzIncompleteResultHandling.REJECT; // Configure other parameters as needed. - var result = await ScanbotSdk.recognizeOperations.recognizeMrzOnImage(uriPath, configuration); - if (result.success) { - // ... + var result = await ScanbotSdk.mrz.scanFromImageFileUri( + uriPath, + configuration, + ); + if (result is Ok && result.value.success) { + /** Handle the result **/ + } else { + print(result.toString()); } } String formatMrzResult(MrzScannerResult result) { - return ''' + return ''' Document: ${result.document?.type.name} rawMrz: ${result.rawMRZ} '''; - -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtu_data_detectors/rtu_check_scanner.dart b/lib/snippets/data_capture_sdk/rtu_data_detectors/rtu_check_scanner.dart index cc9058b..2f11c6d 100644 --- a/lib/snippets/data_capture_sdk/rtu_data_detectors/rtu_check_scanner.dart +++ b/lib/snippets/data_capture_sdk/rtu_data_detectors/rtu_check_scanner.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; import 'package:scanbot_sdk_example_flutter/ui/preview/check_preview.dart'; import '../../../utility/utils.dart'; @@ -20,36 +20,37 @@ class RtuCheckScannerFeature extends StatelessWidget { final isLicenseValid = await checkLicenseStatus(context); if (!isLicenseValid) return; - try { - var config = CheckScannerScreenConfiguration(); - // Configure the strings. - config.localization.topUserGuidance = 'Localized topUserGuidance'; - config.localization.cameraPermissionCloseButton = 'Localized cameraPermissionCloseButton'; - config.localization.completionOverlaySuccessMessage = 'Localized completionOverlaySuccessMessage'; - config.localization.introScreenText = 'Localized introScreenText'; - // Configure other parameters as needed. - - // An autorelease pool is required only because the result object contains image references. - await autorelease(() async { - var result = await ScanbotSdkUiV2.startCheckScanner(config); - - if (result.status == OperationStatus.OK && result.data?.check != null) { - - /// if you want to use image later, call encodeImages() to save in buffer + var config = CheckScannerScreenConfiguration(); + // Configure the strings. + config.localization.topUserGuidance = 'Localized topUserGuidance'; + config.localization.cameraPermissionCloseButton = + 'Localized cameraPermissionCloseButton'; + config.localization.completionOverlaySuccessMessage = + 'Localized completionOverlaySuccessMessage'; + config.localization.introScreenText = 'Localized introScreenText'; + // Configure other parameters as needed. + + // An autorelease pool is required only because the result object contains image references. + await autorelease(() async { + var result = await ScanbotSdk.check.startScanner(config); + switch (result) { + case Ok(): + + /// if the image needs to be used later, call encodeImages() to save in buffer // result.data?.encodeImages(); await Navigator.push( context, MaterialPageRoute( - builder: (_) => CheckDocumentResultPreview( - uiResult: result.data, - ), + builder: (_) => + CheckDocumentResultPreview(uiResult: result.value), ), ); - } - }); - } catch (e) { - showAlertDialog(context, 'Error: ${e.toString()}'); - } + case Error(): + await showAlertDialog(context, title: "Error", result.error.message); + case Cancel(): + print("Operation was canceled"); + } + }); } } diff --git a/lib/snippets/data_capture_sdk/rtu_data_detectors/rtu_credit_card_scanner.dart b/lib/snippets/data_capture_sdk/rtu_data_detectors/rtu_credit_card_scanner.dart index e5e69b0..0870f8f 100644 --- a/lib/snippets/data_capture_sdk/rtu_data_detectors/rtu_credit_card_scanner.dart +++ b/lib/snippets/data_capture_sdk/rtu_data_detectors/rtu_credit_card_scanner.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; import 'package:scanbot_sdk_example_flutter/ui/preview/credit_card_preview.dart'; import '../../../utility/utils.dart'; @@ -20,38 +20,36 @@ class RtuCreditCardScannerFeature extends StatelessWidget { final isLicenseValid = await checkLicenseStatus(context); if (!isLicenseValid) return; - try { - var config = CreditCardScannerScreenConfiguration(); - // Configure the top bar mode - config.topBar.mode = TopBarMode.GRADIENT; - // Configure the top bar status bar mode - config.topBar.statusBarMode = StatusBarMode.LIGHT; - // Configure the top bar background color - config.topBar.cancelButton.text = 'Cancel'; - // Configure parameters as needed. + var config = CreditCardScannerScreenConfiguration(); + // Configure the top bar mode + config.topBar.mode = TopBarMode.GRADIENT; + // Configure the top bar status bar mode + config.topBar.statusBarMode = StatusBarMode.LIGHT; + // Configure the top bar background color + config.topBar.cancelButton.text = 'Cancel'; + // Configure parameters as needed. - // An autorelease pool is required only because the result object contains image references. - await autorelease(() async { - var result = await ScanbotSdkUiV2.startCreditCardScanner(config); + // An autorelease pool is required only because the result object contains image references. + await autorelease(() async { + var result = await ScanbotSdk.creditCard.startScanner(config); - if (result.status == OperationStatus.OK && result.data?.creditCard != null) { + switch (result) { + case Ok(): - /// if you want to use image later, call encodeImages() to save in buffer + /// if the image needs to be used later, call encodeImages() to save in buffer // result.data?.encodeImages(); await Navigator.push( context, MaterialPageRoute( - builder: (_) => CreditCardResultPreview( - uiResult: result.data, - ), - + builder: (_) => CreditCardResultPreview(uiResult: result.value), ), ); - } - }); - } catch (e) { - showAlertDialog(context, 'Error: ${e.toString()}'); - } + case Error(): + await showAlertDialog(context, title: "Error", result.error.message); + case Cancel(): + print("Operation was canceled"); + } + }); } } diff --git a/lib/snippets/data_capture_sdk/rtu_data_detectors/rtu_document_data_extractor.dart b/lib/snippets/data_capture_sdk/rtu_data_detectors/rtu_document_data_extractor.dart index b87c1df..5410c92 100644 --- a/lib/snippets/data_capture_sdk/rtu_data_detectors/rtu_document_data_extractor.dart +++ b/lib/snippets/data_capture_sdk/rtu_data_detectors/rtu_document_data_extractor.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; import '../../../ui/preview/extracted_document_data_preview.dart'; import '../../../utility/utils.dart'; @@ -20,32 +20,33 @@ class RtuDocumentDataExtractorFeature extends StatelessWidget { final isLicenseValid = await checkLicenseStatus(context); if (!isLicenseValid) return; - try { - var config = DocumentDataExtractorScreenConfiguration(); - config.viewFinder.overlayColor = ScanbotColor('#C8193C'); - // Configure other parameters as needed. + var config = DocumentDataExtractorScreenConfiguration(); + config.viewFinder.overlayColor = ScanbotColor('#C8193C'); + // Configure other parameters as needed. - // An autorelease pool is required only because the result object contains image references. - await autorelease(() async { - var result = await ScanbotSdkUiV2.startDocumentDataExtractor(config); + // An autorelease pool is required only because the result object contains image references. + await autorelease(() async { + var result = await ScanbotSdk.documentDataExtractor.startExtractorScreen( + config, + ); + switch (result) { + case Ok(): - if (result.status == OperationStatus.OK && result.data?.document != null) { - - /// if you want to use image later, call encodeImages() to save in buffer + /// if the image needs to be used later, call encodeImages() to save in buffer // result.data?.encodeImages(); await Navigator.push( context, MaterialPageRoute( - builder: (_) => ExtractedDocumentDataPreview( - uiResult: result.data, - ), + builder: (_) => + ExtractedDocumentDataPreview(uiResult: result.value), ), ); - } - }); - } catch (e) { - showAlertDialog(context, 'Error: ${e.toString()}'); - } + case Error(): + await showAlertDialog(context, title: "Error", result.error.message); + case Cancel(): + print("Operation was canceled"); + } + }); } } diff --git a/lib/snippets/data_capture_sdk/rtu_data_detectors/rtu_mrz_scanner.dart b/lib/snippets/data_capture_sdk/rtu_data_detectors/rtu_mrz_scanner.dart index 8c049b9..477dbb8 100644 --- a/lib/snippets/data_capture_sdk/rtu_data_detectors/rtu_mrz_scanner.dart +++ b/lib/snippets/data_capture_sdk/rtu_data_detectors/rtu_mrz_scanner.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; import '../../../ui/preview/mrz_document_preview.dart'; import '../../../utility/utils.dart'; @@ -20,45 +20,45 @@ class RtuMrzScannerFeature extends StatelessWidget { final isLicenseValid = await checkLicenseStatus(context); if (!isLicenseValid) return; - try { - var config = MrzScannerScreenConfiguration(); + var config = MrzScannerScreenConfiguration(); - // Set colors - config.palette.sbColorPrimary = ScanbotColor('#C8193C'); - config.palette.sbColorOnPrimary = ScanbotColor('#ffffff'); + // Set colors + config.palette.sbColorPrimary = ScanbotColor('#C8193C'); + config.palette.sbColorOnPrimary = ScanbotColor('#ffffff'); - // Add a top guidance title - config.topUserGuidance.title = StyledText( - text: 'Scan MRZ', - color: ScanbotColor('#C8193C'), - useShadow: true, - ); + // Add a top guidance title + config.topUserGuidance.title = StyledText( + text: 'Scan MRZ', + color: ScanbotColor('#C8193C'), + useShadow: true, + ); - // Modify the action bar - config.actionBar.flipCameraButton.visible = false; - config.actionBar.flashButton.activeForegroundColor = - ScanbotColor('#C8193C'); + // Modify the action bar + config.actionBar.flipCameraButton.visible = false; + config.actionBar.flashButton.activeForegroundColor = ScanbotColor( + '#C8193C', + ); - // Configure the scanner - config.scannerConfiguration.incompleteResultHandling = - MrzIncompleteResultHandling.ACCEPT; + // Configure the scanner + config.scannerConfiguration.incompleteResultHandling = + MrzIncompleteResultHandling.ACCEPT; - // Configure other parameters as needed. - final result = await ScanbotSdkUiV2.startMrzScanner(config); + // Configure other parameters as needed. + final result = await ScanbotSdk.mrz.startScanner(config); + switch (result) { + case Ok(): - if (result.status == OperationStatus.OK && result.data?.mrzDocument != null) { // Always serialize the MRZ document before stringifying, and use the serialized result. await Navigator.push( context, MaterialPageRoute( - builder: (_) => MrzDocumentResultPreview( - uiResult: result.data, - ), + builder: (_) => MrzDocumentResultPreview(uiResult: result.value), ), ); - } - } catch (e) { - showAlertDialog(context, 'Error: ${e.toString()}'); + case Error(): + await showAlertDialog(context, title: "Error", result.error.message); + case Cancel(): + print("Operation was canceled"); } } } diff --git a/lib/snippets/data_capture_sdk/rtu_data_detectors/rtu_text_pattern_scanner.dart b/lib/snippets/data_capture_sdk/rtu_data_detectors/rtu_text_pattern_scanner.dart index 4e34bcc..19a7d0a 100644 --- a/lib/snippets/data_capture_sdk/rtu_data_detectors/rtu_text_pattern_scanner.dart +++ b/lib/snippets/data_capture_sdk/rtu_data_detectors/rtu_text_pattern_scanner.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; import '../../../ui/preview/text_pattern_preview.dart'; import '../../../utility/utils.dart'; @@ -20,26 +20,26 @@ class RtuTextPatternScannerFeature extends StatelessWidget { final isLicenseValid = await checkLicenseStatus(context); if (!isLicenseValid) return; - try { - var config = TextPatternScannerScreenConfiguration(); - // Show the top user guidance - config.topUserGuidance.visible = true; - // Customize the top user guidance - config.topUserGuidance.title.text = 'Customized title'; - // Configure parameters as needed. + var config = TextPatternScannerScreenConfiguration(); + // Show the top user guidance + config.topUserGuidance.visible = true; + // Customize the top user guidance + config.topUserGuidance.title.text = 'Customized title'; + // Configure parameters as needed. - var result = await ScanbotSdkUiV2.startTextPatternScanner(config); - - if (result.status == OperationStatus.OK && result.data != null) { + var result = await ScanbotSdk.textPattern.startScanner(config); + switch (result) { + case Ok(): await Navigator.push( context, MaterialPageRoute( - builder: (_) => TextPatternScannerUiResultPreview(result.data!), + builder: (_) => TextPatternScannerUiResultPreview(result.value), ), ); - } - } catch (e) { - showAlertDialog(context, 'Error: ${e.toString()}'); + case Error(): + await showAlertDialog(context, title: "Error", result.error.message); + case Cancel(): + print("Operation was canceled"); } } } diff --git a/lib/snippets/data_capture_sdk/rtu_data_detectors/rtu_vin_scanner.dart b/lib/snippets/data_capture_sdk/rtu_data_detectors/rtu_vin_scanner.dart index ec14cba..4c3fbf9 100644 --- a/lib/snippets/data_capture_sdk/rtu_data_detectors/rtu_vin_scanner.dart +++ b/lib/snippets/data_capture_sdk/rtu_data_detectors/rtu_vin_scanner.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; import '../../../ui/preview/vin_preview.dart'; import '../../../utility/utils.dart'; @@ -20,31 +20,31 @@ class RtuVinScannerFeature extends StatelessWidget { final isLicenseValid = await checkLicenseStatus(context); if (!isLicenseValid) return; - try { - var config = VinScannerScreenConfiguration(); - config.introScreen.explanation.text = - 'Quickly and securely scan the VIN by holding your device over the vehicle identification number or vehicle identification barcode' + - '\\nThe scanner will guide you to the optimal scanning position.' + - 'Once the scan is complete, your VIN details will automatically be extracted and processed.'; - // Configure the done button. E.g., the text or the background color. - config.introScreen.doneButton.text = 'Start Scanning'; - config.introScreen.doneButton.background.fillColor = ScanbotColor('#C8193C'); - // Configure other parameters as needed. - - var result = await ScanbotSdkUiV2.startVINScanner(config); + var config = VinScannerScreenConfiguration(); + config.introScreen.explanation.text = + 'Quickly and securely scan the VIN by holding your device over the vehicle identification number or vehicle identification barcode' + '\\nThe scanner will guide you to the optimal scanning position.' + 'Once the scan is complete, your VIN details will automatically be extracted and processed.'; + // Configure the done button. E.g., the text or the background color. + config.introScreen.doneButton.text = 'Start Scanning'; + config.introScreen.doneButton.background.fillColor = ScanbotColor( + '#C8193C', + ); + // Configure other parameters as needed. - if (result.status == OperationStatus.OK && result.data != null) { + var result = await ScanbotSdk.vin.startScanner(config); + switch (result) { + case Ok(): await Navigator.push( context, MaterialPageRoute( - builder: (_) => VinScannerResultPreview( - uiResult: result.data, - ), + builder: (_) => VinScannerResultPreview(uiResult: result.value), ), ); - } - } catch (e) { - showAlertDialog(context, 'Error: ${e.toString()}'); + case Error(): + await showAlertDialog(context, title: "Error", result.error.message); + case Cancel(): + print("Operation was canceled"); } } } diff --git a/lib/snippets/data_capture_sdk/rtuui_check/action_bar.dart b/lib/snippets/data_capture_sdk/rtuui_check/action_bar.dart index 0341774..0c1f03d 100644 --- a/lib/snippets/data_capture_sdk/rtuui_check/action_bar.dart +++ b/lib/snippets/data_capture_sdk/rtuui_check/action_bar.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { // Create an instance of the default configuration @@ -14,8 +14,13 @@ Future startScanning() async { // Hide the flip camera button configuration.actionBar.flipCameraButton.visible = false; // Start the Check Scanner - var result = await ScanbotSdkUiV2.startCheckScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.check.startScanner(configuration); + + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_check/finder_overlay.dart b/lib/snippets/data_capture_sdk/rtuui_check/finder_overlay.dart index b23074a..431d22d 100644 --- a/lib/snippets/data_capture_sdk/rtuui_check/finder_overlay.dart +++ b/lib/snippets/data_capture_sdk/rtuui_check/finder_overlay.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { // Create an instance of the default configuration @@ -6,18 +6,19 @@ Future startScanning() async { // Set the overlay color configuration.viewFinder.overlayColor = ScanbotColor('#C8193C'); // Configure the aspect ratio of the view finder - configuration.viewFinder.aspectRatio = AspectRatio( - width: 8, - height: 6, - ); + configuration.viewFinder.aspectRatio = AspectRatio(width: 8, height: 6); // Configure the view finder style configuration.viewFinder.style = FinderCorneredStyle( cornerRadius: 8, strokeWidth: 2, ); // Start the Check Scanner - var result = await ScanbotSdkUiV2.startCheckScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.check.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_check/introduction_screen.dart b/lib/snippets/data_capture_sdk/rtuui_check/introduction_screen.dart index 90cf389..a03bc17 100644 --- a/lib/snippets/data_capture_sdk/rtuui_check/introduction_screen.dart +++ b/lib/snippets/data_capture_sdk/rtuui_check/introduction_screen.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { // Create an instance of the default configuration @@ -11,21 +11,25 @@ Future startScanning() async { text: 'Check Scanner', ); // Configure the image for the introduction screen. - configuration.introScreen.image = CheckIntroCustomImage( - uri: 'imageUri', - ); + configuration.introScreen.image = CheckIntroCustomImage(uri: 'imageUri'); // Configure the text. configuration.introScreen.explanation.color = ScanbotColor('#000000'); configuration.introScreen.explanation.text = - 'Quickly and securely scan your checks by holding your device over the check' + - '\\nThe scanner will guide you to the optimal scanning position.' + - 'Once the scan is complete, your check details will automatically be extracted and processed.'; + 'Quickly and securely scan your checks by holding your device over the check' + '\\nThe scanner will guide you to the optimal scanning position.' + 'Once the scan is complete, your check details will automatically be extracted and processed.'; // Configure the done button. E.g., the text or the background color. configuration.introScreen.doneButton.text = 'Start Scanning'; - configuration.introScreen.doneButton.background.fillColor = ScanbotColor('#C8193C'); + configuration.introScreen.doneButton.background.fillColor = ScanbotColor( + '#C8193C', + ); // Start the Check Scanner UI - var result = await ScanbotSdkUiV2.startCheckScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.check.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_check/launching_the_scanner.dart b/lib/snippets/data_capture_sdk/rtuui_check/launching_the_scanner.dart index ecc386b..8207f70 100644 --- a/lib/snippets/data_capture_sdk/rtuui_check/launching_the_scanner.dart +++ b/lib/snippets/data_capture_sdk/rtuui_check/launching_the_scanner.dart @@ -1,11 +1,15 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { // Create an instance of the default configuration var configuration = CheckScannerScreenConfiguration(); // Start the Check Scanner - var result = await ScanbotSdkUiV2.startCheckScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.check.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_check/localization.dart b/lib/snippets/data_capture_sdk/rtuui_check/localization.dart index fae67ef..0a47ee3 100644 --- a/lib/snippets/data_capture_sdk/rtuui_check/localization.dart +++ b/lib/snippets/data_capture_sdk/rtuui_check/localization.dart @@ -1,16 +1,22 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { // Create an instance of the default configuration var configuration = CheckScannerScreenConfiguration(); // Configure the strings. configuration.localization.topUserGuidance = 'Localized topUserGuidance'; - configuration.localization.cameraPermissionCloseButton = 'Localized cameraPermissionCloseButton'; - configuration.localization.completionOverlaySuccessMessage = 'Localized completionOverlaySuccessMessage'; + configuration.localization.cameraPermissionCloseButton = + 'Localized cameraPermissionCloseButton'; + configuration.localization.completionOverlaySuccessMessage = + 'Localized completionOverlaySuccessMessage'; configuration.localization.introScreenText = 'Localized introScreenText'; // Start the Check Scanner UI - var result = await ScanbotSdkUiV2.startCheckScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.check.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_check/palette.dart b/lib/snippets/data_capture_sdk/rtuui_check/palette.dart index 3ac57ed..7b75526 100644 --- a/lib/snippets/data_capture_sdk/rtuui_check/palette.dart +++ b/lib/snippets/data_capture_sdk/rtuui_check/palette.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { // Create an instance of the default configuration @@ -23,8 +23,12 @@ Future startScanning() async { palette.sbColorSurfaceHigh = ScanbotColor('#7A000000'); palette.sbColorModalOverlay = ScanbotColor('#A3000000'); // Start the Check Scanner UI - var result = await ScanbotSdkUiV2.startCheckScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.check.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_check/top_bar.dart b/lib/snippets/data_capture_sdk/rtuui_check/top_bar.dart index a2d20f3..3e7b32f 100644 --- a/lib/snippets/data_capture_sdk/rtuui_check/top_bar.dart +++ b/lib/snippets/data_capture_sdk/rtuui_check/top_bar.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { // Create an instance of the default configuration @@ -11,8 +11,12 @@ Future startScanning() async { configuration.topBar.cancelButton.text = 'Cancel'; configuration.topBar.cancelButton.foreground.color = ScanbotColor('#C8193C'); // Start the Check Scanner UI - var result = await ScanbotSdkUiV2.startCheckScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.check.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_check/user_guidance.dart b/lib/snippets/data_capture_sdk/rtuui_check/user_guidance.dart index a6673c7..59bec10 100644 --- a/lib/snippets/data_capture_sdk/rtuui_check/user_guidance.dart +++ b/lib/snippets/data_capture_sdk/rtuui_check/user_guidance.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { // Create an instance of the default configuration @@ -20,8 +20,12 @@ Future startScanning() async { // Customize the scan status guidance background scanStatusUserGuidance.background.fillColor = ScanbotColor('#C8193C'); // Start the Check Scanner UI - var result = await ScanbotSdkUiV2.startCheckScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.check.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_credit_card/action_bar.dart b/lib/snippets/data_capture_sdk/rtuui_credit_card/action_bar.dart index 973487b..cd7518b 100644 --- a/lib/snippets/data_capture_sdk/rtuui_credit_card/action_bar.dart +++ b/lib/snippets/data_capture_sdk/rtuui_credit_card/action_bar.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -16,8 +16,12 @@ Future startScanning() async { /** Hide the flip camera button */ actionBar.flipCameraButton.visible = false; /** Start the Credit Card Scanner **/ - var result = await ScanbotSdkUiV2.startCreditCardScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.creditCard.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_credit_card/finder_overlay.dart b/lib/snippets/data_capture_sdk/rtuui_credit_card/finder_overlay.dart index 5c9e57e..c99b790 100644 --- a/lib/snippets/data_capture_sdk/rtuui_credit_card/finder_overlay.dart +++ b/lib/snippets/data_capture_sdk/rtuui_credit_card/finder_overlay.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -11,8 +11,12 @@ Future startScanning() async { strokeWidth: 2, ); /** Start the Credit Card Scanner **/ - var result = await ScanbotSdkUiV2.startCreditCardScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.creditCard.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_credit_card/introduction_screen.dart b/lib/snippets/data_capture_sdk/rtuui_credit_card/introduction_screen.dart index 3a3395d..d2d92e0 100644 --- a/lib/snippets/data_capture_sdk/rtuui_credit_card/introduction_screen.dart +++ b/lib/snippets/data_capture_sdk/rtuui_credit_card/introduction_screen.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -13,19 +13,23 @@ Future startScanning() async { text: 'Credit Card Scanner', ); /** Configure the image for the introduction screen. */ - introductionConfiguration.image = CreditCardIntroCustomImage( - uri: 'imageUri', - ); + introductionConfiguration.image = CreditCardIntroCustomImage(uri: 'imageUri'); /** Configure the text. **/ configuration.introScreen.explanation.color = ScanbotColor('#000000'); configuration.introScreen.explanation.text = - "To quickly and securely input your credit card details, please hold your device over the credit card, so that the camera aligns with the numbers on the front of the card.\n\nThe scanner will guide you to the optimal scanning position. Once the scan is complete, your card details will automatically be extracted and processed.\n\nPress 'Start Scanning' to begin."; + "To quickly and securely input your credit card details, please hold your device over the credit card, so that the camera aligns with the numbers on the front of the card.\n\nThe scanner will guide you to the optimal scanning position. Once the scan is complete, your card details will automatically be extracted and processed.\n\nPress 'Start Scanning' to begin."; /** Configure the done button. E.g., the text or the background color. **/ configuration.introScreen.doneButton.text = 'Start Scanning'; - configuration.introScreen.doneButton.background.fillColor = ScanbotColor('#C8193C'); + configuration.introScreen.doneButton.background.fillColor = ScanbotColor( + '#C8193C', + ); /** Start the Credit Card Scanner **/ - var result = await ScanbotSdkUiV2.startCreditCardScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.creditCard.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_credit_card/launching_the_scanner.dart b/lib/snippets/data_capture_sdk/rtuui_credit_card/launching_the_scanner.dart index 7dc9f0a..177c403 100644 --- a/lib/snippets/data_capture_sdk/rtuui_credit_card/launching_the_scanner.dart +++ b/lib/snippets/data_capture_sdk/rtuui_credit_card/launching_the_scanner.dart @@ -1,11 +1,15 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ var configuration = CreditCardScannerScreenConfiguration(); /** Start the Credit Card Scanner **/ - var result = await ScanbotSdkUiV2.startCreditCardScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.creditCard.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_credit_card/localization.dart b/lib/snippets/data_capture_sdk/rtuui_credit_card/localization.dart index d0289b1..7601a10 100644 --- a/lib/snippets/data_capture_sdk/rtuui_credit_card/localization.dart +++ b/lib/snippets/data_capture_sdk/rtuui_credit_card/localization.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -8,14 +8,18 @@ Future startScanning() async { /** Configure the strings. */ localization.topUserGuidance = 'Localized topUserGuidance'; localization.cameraPermissionCloseButton = - 'Localized cameraPermissionCloseButton'; + 'Localized cameraPermissionCloseButton'; localization.completionOverlaySuccessMessage = - 'Localized completionOverlaySuccessMessage'; + 'Localized completionOverlaySuccessMessage'; localization.creditCardUserGuidanceNoCardFound = - 'Localized creditCardUserGuidanceNoCardFound'; + 'Localized creditCardUserGuidanceNoCardFound'; /** Start the Credit Card Scanner **/ - var result = await ScanbotSdkUiV2.startCreditCardScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.creditCard.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_credit_card/palette.dart b/lib/snippets/data_capture_sdk/rtuui_credit_card/palette.dart index 8484cfc..c57e02a 100644 --- a/lib/snippets/data_capture_sdk/rtuui_credit_card/palette.dart +++ b/lib/snippets/data_capture_sdk/rtuui_credit_card/palette.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -23,8 +23,12 @@ Future startScanning() async { palette.sbColorSurfaceHigh = ScanbotColor('#7A000000'); palette.sbColorModalOverlay = ScanbotColor('#A3000000'); /** Start the Credit Card Scanner **/ - var result = await ScanbotSdkUiV2.startCreditCardScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.creditCard.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_credit_card/top_bar.dart b/lib/snippets/data_capture_sdk/rtuui_credit_card/top_bar.dart index 13f38d3..9dff56b 100644 --- a/lib/snippets/data_capture_sdk/rtuui_credit_card/top_bar.dart +++ b/lib/snippets/data_capture_sdk/rtuui_credit_card/top_bar.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -11,8 +11,12 @@ Future startScanning() async { configuration.topBar.cancelButton.text = 'Cancel'; configuration.topBar.cancelButton.foreground.color = ScanbotColor('#C8193C'); /** Start the Credit Card Scanner **/ - var result = await ScanbotSdkUiV2.startCreditCardScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.creditCard.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_credit_card/user_guidance.dart b/lib/snippets/data_capture_sdk/rtuui_credit_card/user_guidance.dart index 2bd746d..a40f276 100644 --- a/lib/snippets/data_capture_sdk/rtuui_credit_card/user_guidance.dart +++ b/lib/snippets/data_capture_sdk/rtuui_credit_card/user_guidance.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -23,8 +23,12 @@ Future startScanning() async { /** Customize the status user guidance background */ scanStatusUserGuidance.background.fillColor = ScanbotColor('#C8193C'); /** Start the Credit Card Scanner **/ - var result = await ScanbotSdkUiV2.startCreditCardScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.creditCard.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_dde/action_bar.dart b/lib/snippets/data_capture_sdk/rtuui_dde/action_bar.dart index d8b55aa..4914e63 100644 --- a/lib/snippets/data_capture_sdk/rtuui_dde/action_bar.dart +++ b/lib/snippets/data_capture_sdk/rtuui_dde/action_bar.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -16,8 +16,14 @@ Future startScanning() async { /** Hide the flip camera button */ actionBar.flipCameraButton.visible = false; /** Start the Document Data Extractor **/ - var result = await ScanbotSdkUiV2.startDocumentDataExtractor(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.documentDataExtractor.startExtractorScreen( + configuration, + ); + if (result is Ok) { + /** Handle the result **/ + var documentDataExtractorUiResult = result.value; + print(documentDataExtractorUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_dde/finder_overlay.dart b/lib/snippets/data_capture_sdk/rtuui_dde/finder_overlay.dart index 7471e9b..81f45ed 100644 --- a/lib/snippets/data_capture_sdk/rtuui_dde/finder_overlay.dart +++ b/lib/snippets/data_capture_sdk/rtuui_dde/finder_overlay.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { // Create an instance of the default configuration @@ -15,8 +15,14 @@ Future startScanning() async { configuration.viewFinder.style = FinderCorneredStyle(strokeWidth: 3.0); // Start the DDE - var result = await ScanbotSdkUiV2.startDocumentDataExtractor(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.documentDataExtractor.startExtractorScreen( + configuration, + ); + if (result is Ok) { + /** Handle the result **/ + var documentDataExtractorUiResult = result.value; + print(documentDataExtractorUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_dde/introduction_screen.dart b/lib/snippets/data_capture_sdk/rtuui_dde/introduction_screen.dart index 49526e2..c07b0d2 100644 --- a/lib/snippets/data_capture_sdk/rtuui_dde/introduction_screen.dart +++ b/lib/snippets/data_capture_sdk/rtuui_dde/introduction_screen.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { // Create an instance of the default configuration @@ -14,11 +14,13 @@ Future startScanning() async { // Configure the image for the introduction screen. // If you want to have no image... - configuration.introScreen.image = DocumentDataExtractorIntroImage.documentDataIntroNoImage(); + configuration.introScreen.image = + DocumentDataExtractorIntroImage.documentDataIntroNoImage(); // For a custom image... // configuration.introScreen.image = DocumentDataExtractorIntroImage.documentDataIntroCustomImage(uri: "PathToImage") // Or you can also use our default image. - configuration.introScreen.image = DocumentDataExtractorIntroImage.documentDataIntroDefaultImage(); + configuration.introScreen.image = + DocumentDataExtractorIntroImage.documentDataIntroDefaultImage(); // Configure the color of the handler on top. configuration.introScreen.handlerColor = ScanbotColor("#EFEFEF"); @@ -28,16 +30,25 @@ Future startScanning() async { // Configure the text. configuration.introScreen.explanation.color = ScanbotColor("#000000"); - configuration.introScreen.explanation.text = "To quickly and securely scan your document details, please hold your device over the document, so that the camera aligns with all the information on the document.\n\nThe scanner will guide you to the optimal scanning position. Once the scan is complete, your document details will automatically be extracted and processed.\n\nPress 'Start Scanning' to begin."; + configuration.introScreen.explanation.text = + "To quickly and securely scan your document details, please hold your device over the document, so that the camera aligns with all the information on the document.\n\nThe scanner will guide you to the optimal scanning position. Once the scan is complete, your document details will automatically be extracted and processed.\n\nPress 'Start Scanning' to begin."; // Configure the done button. // e.g the text or the background color. configuration.introScreen.doneButton.text = "Start Scanning"; - configuration.introScreen.doneButton.background.fillColor = ScanbotColor("#C8193C"); + configuration.introScreen.doneButton.background.fillColor = ScanbotColor( + "#C8193C", + ); // Start the DDE - var result = await ScanbotSdkUiV2.startDocumentDataExtractor(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.documentDataExtractor.startExtractorScreen( + configuration, + ); + if (result is Ok) { + /** Handle the result **/ + var documentDataExtractorUiResult = result.value; + print(documentDataExtractorUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_dde/launching_the_scanner.dart b/lib/snippets/data_capture_sdk/rtuui_dde/launching_the_scanner.dart index 0dc2fe7..8b3741b 100644 --- a/lib/snippets/data_capture_sdk/rtuui_dde/launching_the_scanner.dart +++ b/lib/snippets/data_capture_sdk/rtuui_dde/launching_the_scanner.dart @@ -1,25 +1,50 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { // Create an instance of the default configuration var configuration = DocumentDataExtractorScreenConfiguration(); // Start the Document Data Extractor - var result = await ScanbotSdkUiV2.startDocumentDataExtractor(configuration); - if (result.status == OperationStatus.OK) { + var result = await ScanbotSdk.documentDataExtractor.startExtractorScreen( + configuration, + ); + + if (result is Ok) { // Cast the resulted generic document to the appropriate document model. // Available document types are defined in [DocumentsModelRootType] enum. - var documentModel = DeIdCardFront(result.data!.document!); + var documentModel = DeIdCardFront(result.value.document!); // Retrieve values from the German ID card front - print('Birth date: ${documentModel.birthDate.value?.text}, Confidence: ${documentModel.birthDate.value?.confidence}'); - print('Birthplace: ${documentModel.birthplace.value?.text}, Confidence: ${documentModel.birthplace.value?.confidence}'); - print('Card access number: ${documentModel.cardAccessNumber.value?.text}, Confidence: ${documentModel.cardAccessNumber.value?.confidence}'); - print('Expiry date: ${documentModel.expiryDate.value?.text}, Confidence: ${documentModel.expiryDate.value?.confidence}'); - print('Given names: ${documentModel.givenNames.value?.text}, Confidence: ${documentModel.givenNames.value?.confidence}'); - print('ID: ${documentModel.id.value?.text}, Confidence: ${documentModel.id.value?.confidence}'); - print('Maiden name: ${documentModel.maidenName?.value?.text}, Confidence: ${documentModel.maidenName?.value?.confidence}'); - print('Nationality: ${documentModel.nationality.value?.text}, Confidence: ${documentModel.nationality.value?.confidence}'); - print('Surname: ${documentModel.surname.value?.text}, Confidence: ${documentModel.surname.value?.confidence}'); - print('Series: ${documentModel.series.value?.text}, Confidence: ${documentModel.series.value?.confidence}'); + print( + 'Birth date: ${documentModel.birthDate.value?.text}, Confidence: ${documentModel.birthDate.value?.confidence}', + ); + print( + 'Birthplace: ${documentModel.birthplace.value?.text}, Confidence: ${documentModel.birthplace.value?.confidence}', + ); + print( + 'Card access number: ${documentModel.cardAccessNumber.value?.text}, Confidence: ${documentModel.cardAccessNumber.value?.confidence}', + ); + print( + 'Expiry date: ${documentModel.expiryDate.value?.text}, Confidence: ${documentModel.expiryDate.value?.confidence}', + ); + print( + 'Given names: ${documentModel.givenNames.value?.text}, Confidence: ${documentModel.givenNames.value?.confidence}', + ); + print( + 'ID: ${documentModel.id.value?.text}, Confidence: ${documentModel.id.value?.confidence}', + ); + print( + 'Maiden name: ${documentModel.maidenName?.value?.text}, Confidence: ${documentModel.maidenName?.value?.confidence}', + ); + print( + 'Nationality: ${documentModel.nationality.value?.text}, Confidence: ${documentModel.nationality.value?.confidence}', + ); + print( + 'Surname: ${documentModel.surname.value?.text}, Confidence: ${documentModel.surname.value?.confidence}', + ); + print( + 'Series: ${documentModel.series.value?.text}, Confidence: ${documentModel.series.value?.confidence}', + ); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_dde/localization.dart b/lib/snippets/data_capture_sdk/rtuui_dde/localization.dart index ebf7804..f538d1c 100644 --- a/lib/snippets/data_capture_sdk/rtuui_dde/localization.dart +++ b/lib/snippets/data_capture_sdk/rtuui_dde/localization.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { // Create an instance of the default configuration @@ -8,13 +8,19 @@ Future startScanning() async { // Configure the strings. localization.topUserGuidance = 'Localized topUserGuidance'; localization.cameraPermissionCloseButton = - 'Localized cameraPermissionCloseButton'; + 'Localized cameraPermissionCloseButton'; localization.completionOverlaySuccessMessage = - 'Localized completionOverlaySuccessMessage'; + 'Localized completionOverlaySuccessMessage'; // Start the DDE - var result = await ScanbotSdkUiV2.startDocumentDataExtractor(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.documentDataExtractor.startExtractorScreen( + configuration, + ); + if (result is Ok) { + /** Handle the result **/ + var documentDataExtractorUiResult = result.value; + print(documentDataExtractorUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_dde/palette.dart b/lib/snippets/data_capture_sdk/rtuui_dde/palette.dart index 744769a..0e71ff7 100644 --- a/lib/snippets/data_capture_sdk/rtuui_dde/palette.dart +++ b/lib/snippets/data_capture_sdk/rtuui_dde/palette.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -23,8 +23,14 @@ Future startScanning() async { palette.sbColorSurfaceHigh = ScanbotColor('#7A000000'); palette.sbColorModalOverlay = ScanbotColor('#A3000000'); /** Start the DDE **/ - var result = await ScanbotSdkUiV2.startDocumentDataExtractor(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.documentDataExtractor.startExtractorScreen( + configuration, + ); + if (result is Ok) { + /** Handle the result **/ + var documentDataExtractorUiResult = result.value; + print(documentDataExtractorUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_dde/top_bar.dart b/lib/snippets/data_capture_sdk/rtuui_dde/top_bar.dart index 00d862e..346491e 100644 --- a/lib/snippets/data_capture_sdk/rtuui_dde/top_bar.dart +++ b/lib/snippets/data_capture_sdk/rtuui_dde/top_bar.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -11,8 +11,14 @@ Future startScanning() async { configuration.topBar.cancelButton.text = 'Cancel'; configuration.topBar.cancelButton.foreground.color = ScanbotColor('#C8193C'); /** Start the DDE **/ - var result = await ScanbotSdkUiV2.startDocumentDataExtractor(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.documentDataExtractor.startExtractorScreen( + configuration, + ); + if (result is Ok) { + /** Handle the result **/ + var documentDataExtractorUiResult = result.value; + print(documentDataExtractorUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_dde/user_guidance.dart b/lib/snippets/data_capture_sdk/rtuui_dde/user_guidance.dart index 5ed0042..d622ab4 100644 --- a/lib/snippets/data_capture_sdk/rtuui_dde/user_guidance.dart +++ b/lib/snippets/data_capture_sdk/rtuui_dde/user_guidance.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { // Create an instance of the default configuration @@ -24,8 +24,14 @@ Future startScanning() async { // Configure the background. scanStatusUserGuidance.background.fillColor = ScanbotColor("#7A000000"); // Start the DDE - var result = await ScanbotSdkUiV2.startDocumentDataExtractor(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.documentDataExtractor.startExtractorScreen( + configuration, + ); + if (result is Ok) { + /** Handle the result **/ + var documentDataExtractorUiResult = result.value; + print(documentDataExtractorUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_mrz/action_bar.dart b/lib/snippets/data_capture_sdk/rtuui_mrz/action_bar.dart index d118919..933e294 100644 --- a/lib/snippets/data_capture_sdk/rtuui_mrz/action_bar.dart +++ b/lib/snippets/data_capture_sdk/rtuui_mrz/action_bar.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -18,8 +18,12 @@ Future startScanning() async { actionBar.flipCameraButton.visible = false; /** Start the MRZ Scanner UI */ - var result = await ScanbotSdkUiV2.startMrzScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.mrz.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_mrz/finder_overlay.dart b/lib/snippets/data_capture_sdk/rtuui_mrz/finder_overlay.dart index efbb986..2acf6e6 100644 --- a/lib/snippets/data_capture_sdk/rtuui_mrz/finder_overlay.dart +++ b/lib/snippets/data_capture_sdk/rtuui_mrz/finder_overlay.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -17,8 +17,12 @@ Future startScanning() async { strokeWidth: 2, ); /** Start the MRZ Scanner UI */ - var result = await ScanbotSdkUiV2.startMrzScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.mrz.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_mrz/introduction_screen.dart b/lib/snippets/data_capture_sdk/rtuui_mrz/introduction_screen.dart index cce2702..60b4a56 100644 --- a/lib/snippets/data_capture_sdk/rtuui_mrz/introduction_screen.dart +++ b/lib/snippets/data_capture_sdk/rtuui_mrz/introduction_screen.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -13,19 +13,23 @@ Future startScanning() async { text: 'MRZ Scanner', ); /** Configure the image for the introduction screen. */ - introductionConfiguration.image = MrzIntroCustomImage( - uri: 'imageUri', - ); + introductionConfiguration.image = MrzIntroCustomImage(uri: 'imageUri'); /** Configure the text. **/ configuration.introScreen.explanation.color = ScanbotColor('#000000'); configuration.introScreen.explanation.text = - "The Machine Readable Zone (MRZ) is a special code on your ID document (such as a passport or ID card) that contains your personal information in a machine-readable format.\n\nTo scan it, simply hold your camera over the document, so that it aligns with the MRZ section. Once scanned, the data will be automatically processed, and you will be directed to the results screen.\n\nPress 'Start Scanning' to begin."; + "The Machine Readable Zone (MRZ) is a special code on your ID document (such as a passport or ID card) that contains your personal information in a machine-readable format.\n\nTo scan it, simply hold your camera over the document, so that it aligns with the MRZ section. Once scanned, the data will be automatically processed, and you will be directed to the results screen.\n\nPress 'Start Scanning' to begin."; /** Configure the done button. E.g., the text or the background color. **/ configuration.introScreen.doneButton.text = 'Start Scanning'; - configuration.introScreen.doneButton.background.fillColor = ScanbotColor('#C8193C'); + configuration.introScreen.doneButton.background.fillColor = ScanbotColor( + '#C8193C', + ); /** Start the MRZ Scanner UI */ - var result = await ScanbotSdkUiV2.startMrzScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.mrz.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_mrz/launching_the_scanner.dart b/lib/snippets/data_capture_sdk/rtuui_mrz/launching_the_scanner.dart index 65834eb..559c9b7 100644 --- a/lib/snippets/data_capture_sdk/rtuui_mrz/launching_the_scanner.dart +++ b/lib/snippets/data_capture_sdk/rtuui_mrz/launching_the_scanner.dart @@ -1,16 +1,22 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { // Create an instance of the default configuration var configuration = MrzScannerScreenConfiguration(); // Start the MRZ Scanner - var result = await ScanbotSdkUiV2.startMrzScanner(configuration); - if (result.status == OperationStatus.OK) { + var result = await ScanbotSdk.mrz.startScanner(configuration); + if (result is Ok) { // Cast the resulted generic document to the MRZ model. - var mrzModel = MRZ(result.data!.mrzDocument!); + var mrzModel = MRZ(result.value.mrzDocument!); // Retrieve the values. // e.g - print('Birth date: ${mrzModel.birthDate.value?.text}, Confidence: ${mrzModel.birthDate.value?.confidence}'); - print('Nationality: ${mrzModel.nationality.value?.text}, Confidence: ${mrzModel.nationality.value?.confidence}'); + print( + 'Birth date: ${mrzModel.birthDate.value?.text}, Confidence: ${mrzModel.birthDate.value?.confidence}', + ); + print( + 'Nationality: ${mrzModel.nationality.value?.text}, Confidence: ${mrzModel.nationality.value?.confidence}', + ); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_mrz/localization.dart b/lib/snippets/data_capture_sdk/rtuui_mrz/localization.dart index 2229760..225d358 100644 --- a/lib/snippets/data_capture_sdk/rtuui_mrz/localization.dart +++ b/lib/snippets/data_capture_sdk/rtuui_mrz/localization.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -8,13 +8,17 @@ Future startScanning() async { /** Configure the strings. */ localization.topUserGuidance = 'Localized topUserGuidance'; localization.cameraPermissionCloseButton = - 'Localized cameraPermissionCloseButton'; + 'Localized cameraPermissionCloseButton'; localization.completionOverlaySuccessMessage = - 'Localized completionOverlaySuccessMessage'; + 'Localized completionOverlaySuccessMessage'; localization.finderViewUserGuidance = 'Localized finderViewUserGuidance'; /** Start the MRZ Scanner UI */ - var result = await ScanbotSdkUiV2.startMrzScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.mrz.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_mrz/palette.dart b/lib/snippets/data_capture_sdk/rtuui_mrz/palette.dart index e953044..7aa373b 100644 --- a/lib/snippets/data_capture_sdk/rtuui_mrz/palette.dart +++ b/lib/snippets/data_capture_sdk/rtuui_mrz/palette.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -23,8 +23,12 @@ Future startScanning() async { palette.sbColorSurfaceHigh = ScanbotColor('#7A000000'); palette.sbColorModalOverlay = ScanbotColor('#A3000000'); /** Start the MRZ Scanner UI */ - var result = await ScanbotSdkUiV2.startMrzScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.mrz.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_mrz/top_bar.dart b/lib/snippets/data_capture_sdk/rtuui_mrz/top_bar.dart index 54b8be6..f9dab71 100644 --- a/lib/snippets/data_capture_sdk/rtuui_mrz/top_bar.dart +++ b/lib/snippets/data_capture_sdk/rtuui_mrz/top_bar.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -11,8 +11,12 @@ Future startScanning() async { configuration.topBar.cancelButton.text = 'Cancel'; configuration.topBar.cancelButton.foreground.color = ScanbotColor('#C8193C'); /** Start the MRZ Scanner UI */ - var result = await ScanbotSdkUiV2.startMrzScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.mrz.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_mrz/user_guidance.dart b/lib/snippets/data_capture_sdk/rtuui_mrz/user_guidance.dart index 3495450..93b0daa 100644 --- a/lib/snippets/data_capture_sdk/rtuui_mrz/user_guidance.dart +++ b/lib/snippets/data_capture_sdk/rtuui_mrz/user_guidance.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -22,8 +22,12 @@ Future startScanning() async { /** Customize the finder user guidance background */ finderUserGuidance.background.fillColor = ScanbotColor('#C8193C'); /** Start the MRZ Scanner UI */ - var result = await ScanbotSdkUiV2.startMrzScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.mrz.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_text_pattern/action_bar.dart b/lib/snippets/data_capture_sdk/rtuui_text_pattern/action_bar.dart index 172a47e..207e668 100644 --- a/lib/snippets/data_capture_sdk/rtuui_text_pattern/action_bar.dart +++ b/lib/snippets/data_capture_sdk/rtuui_text_pattern/action_bar.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -18,8 +18,12 @@ Future startScanning() async { actionBar.flipCameraButton.visible = false; /** Start the MRZ Scanner UI */ - var result = await ScanbotSdkUiV2.startTextPatternScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.textPattern.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_text_pattern/introduction_screen.dart b/lib/snippets/data_capture_sdk/rtuui_text_pattern/introduction_screen.dart index 64f9434..be84926 100644 --- a/lib/snippets/data_capture_sdk/rtuui_text_pattern/introduction_screen.dart +++ b/lib/snippets/data_capture_sdk/rtuui_text_pattern/introduction_screen.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -19,13 +19,19 @@ Future startScanning() async { /** Configure the text. **/ configuration.introScreen.explanation.color = ScanbotColor('#000000'); configuration.introScreen.explanation.text = - "To scan a single line of text, please hold your device so that the camera viewfinder clearly captures the text you want to scan. Please ensure the text is properly aligned. Once the scan is complete, the text will be automatically extracted.\n\nPress 'Start Scanning' to begin."; + "To scan a single line of text, please hold your device so that the camera viewfinder clearly captures the text you want to scan. Please ensure the text is properly aligned. Once the scan is complete, the text will be automatically extracted.\n\nPress 'Start Scanning' to begin."; /** Configure the done button. E.g., the text or the background color. **/ configuration.introScreen.doneButton.text = 'Start Scanning'; - configuration.introScreen.doneButton.background.fillColor = ScanbotColor('#C8193C'); + configuration.introScreen.doneButton.background.fillColor = ScanbotColor( + '#C8193C', + ); /** Start the Text Pattern Scanner **/ - var result = await ScanbotSdkUiV2.startTextPatternScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.textPattern.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_text_pattern/launching_the_scanner.dart b/lib/snippets/data_capture_sdk/rtuui_text_pattern/launching_the_scanner.dart index 7f740c0..68e73f7 100644 --- a/lib/snippets/data_capture_sdk/rtuui_text_pattern/launching_the_scanner.dart +++ b/lib/snippets/data_capture_sdk/rtuui_text_pattern/launching_the_scanner.dart @@ -1,11 +1,15 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ var configuration = TextPatternScannerScreenConfiguration(); /** Start the Text Pattern Scanner **/ - var result = await ScanbotSdkUiV2.startTextPatternScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.textPattern.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_text_pattern/localization.dart b/lib/snippets/data_capture_sdk/rtuui_text_pattern/localization.dart index 4f952d5..4f98e42 100644 --- a/lib/snippets/data_capture_sdk/rtuui_text_pattern/localization.dart +++ b/lib/snippets/data_capture_sdk/rtuui_text_pattern/localization.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -7,14 +7,18 @@ Future startScanning() async { /** Configure the strings. */ localization.topUserGuidance = 'Localized topUserGuidance'; localization.cameraPermissionCloseButton = - 'Localized cameraPermissionCloseButton'; + 'Localized cameraPermissionCloseButton'; localization.completionOverlaySuccessMessage = - 'Localized completionOverlaySuccessMessage'; + 'Localized completionOverlaySuccessMessage'; localization.finderViewUserGuidance = 'Localized finderViewUserGuidance'; localization.introScreenTitle = 'Localized introScreenTitle'; /** Start the Text Pattern Scanner **/ - var result = await ScanbotSdkUiV2.startTextPatternScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.textPattern.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_text_pattern/palette.dart b/lib/snippets/data_capture_sdk/rtuui_text_pattern/palette.dart index 337c186..f826850 100644 --- a/lib/snippets/data_capture_sdk/rtuui_text_pattern/palette.dart +++ b/lib/snippets/data_capture_sdk/rtuui_text_pattern/palette.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -23,8 +23,12 @@ Future startScanning() async { palette.sbColorSurfaceHigh = ScanbotColor('#7A000000'); palette.sbColorModalOverlay = ScanbotColor('#A3000000'); /** Start the Text Pattern Scanner **/ - var result = await ScanbotSdkUiV2.startTextPatternScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.textPattern.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_text_pattern/top_bar.dart b/lib/snippets/data_capture_sdk/rtuui_text_pattern/top_bar.dart index 8cebf9c..43cf05e 100644 --- a/lib/snippets/data_capture_sdk/rtuui_text_pattern/top_bar.dart +++ b/lib/snippets/data_capture_sdk/rtuui_text_pattern/top_bar.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -11,8 +11,12 @@ Future startScanning() async { configuration.topBar.cancelButton.text = 'Cancel'; configuration.topBar.cancelButton.foreground.color = ScanbotColor('#C8193C'); /** Start the Text Pattern Scanner **/ - var result = await ScanbotSdkUiV2.startTextPatternScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.textPattern.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_text_pattern/user_guidance.dart b/lib/snippets/data_capture_sdk/rtuui_text_pattern/user_guidance.dart index 815a26b..270e28a 100644 --- a/lib/snippets/data_capture_sdk/rtuui_text_pattern/user_guidance.dart +++ b/lib/snippets/data_capture_sdk/rtuui_text_pattern/user_guidance.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -22,8 +22,12 @@ Future startScanning() async { /** Customize the finder user guidance background */ finderUserGuidance.background.fillColor = ScanbotColor('#C8193C'); /** Start the Text Pattern Scanner **/ - var result = await ScanbotSdkUiV2.startTextPatternScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.textPattern.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_v1_use_cases/check_scanner.dart b/lib/snippets/data_capture_sdk/rtuui_v1_use_cases/check_scanner.dart deleted file mode 100644 index b657ff7..0000000 --- a/lib/snippets/data_capture_sdk/rtuui_v1_use_cases/check_scanner.dart +++ /dev/null @@ -1,27 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:scanbot_sdk/scanbot_sdk_ui.dart'; - -CheckScannerScreenConfiguration checkScannerConfigurationSnippet() { - return CheckScannerScreenConfiguration( - // Behavior configuration: - // e.g. disable capturing the photo to recognize on live video stream - captureHighResolutionImage: false, - - // UI configuration: - // e.g. configure various colors. - topBarBackgroundColor: Colors.red, - topBarButtonsActiveColor: Colors.white, - - // Text configuration: - // e.g. customize UI element's text. - cancelButtonTitle: "Cancel", - ); -} - -Future runCheckScanner() async { - var config = checkScannerConfigurationSnippet(); - var result = await ScanbotSdkUi.startCheckScanner(config); - if (result.status == OperationStatus.OK) { - // ... - } -} diff --git a/lib/snippets/data_capture_sdk/rtuui_v1_use_cases/ehic_scanner.dart b/lib/snippets/data_capture_sdk/rtuui_v1_use_cases/ehic_scanner.dart deleted file mode 100644 index 1699007..0000000 --- a/lib/snippets/data_capture_sdk/rtuui_v1_use_cases/ehic_scanner.dart +++ /dev/null @@ -1,27 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:scanbot_sdk/scanbot_sdk_ui.dart'; - -HealthInsuranceCardScannerConfiguration healthInsuranceScannerConfigurationSnippet() { - return HealthInsuranceCardScannerConfiguration() - // Behavior configuration: - // e.g. turn on the flashlight. - ..flashEnabled = true - - // UI configuration: - // e.g. configure various colors. - ..topBarButtonsActiveColor = Colors.white - ..topBarBackgroundColor = Colors.red - - // Text configuration: - // e.g. customize some UI elements' text. - ..flashButtonTitle = "Flash" - ..cancelButtonTitle = "Cancel"; -} - -Future runEhicScanner() async { - var config = healthInsuranceScannerConfigurationSnippet(); - var result = await ScanbotSdkUi.startEhicScanner(config); - if (result.status == OperationStatus.OK) { - // ... - } -} diff --git a/lib/snippets/data_capture_sdk/rtuui_v1_use_cases/medical_scanner.dart b/lib/snippets/data_capture_sdk/rtuui_v1_use_cases/medical_scanner.dart deleted file mode 100644 index 7cd4db9..0000000 --- a/lib/snippets/data_capture_sdk/rtuui_v1_use_cases/medical_scanner.dart +++ /dev/null @@ -1,36 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:scanbot_sdk/scanbot_sdk_ui.dart'; - -MedicalCertificateScannerConfiguration medicalCertificateScannerConfigurationSnippet() { - return MedicalCertificateScannerConfiguration() - // Behavior configuration: - // e.g. disable recognition of patient's personal information. - ..recognizePatientInfo = false - - // UI configuration: - // e.g. configure various colors. - ..topBarBackgroundColor = Colors.red - ..topBarButtonsActiveColor = Colors.white - - // Configuration for the hint values: - // If you do not set your own values, the default ones will be used. - ..userGuidanceStrings = MedicalCertificateUserGuidanceStrings( - "Start scanning", - "Scanning", - "Energy saving", - "Capturing", - "Processing", - "Paused") - - // Text configuration: - // e.g. customize UI element's text. - ..cancelButtonTitle = "Cancel"; -} - -Future runMedicalDocumentPageScanner() async { - var config = medicalCertificateScannerConfigurationSnippet(); - var result = await ScanbotSdkUi.startMedicalCertificateScanner(config); - if (result.status == OperationStatus.OK) { - // ... - } -} diff --git a/lib/snippets/data_capture_sdk/rtuui_vin/action_bar.dart b/lib/snippets/data_capture_sdk/rtuui_vin/action_bar.dart index e7a2e8d..a4b8cf0 100644 --- a/lib/snippets/data_capture_sdk/rtuui_vin/action_bar.dart +++ b/lib/snippets/data_capture_sdk/rtuui_vin/action_bar.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -16,8 +16,12 @@ Future startScanning() async { /** Hide the flip camera button */ actionBar.flipCameraButton.visible = false; /** Start the VIN Scanner **/ - var result = await ScanbotSdkUiV2.startVINScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.vin.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_vin/finder_overlay.dart b/lib/snippets/data_capture_sdk/rtuui_vin/finder_overlay.dart index 12619fc..a63b476 100644 --- a/lib/snippets/data_capture_sdk/rtuui_vin/finder_overlay.dart +++ b/lib/snippets/data_capture_sdk/rtuui_vin/finder_overlay.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -9,8 +9,12 @@ Future startScanning() async { strokeWidth: 2, ); /** Start the VIN Scanner **/ - var result = await ScanbotSdkUiV2.startVINScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.vin.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_vin/introduction_screen.dart b/lib/snippets/data_capture_sdk/rtuui_vin/introduction_screen.dart index c2a3f9d..6971d27 100644 --- a/lib/snippets/data_capture_sdk/rtuui_vin/introduction_screen.dart +++ b/lib/snippets/data_capture_sdk/rtuui_vin/introduction_screen.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { // Create an instance of the default configuration @@ -28,16 +28,23 @@ Future startScanning() async { // Configure the text. configuration.introScreen.explanation.color = ScanbotColor("#000000"); - configuration.introScreen.explanation.text = "To scan a VIN (Vehicle Identification Number), please hold your device so that the camera viewfinder clearly captures the VIN code. Please ensure the VIN is properly aligned. Once the scan is complete, the VIN will be automatically extracted.\n\nPress 'Start Scanning' to begin."; + configuration.introScreen.explanation.text = + "To scan a VIN (Vehicle Identification Number), please hold your device so that the camera viewfinder clearly captures the VIN code. Please ensure the VIN is properly aligned. Once the scan is complete, the VIN will be automatically extracted.\n\nPress 'Start Scanning' to begin."; // Configure the done button. // e.g the text or the background color. configuration.introScreen.doneButton.text = "Start Scanning"; - configuration.introScreen.doneButton.background.fillColor = ScanbotColor("#C8193C"); + configuration.introScreen.doneButton.background.fillColor = ScanbotColor( + "#C8193C", + ); /** Start the VIN Scanner **/ - var result = await ScanbotSdkUiV2.startVINScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.vin.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_vin/launching_the_scanner.dart b/lib/snippets/data_capture_sdk/rtuui_vin/launching_the_scanner.dart index 291e09c..2564c73 100644 --- a/lib/snippets/data_capture_sdk/rtuui_vin/launching_the_scanner.dart +++ b/lib/snippets/data_capture_sdk/rtuui_vin/launching_the_scanner.dart @@ -1,11 +1,15 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ var configuration = VinScannerScreenConfiguration(); /** Start the VIN Scanner **/ - var result = await ScanbotSdkUiV2.startVINScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.vin.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_vin/localization.dart b/lib/snippets/data_capture_sdk/rtuui_vin/localization.dart index c53a146..fc62518 100644 --- a/lib/snippets/data_capture_sdk/rtuui_vin/localization.dart +++ b/lib/snippets/data_capture_sdk/rtuui_vin/localization.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -8,13 +8,17 @@ Future startScanning() async { /** Configure the strings. */ localization.topUserGuidance = 'Localized topUserGuidance'; localization.cameraPermissionCloseButton = - 'Localized cameraPermissionCloseButton'; + 'Localized cameraPermissionCloseButton'; localization.completionOverlaySuccessMessage = - 'Localized completionOverlaySuccessMessage'; + 'Localized completionOverlaySuccessMessage'; /** Start the VIN Scanner **/ - var result = await ScanbotSdkUiV2.startVINScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.vin.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_vin/palette.dart b/lib/snippets/data_capture_sdk/rtuui_vin/palette.dart index d0e4f50..cfcbdb8 100644 --- a/lib/snippets/data_capture_sdk/rtuui_vin/palette.dart +++ b/lib/snippets/data_capture_sdk/rtuui_vin/palette.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -23,8 +23,12 @@ Future startScanning() async { palette.sbColorSurfaceHigh = ScanbotColor('#7A000000'); palette.sbColorModalOverlay = ScanbotColor('#A3000000'); /** Start the VIN Scanner **/ - var result = await ScanbotSdkUiV2.startVINScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.vin.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_vin/top_bar.dart b/lib/snippets/data_capture_sdk/rtuui_vin/top_bar.dart index 6b08a7d..e0f08b3 100644 --- a/lib/snippets/data_capture_sdk/rtuui_vin/top_bar.dart +++ b/lib/snippets/data_capture_sdk/rtuui_vin/top_bar.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -11,8 +11,12 @@ Future startScanning() async { configuration.topBar.cancelButton.text = 'Cancel'; configuration.topBar.cancelButton.foreground.color = ScanbotColor('#C8193C'); /** Start the VIN Scanner **/ - var result = await ScanbotSdkUiV2.startVINScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.vin.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/data_capture_sdk/rtuui_vin/user_guidance.dart b/lib/snippets/data_capture_sdk/rtuui_vin/user_guidance.dart index cc7bf93..3550b31 100644 --- a/lib/snippets/data_capture_sdk/rtuui_vin/user_guidance.dart +++ b/lib/snippets/data_capture_sdk/rtuui_vin/user_guidance.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; Future startScanning() async { /** Create an instance of the default configuration */ @@ -20,8 +20,12 @@ Future startScanning() async { /** Customize the status user guidance background */ finderUserGuidance.background.fillColor = ScanbotColor('#C8193C'); /** Start the Credit Card Scanner **/ - var result = await ScanbotSdkUiV2.startVINScanner(configuration); - if (result.status == OperationStatus.OK) { - // ... + var result = await ScanbotSdk.vin.startScanner(configuration); + if (result is Ok) { + /** Handle the result **/ + var scannerUiResult = result.value; + print(scannerUiResult.toString()); + } else { + print(result.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/document_sdk/acknowledge_config_snippet.dart b/lib/snippets/document_sdk/acknowledge_config_snippet.dart index bca1d5b..5b189d6 100644 --- a/lib/snippets/document_sdk/acknowledge_config_snippet.dart +++ b/lib/snippets/document_sdk/acknowledge_config_snippet.dart @@ -1,43 +1,42 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; DocumentScanningFlow acknowledgementConfigurationScanningFlow() { // Create the default configuration object. var configuration = DocumentScanningFlow(); configuration.screens.camera.acknowledgement - // Set the acknowledgment mode - // Modes: - // - `ALWAYS`: Runs the quality analyzer on the captured document and always displays the acknowledgment screen. - // - `BAD_QUALITY`: Runs the quality analyzer and displays the acknowledgment screen only if the quality is poor. - // - `NONE`: Skips the quality check entirely. - ..acknowledgementMode = AcknowledgementMode.ALWAYS - - // Set the minimum acceptable document quality. - // Options: EXCELLENT, GOOD, REASONABLE, POOR, VERY_POOR, or NO_DOCUMENT. - ..minimumQuality = DocumentQuality.REASONABLE - - // Set the background color for the acknowledgment screen. - ..backgroundColor = ScanbotColor("#EFEFEF") - - // You can also configure the buttons in the bottom bar of the acknowledgment screen. - // E.g., to force the user to retake, if the captured document is not OK. - ..bottomBar.acceptWhenNotOkButton.visible = false - - // Hide the titles of the buttons. - ..bottomBar.acceptWhenNotOkButton.title.visible = false - ..bottomBar.acceptWhenOkButton.title.visible = false - ..bottomBar.retakeButton.title.visible = false - - // Configure the acknowledgment screen's hint message which is shown if the least acceptable quality is not met. - ..badImageHint.visible = true; + // Set the acknowledgment mode + // Modes: + // - `ALWAYS`: Runs the quality analyzer on the captured document and always displays the acknowledgment screen. + // - `BAD_QUALITY`: Runs the quality analyzer and displays the acknowledgment screen only if the quality is poor. + // - `NONE`: Skips the quality check entirely. + ..acknowledgementMode = AcknowledgementMode.ALWAYS + // Set the minimum acceptable document quality. + // Options: EXCELLENT, GOOD, REASONABLE, POOR, VERY_POOR. + ..minimumQuality = DocumentQuality.REASONABLE + // Set the background color for the acknowledgment screen. + ..backgroundColor = ScanbotColor("#EFEFEF") + // You can also configure the buttons in the bottom bar of the acknowledgment screen. + // E.g., to force the user to retake, if the captured document is not OK. + ..bottomBar.acceptWhenNotOkButton.visible = false + // Hide the titles of the buttons. + ..bottomBar.acceptWhenNotOkButton.title.visible = false + ..bottomBar.acceptWhenOkButton.title.visible = false + ..bottomBar.retakeButton.title.visible = false + // Configure the acknowledgment screen's hint message which is shown if the least acceptable quality is not met. + ..badImageHint.visible = true; return configuration; } void runDocumentScanner() async { var configuration = acknowledgementConfigurationScanningFlow(); - var documentResult = await ScanbotSdkUiV2.startDocumentScanner(configuration); - // Handle the document if the status is 'OK' - if(documentResult.status == OperationStatus.OK) { + var documentResult = await ScanbotSdk.document.startScanner(configuration); + // Handle the document if the result is 'Ok' + if (documentResult is Ok) { + var documentData = documentResult.value; + print(documentData); + } else { + print(documentResult.toString()); } } diff --git a/lib/snippets/document_sdk/automatic_filtering.dart b/lib/snippets/document_sdk/automatic_filtering.dart index 7a3505f..9991da3 100644 --- a/lib/snippets/document_sdk/automatic_filtering.dart +++ b/lib/snippets/document_sdk/automatic_filtering.dart @@ -1,5 +1,4 @@ import 'package:scanbot_sdk/scanbot_sdk.dart'; -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; Future startScanning() async { /** Create the default configuration instance */ @@ -7,8 +6,12 @@ Future startScanning() async { /** Set any `ParametricFilter` type to default filter.*/ configuration.outputSettings.defaultFilter = ScanbotBinarizationFilter(); /** Start the Document Scanner UI */ - var documentResult = await ScanbotSdkUiV2.startDocumentScanner(configuration); - /** Handle the document if the status is 'OK' */ - if (documentResult.status == OperationStatus.OK) { + var documentResult = await ScanbotSdk.document.startScanner(configuration); + /** Handle the document if the result is 'Ok' */ + if (documentResult is Ok) { + var documentData = documentResult.value; + print(documentData); + } else { + print(documentResult.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/document_sdk/cropp_screen_snippet.dart b/lib/snippets/document_sdk/cropp_screen_snippet.dart index aaf2d72..4d6062f 100644 --- a/lib/snippets/document_sdk/cropp_screen_snippet.dart +++ b/lib/snippets/document_sdk/cropp_screen_snippet.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; void startCropping() async { // Create the default configuration object. @@ -10,12 +10,18 @@ void startCropping() async { cropScreenConfiguration.bottomBar.rotateButton.visible = false; // Configure various colors. configuration.appearance.topBarBackgroundColor = ScanbotColor('#C8193C'); - cropScreenConfiguration.topBarConfirmButton.foreground.color = ScanbotColor('#FFFFFF'); + cropScreenConfiguration.topBarConfirmButton.foreground.color = ScanbotColor( + '#FFFFFF', + ); // Customize a UI element's text configuration.localization.croppingTopBarCancelButtonTitle = 'Cancel'; // Start the Document Scanner UI - var documentResult = await ScanbotSdkUiV2.startDocumentScanner(configuration); - // Handle the document if the status is 'OK' - if(documentResult.status == OperationStatus.OK) { + var documentResult = await ScanbotSdk.document.startScanner(configuration); + // Handle the document if the result is 'Ok' + if (documentResult is Ok) { + var documentData = documentResult.value; + print(documentData); + } else { + print(documentResult.toString()); } } diff --git a/lib/snippets/document_sdk/document_detection/document_detection.dart b/lib/snippets/document_sdk/document_detection/document_detection.dart deleted file mode 100644 index a2b5eb6..0000000 --- a/lib/snippets/document_sdk/document_detection/document_detection.dart +++ /dev/null @@ -1,15 +0,0 @@ -import '../../../utility/utils.dart' show selectImageFromLibrary; -import 'package:scanbot_sdk/scanbot_sdk.dart'; - -Future detectDocumentDetection() async { - /** - * Select an image from the Image Library - * Return early if no image is selected or there is an issue with selecting an image - **/ - var imageFile = await selectImageFromLibrary(); - if (imageFile == null) { - return; - } - /** Detect the document */ - var documentDetectionResult = await ScanbotSdk.document.detectDocument(imageFile.path); -} \ No newline at end of file diff --git a/lib/snippets/document_sdk/document_detection/document_detection_cropping_ui.dart b/lib/snippets/document_sdk/document_detection/document_detection_cropping_ui.dart index b7f7440..f77a2a6 100644 --- a/lib/snippets/document_sdk/document_detection/document_detection_cropping_ui.dart +++ b/lib/snippets/document_sdk/document_detection/document_detection_cropping_ui.dart @@ -1,9 +1,10 @@ import 'package:scanbot_sdk/scanbot_sdk.dart'; -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; import '../../../utility/utils.dart'; -Future startDocumentDetectionWithCroppingScreen(String imageFilePath) async { +Future startDocumentDetectionWithCroppingScreen( + String imageFilePath, +) async { /** * Select an image from the Image Library * Return early if no image is selected or there is an issue selecting an image @@ -14,23 +15,34 @@ Future startDocumentDetectionWithCroppingScreen(String imageFilePath) asyn } /** Create a new document with the provided imageFileUri. */ - var params = CreateDocumentParams( - imageFileUris: [imageFile.path] - ); - var document = await ScanbotSdk.document.createDocument(params); - /** Create a new configuration with the document and the document's first page. */ - var configuration = CroppingConfiguration( - documentUuid: document.uuid, - pageUuid: document.pages[0].uuid, - ); - /* Customize the configuration. */ - configuration.cropping.bottomBar.rotateButton.visible = false; - configuration.appearance.topBarBackgroundColor = ScanbotColor('#c8193c'); - configuration.cropping.topBarConfirmButton.foreground.color = ScanbotColor('#ffffff'); - configuration.localization.croppingTopBarCancelButtonTitle = 'Cancel'; - /** Start the cropping UI Screen */ - var documentResult = await ScanbotSdkUiV2.startCroppingScreen(configuration); - /** Handle the document if the status is 'OK' */ - if (documentResult.status == OperationStatus.OK) { + var documentResult = await ScanbotSdk.document + .createDocumentFromImageFileUris(images: [imageFile.path]); + if (documentResult is Ok) { + var document = documentResult.value; + /** Create a new configuration with the document and the document's first page. */ + var configuration = CroppingConfiguration( + documentUuid: document.uuid, + pageUuid: document.pages[0].uuid, + ); + /* Customize the configuration. */ + configuration.cropping.bottomBar.rotateButton.visible = false; + configuration.appearance.topBarBackgroundColor = ScanbotColor('#c8193c'); + configuration.cropping.topBarConfirmButton.foreground.color = ScanbotColor( + '#ffffff', + ); + configuration.localization.croppingTopBarCancelButtonTitle = 'Cancel'; + /** Start the cropping UI Screen */ + var documentCroppingResult = await ScanbotSdk.document.startCroppingScreen( + configuration, + ); + /** Handle the document if the result is 'Ok' */ + if (documentCroppingResult is Ok) { + var documentData = documentCroppingResult.value; + print(documentData); + } else { + print(documentCroppingResult.toString()); + } + } else { + print(documentResult.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/document_sdk/document_detection/scan_from_image_file_uri.dart b/lib/snippets/document_sdk/document_detection/scan_from_image_file_uri.dart new file mode 100644 index 0000000..38fe7c7 --- /dev/null +++ b/lib/snippets/document_sdk/document_detection/scan_from_image_file_uri.dart @@ -0,0 +1,25 @@ +import '../../../utility/utils.dart' show selectImageFromLibrary; +import 'package:scanbot_sdk/scanbot_sdk.dart'; + +Future scanDocumentFromImageFileUri() async { + /** + * Select an image from the Image Library + * Return early if no image is selected or there is an issue with selecting an image + **/ + var imageFile = await selectImageFromLibrary(); + if (imageFile == null) { + return; + } + /** Detect the document */ + var result = await ScanbotSdk.document.scanFromImageFileUri( + imageFile.path, + DocumentScannerConfiguration(), + ); + if (result is Ok) { + /** Handle the result **/ + var documentDetectionResult = result.value; + print(documentDetectionResult.toString()); + } else { + print(result.toString()); + } +} diff --git a/lib/snippets/document_sdk/document_detection/scan_from_image_ref.dart b/lib/snippets/document_sdk/document_detection/scan_from_image_ref.dart new file mode 100644 index 0000000..c48c73d --- /dev/null +++ b/lib/snippets/document_sdk/document_detection/scan_from_image_ref.dart @@ -0,0 +1,31 @@ +import '../../../utility/utils.dart' show selectImageFromLibrary; +import 'package:scanbot_sdk/scanbot_sdk.dart'; + +Future scanDocumentFromImageRef() async { + /** + * Select an image from the Image Library + * Return early if no image is selected or there is an issue with selecting an image + **/ + var imageFile = await selectImageFromLibrary(); + if (imageFile == null) { + return; + } + + await autorelease(() async { + final imageRef = ImageRef.fromPath(imageFile.path); + + /** Detect the document */ + var result = await ScanbotSdk.document.scanFromImageRef( + imageRef, + DocumentScannerConfiguration(), + ); + + if (result is Ok) { + /** Handle the result **/ + var documentDetectionResult = result.value; + print(documentDetectionResult.toString()); + } else { + print(result.toString()); + } + }); +} diff --git a/lib/snippets/document_sdk/document_operations/apply_filters_on_document.dart b/lib/snippets/document_sdk/document_operations/apply_filters_on_document.dart index 4a500c1..f1ff51f 100644 --- a/lib/snippets/document_sdk/document_operations/apply_filters_on_document.dart +++ b/lib/snippets/document_sdk/document_operations/apply_filters_on_document.dart @@ -2,22 +2,34 @@ import 'package:scanbot_sdk/scanbot_sdk.dart'; Future applyFiltersAndRotateScannedPage() async { /** Load a document from storage or create a new one */ - var document = await ScanbotSdk.document.loadDocument( + var documentResult = await ScanbotSdk.document.loadDocument( "SOME_STORED_DOCUMENT_ID", ); - /** Get the first page of the document */ - var page = document.pages[0]; - /** - * Apply ScanbotBinarizationFilter to the page - * Rotate the page clockwise by 90 degrees - */ - var params = ModifyPageParams( - documentID: document.uuid, - pageID: page.uuid, - filters: [ScanbotBinarizationFilter()], - rotation: PageRotation.CLOCKWISE_90 - ); - var documentResultWithModifiedPage = await ScanbotSdk.document.modifyPage(params); - /** Handle the document */ -} \ No newline at end of file + if (documentResult is Ok) { + var document = documentResult.value; + + /** Get the first page of the document */ + var page = document.pages[0]; + /** + * Apply ScanbotBinarizationFilter to the page + * Rotate the page clockwise by 90 degrees + */ + var options = ModifyPageOptions( + filters: [ScanbotBinarizationFilter()], + rotation: ImageRotation.CLOCKWISE_90, + ); + var documentResultWithModifiedPage = await ScanbotSdk.document.modifyPage( + document.uuid, + page.uuid, + options: options, + ); + if (documentResultWithModifiedPage is Ok) { + /** Handle the document */ + } else { + print(documentResultWithModifiedPage.toString()); + } + } else { + print(documentResult.toString()); + } +} diff --git a/lib/snippets/document_sdk/document_operations/create_document_from_pdf.dart b/lib/snippets/document_sdk/document_operations/create_document_from_pdf.dart index 04997d4..4b8b923 100644 --- a/lib/snippets/document_sdk/document_operations/create_document_from_pdf.dart +++ b/lib/snippets/document_sdk/document_operations/create_document_from_pdf.dart @@ -5,5 +5,12 @@ Future createDocumentFromPDF(String pdfFilePath) async { * Create a document with a uuid * Extract images from the PDF file and add them as document pages */ - var document = await ScanbotSdk.document.createDocumentFromPDF(pdfFilePath); -} \ No newline at end of file + var documentResult = await ScanbotSdk.document.createDocumentFromPdf( + pdfFilePath, + ); + if (documentResult is Ok) { + /** Handle the document */ + } else { + print(documentResult.toString()); + } +} diff --git a/lib/snippets/document_sdk/document_operations/create_document_pdf.dart b/lib/snippets/document_sdk/document_operations/create_document_pdf.dart index 930c69b..dec4de6 100644 --- a/lib/snippets/document_sdk/document_operations/create_document_pdf.dart +++ b/lib/snippets/document_sdk/document_operations/create_document_pdf.dart @@ -1,21 +1,27 @@ -import 'package:scanbot_sdk/core.dart'; import 'package:scanbot_sdk/scanbot_sdk.dart'; Future createDocumentPDF() async { /** Load a document from storage or create a new one */ - var document = await ScanbotSdk.document.loadDocument( + var documentResult = await ScanbotSdk.document.loadDocument( 'SOME_STORED_DOCUMENT_ID', ); /** Create a PDF file with the provided options */ - var params = PDFFromDocumentParams( - documentID: document.uuid, - pdfConfiguration: PdfConfiguration( - pageSize: PageSize.A4, - pageDirection: PageDirection.PORTRAIT, - ), - ocrConfiguration: OcrOptions( - engineMode: OcrEngine.SCANBOT_OCR - ) + var pdfConfiguration = PdfConfiguration( + pageSize: PageSize.A4, + pageDirection: PageDirection.PORTRAIT, ); - var pdfUriResult = await ScanbotSdk.document.createPDFForDocument(params); + + var ocrConfiguration = OcrConfiguration(engineMode: OcrEngine.SCANBOT_OCR); + if (documentResult is Ok) { + var pdfUriResult = await ScanbotSdk.pdfGenerator.generateFromDocument( + documentResult.value.uuid, + pdfConfiguration, + ocrConfiguration: ocrConfiguration, + ); + if (pdfUriResult is Ok) { + /** Handle the pdf */ + } + } else { + print(documentResult.toString()); + } } diff --git a/lib/snippets/document_sdk/document_operations/create_document_tiff.dart b/lib/snippets/document_sdk/document_operations/create_document_tiff.dart index e5b269f..860e026 100644 --- a/lib/snippets/document_sdk/document_operations/create_document_tiff.dart +++ b/lib/snippets/document_sdk/document_operations/create_document_tiff.dart @@ -2,13 +2,19 @@ import 'package:scanbot_sdk/scanbot_sdk.dart'; Future createDocumentTIFF() async { /** Load a document from storage or create a new one */ - var document = await ScanbotSdk.document.loadDocument( + var documentResult = await ScanbotSdk.document.loadDocument( 'SOME_STORED_DOCUMENT_ID', ); - /** Create a TIFF file with the provided options */ - var params = TIFFFromDocumentParams( - documentID: document.uuid, - configuration: TiffGeneratorParameters() - ); - var tiffUriResult = await ScanbotSdk.document.createTIFFForDocument(params); -} \ No newline at end of file + if (documentResult is Ok) { + /** Create a TIFF file with the provided options */ + var tiffUriResult = await ScanbotSdk.tiffGenerator.generateFromDocument( + documentResult.value.uuid, + TiffGeneratorParameters(), + ); + if (tiffUriResult is Ok) { + /** Handle the document */ + } + } else { + print(documentResult.toString()); + } +} diff --git a/lib/snippets/document_sdk/document_operations/document_quality_analyzer.dart b/lib/snippets/document_sdk/document_operations/document_quality_analyzer.dart index a5e9079..cdbaeaa 100644 --- a/lib/snippets/document_sdk/document_operations/document_quality_analyzer.dart +++ b/lib/snippets/document_sdk/document_operations/document_quality_analyzer.dart @@ -2,5 +2,14 @@ import 'package:scanbot_sdk/scanbot_sdk.dart'; Future documentQualityAnalyzer(String imageFilePath) async { /** Detect the quality of the document on image **/ - var quality = await ScanbotSdk.analyzeDocumentQuality(imageFilePath, DocumentQualityAnalyzerConfiguration()); -} \ No newline at end of file + var result = await ScanbotSdk.document.analyzeQualityOnImageFileUri( + imageFilePath, + DocumentQualityAnalyzerConfiguration(), + ); + + if (result is Ok) { + /** Handle the DQA Result */ + } else { + print(result.toString()); + } +} diff --git a/lib/snippets/document_sdk/document_operations/storage_for_documents.dart b/lib/snippets/document_sdk/document_operations/storage_for_documents.dart index 33bf389..70c32d1 100644 --- a/lib/snippets/document_sdk/document_operations/storage_for_documents.dart +++ b/lib/snippets/document_sdk/document_operations/storage_for_documents.dart @@ -1,9 +1,14 @@ import 'package:scanbot_sdk/scanbot_sdk.dart'; Future createDocument() async { - var params = CreateDocumentParams(); /** Create a document with a UUID */ - var document = await ScanbotSdk.document.createDocument(params); + var documentResult = + await ScanbotSdk.document.createDocumentFromImageFileUris(); + if (documentResult is Ok) { + /** Handle the document */ + } else { + print(documentResult.toString()); + } } Future createDocumentWithPages(List imageFileUris) async { @@ -11,38 +16,66 @@ Future createDocumentWithPages(List imageFileUris) async { * Create a document with a UUID * Add images from `imageFileUris` as document pages * */ - var params = CreateDocumentParams( - imageFileUris: imageFileUris, - ); - - var document = await ScanbotSdk.document.createDocument(params); + var documentResult = await ScanbotSdk.document + .createDocumentFromImageFileUris(images: imageFileUris); + if (documentResult is Ok) { + /** Handle the document */ + } else { + print(documentResult.toString()); + } } Future loadDocument(String documentID) async { /** Load a document from storage by ID */ - var document = await ScanbotSdk.document.loadDocument(documentID); + var documentResult = await ScanbotSdk.document.loadDocument(documentID); + if (documentResult is Ok) { + /** Handle the document */ + } else { + print(documentResult.toString()); + } } -Future storedDocumentUUIDs() async { +Future getStoredDocumentUuids() async { /** Retrieve all the document IDs from the storage */ - var documentIds = await ScanbotSdk.document.storedDocumentIDs(); + var documentIdsResult = await ScanbotSdk.document.getStoredDocumentUuids(); + if (documentIdsResult is Ok>) { + /** Handle the document IDs */ + } else { + print(documentIdsResult.toString()); + } } Future reorderDocumentPages(String documentID) async { /** Load a document from storage by ID */ - var document = await ScanbotSdk.document.loadDocument(documentID); - /** Move the first page to the end of the document */ - var params = MovePageParams( - documentID: document.uuid, - fromIndex: 0, - toIndex: document.pages.length - 1 - ); - var documentWithReorderedPages = await ScanbotSdk.document.movePage(params); + var documentResult = await ScanbotSdk.document.loadDocument(documentID); + if (documentResult is Ok) { + var document = documentResult.value; + /** Move the first page to the end of the document */ + var documentWithReorderedPageResult = await ScanbotSdk.document.movePage( + document.uuid, + 0, + document.pages.length - 1, + ); + if (documentWithReorderedPageResult is Ok) { + /** Handle the document */ + } else { + print(documentWithReorderedPageResult.toString()); + } + } else { + print(documentResult.toString()); + } } Future removeAllPagesFromDocument(String documentID) async { /** Remove all the pages from a document */ - var documentWithRemovedPages = await ScanbotSdk.document.removeAllPages(documentID); + var documentWithRemovedPagesResult = await ScanbotSdk.document.removeAllPages( + documentID, + ); + if (documentWithRemovedPagesResult is Ok) { + /** Handle the document */ + } else { + print(documentWithRemovedPagesResult.toString()); + } } Future deleteDocument(String documentID) async { diff --git a/lib/snippets/document_sdk/image_operations/apply_filters_on_image.dart b/lib/snippets/document_sdk/image_operations/apply_filters_on_image.dart index 683aa06..7a65861 100644 --- a/lib/snippets/document_sdk/image_operations/apply_filters_on_image.dart +++ b/lib/snippets/document_sdk/image_operations/apply_filters_on_image.dart @@ -2,13 +2,21 @@ import 'package:scanbot_sdk/scanbot_sdk.dart'; Future applyFiltersOnImage(String imageFileUri) async { /** Apply ScanbotBinarizationFilter to the image */ - var imageWithFilters = await ScanbotSdk.imageOperations.applyFiltersOnImage( - imageFileUri, - [ScanbotBinarizationFilter()], - ); - /** Rotate the page counterclockwise by 90 degrees */ - var rotatedImage = await ScanbotSdk.imageOperations.rotateImage( - imageWithFilters.imageFileUri, - 90, - ); -} \ No newline at end of file + var imageWithFiltersResult = await ScanbotSdk.imageProcessor + .applyFiltersOnImageFile(imageFileUri, [ScanbotBinarizationFilter()]); + + if (imageWithFiltersResult is Ok) { + /** Rotate the page counterclockwise by 90 degrees */ + var rotatedImageResult = await ScanbotSdk.imageProcessor.rotateImageFile( + imageWithFiltersResult.value, + ImageRotation.COUNTERCLOCKWISE_90, + ); + + if (rotatedImageResult is Ok) { + print(rotatedImageResult.value); + /** Handle the rotated image */ + } else { + print(rotatedImageResult.toString()); + } + } +} diff --git a/lib/snippets/document_sdk/image_operations/create_pdf_from_image.dart b/lib/snippets/document_sdk/image_operations/create_pdf_from_image.dart index 316026a..86fde55 100644 --- a/lib/snippets/document_sdk/image_operations/create_pdf_from_image.dart +++ b/lib/snippets/document_sdk/image_operations/create_pdf_from_image.dart @@ -1,11 +1,14 @@ import 'package:scanbot_sdk/scanbot_sdk.dart'; Future createPdfFromImages(List imageFileUris) async { - var params = CreatePDFArguments( - imageFileUris: imageFileUris, - pdfConfiguration: PdfConfiguration(), - ); - /** Create a PDF file with the provided options */ - var result = await ScanbotSdk.imageOperations.createPDFFromImages(params); -} \ No newline at end of file + var result = await ScanbotSdk.pdfGenerator.generateFromImageFileUris( + imageFileUris, + PdfConfiguration(), + ); + if (result is Ok) { + /** Handle the pdf */ + } else { + print(result.toString()); + } +} diff --git a/lib/snippets/document_sdk/image_operations/create_tiff_from_image.dart b/lib/snippets/document_sdk/image_operations/create_tiff_from_image.dart index 82dcd9a..9039e76 100644 --- a/lib/snippets/document_sdk/image_operations/create_tiff_from_image.dart +++ b/lib/snippets/document_sdk/image_operations/create_tiff_from_image.dart @@ -1,11 +1,14 @@ import 'package:scanbot_sdk/scanbot_sdk.dart'; Future createTiffFromImages(List imageFileUris) async { - var params = WriteTIFFArguments( - imageFileUris: imageFileUris, - configuration: TiffGeneratorParameters() - ); - /** Create a Tiff file with the provided options */ - var result = await ScanbotSdk.imageOperations.createTIFFFromImages(params); -} \ No newline at end of file + var result = await ScanbotSdk.tiffGenerator.generateFromImageFileUris( + imageFileUris, + TiffGeneratorParameters(), + ); + if (result is Ok) { + /** Handle the tiff */ + } else { + print(result.toString()); + } +} diff --git a/lib/snippets/document_sdk/image_operations/extract_image_from_pdf.dart b/lib/snippets/document_sdk/image_operations/extract_image_from_pdf.dart index a435bf6..68c1ee9 100644 --- a/lib/snippets/document_sdk/image_operations/extract_image_from_pdf.dart +++ b/lib/snippets/document_sdk/image_operations/extract_image_from_pdf.dart @@ -5,8 +5,13 @@ Future extractImagesFromPDF(String pdfFileUri) async { * Extract the images from the PDF with the desired configuration options * Check if the resulting Page Array is returned */ - var params = ExtractImagesFromPdfParams( - pdfFilePath: pdfFileUri + var imagesResult = await ScanbotSdk.pdfImageExtractor.extractImageFiles( + pdfFileUri, ); - var imagesResult = await ScanbotSdk.imageOperations.extractImagesFromPdf(params); -} \ No newline at end of file + if (imagesResult is Ok>) { + print(imagesResult.value); + /** Handle the images */ + } else { + print(imagesResult.toString()); + } +} diff --git a/lib/snippets/document_sdk/introduction_flow_config_snippet.dart b/lib/snippets/document_sdk/introduction_flow_config_snippet.dart index d3b52b5..9c211b0 100644 --- a/lib/snippets/document_sdk/introduction_flow_config_snippet.dart +++ b/lib/snippets/document_sdk/introduction_flow_config_snippet.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; DocumentScanningFlow introductionConfigurationScanningFlow() { // Create the default configuration object. @@ -23,18 +23,19 @@ DocumentScanningFlow introductionConfigurationScanningFlow() { color: ScanbotColor("#000000"), ), ] - ..title = StyledText( - text: "Introduction", - color: ScanbotColor("#000000"), - ); + ..title = StyledText(text: "Introduction", color: ScanbotColor("#000000")); return configuration; } void runDocumentScanner() async { var configuration = introductionConfigurationScanningFlow(); - var documentResult = await ScanbotSdkUiV2.startDocumentScanner(configuration); - // Handle the document if the status is 'OK' - if(documentResult.status == OperationStatus.OK) { + var documentResult = await ScanbotSdk.document.startScanner(configuration); + // Handle the document if the result is 'Ok' + if (documentResult is Ok) { + var documentData = documentResult.value; + print(documentData); + } else { + print(documentResult.toString()); } } diff --git a/lib/snippets/document_sdk/localization_config_snippet.dart b/lib/snippets/document_sdk/localization_config_snippet.dart index 4e75edd..237d551 100644 --- a/lib/snippets/document_sdk/localization_config_snippet.dart +++ b/lib/snippets/document_sdk/localization_config_snippet.dart @@ -1,18 +1,23 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; DocumentScanningFlow localizationConfigurationFlowSnippet() { return DocumentScanningFlow() - // Configure the strings. - ..localization.cameraTopBarTitle = "document.camera.title" - ..localization.reviewScreenSubmitButtonTitle = "review.submit.title" - ..localization.cameraUserGuidanceNoDocumentFound = "camera.userGuidance.noDocumentFound" - ..localization.cameraUserGuidanceTooDark = "camera.userGuidance.tooDark"; + // Configure the strings. + ..localization.cameraTopBarTitle = "document.camera.title" + ..localization.reviewScreenSubmitButtonTitle = "review.submit.title" + ..localization.cameraUserGuidanceNoDocumentFound = + "camera.userGuidance.noDocumentFound" + ..localization.cameraUserGuidanceTooDark = "camera.userGuidance.tooDark"; } void runDocumentScanner() async { var configuration = localizationConfigurationFlowSnippet(); - var documentResult = await ScanbotSdkUiV2.startDocumentScanner(configuration); - // Handle the document if the status is 'OK' - if(documentResult.status == OperationStatus.OK) { + var documentResult = await ScanbotSdk.document.startScanner(configuration); + // Handle the document if the result is 'Ok' + if (documentResult is Ok) { + var documentData = documentResult.value; + print(documentData); + } else { + print(documentResult.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/document_sdk/migration/create_document_from_legacy_pages.dart b/lib/snippets/document_sdk/migration/create_document_from_legacy_pages.dart index 11c4c46..af22f49 100644 --- a/lib/snippets/document_sdk/migration/create_document_from_legacy_pages.dart +++ b/lib/snippets/document_sdk/migration/create_document_from_legacy_pages.dart @@ -5,10 +5,17 @@ Future createDocumentWithLegacyPages(List pages) async { * Create a document with a UUID * Add pages to the document from 'legacy' pages */ - var params = DocumentFromLegacyPagesParams(pages: pages); - var documentData = await ScanbotSdk.document.createDocumentFromLegacyPages(params); + var documentResult = await ScanbotSdk.document.createDocumentFromLegacyPages( + pages, + ); + if (documentResult is Ok) { + var documentData = documentResult.value; + print(documentData); + } else { + print(documentResult.toString()); + } /** * Now you may delete the files corresponding to the Page to free up storage. - * Use ScanbotSDK.removePage(page) to remove the old pages + * Use ScanbotSdk.legacyPage.removePage(page) or ScanbotSdk.legacyPage.removeAllPages() to remove the old pages */ -} \ No newline at end of file +} diff --git a/lib/snippets/document_sdk/migration/cropping_screen/v1.dart b/lib/snippets/document_sdk/migration/cropping_screen/v1.dart deleted file mode 100644 index 73957f8..0000000 --- a/lib/snippets/document_sdk/migration/cropping_screen/v1.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:flutter/material.dart' show Colors; -import 'package:scanbot_sdk/scanbot_sdk_ui.dart'; - -Future croppingScreen(Page page) async{ - var configuration = CroppingScreenConfiguration( - doneButtonTitle: 'Apply', - topBarBackgroundColor: Colors.white, - bottomBarBackgroundColor: Colors.white, - ); - - var pageResult = await ScanbotSdkUi.startCroppingScreen(page, configuration); -} \ No newline at end of file diff --git a/lib/snippets/document_sdk/migration/cropping_screen/v2.dart b/lib/snippets/document_sdk/migration/cropping_screen/v2.dart deleted file mode 100644 index 300b1a4..0000000 --- a/lib/snippets/document_sdk/migration/cropping_screen/v2.dart +++ /dev/null @@ -1,14 +0,0 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; - -Future croppingScreen(String documentID, String pageID) async { - var configuration = CroppingConfiguration( - documentUuid: documentID, - pageUuid: pageID, - ); - // Equivalent to topBarBackgroundColor & bottomBarBackgroundColor: '#ffffff' - configuration.palette.sbColorPrimary = ScanbotColor('#ffffff'); - // Equivalent to doneButtonTitle: 'Apply', - configuration.localization.croppingTopBarConfirmButtonTitle = 'Apply'; - - var documentData = await ScanbotSdkUiV2.startCroppingScreen(configuration); -} \ No newline at end of file diff --git a/lib/snippets/document_sdk/migration/document_scanner/v1.dart b/lib/snippets/document_sdk/migration/document_scanner/v1.dart deleted file mode 100644 index 287f602..0000000 --- a/lib/snippets/document_sdk/migration/document_scanner/v1.dart +++ /dev/null @@ -1,16 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:scanbot_sdk/scanbot_sdk_ui.dart'; - -Future documentScanner() async { - var config = DocumentScannerScreenConfiguration( - ignoreOrientationMismatch: true, - autoSnappingSensitivity: 0.67, - topBarBackgroundColor: Colors.white, - bottomBarBackgroundColor: Colors.white, - textHintOK: "Don't move.\nCapturing document...", - multiPageButtonHidden: true, - multiPageEnabled: false, - ); - - var pageResult = await ScanbotSdkUi.startDocumentScanner(config); -} \ No newline at end of file diff --git a/lib/snippets/document_sdk/migration/document_scanner/v2.dart b/lib/snippets/document_sdk/migration/document_scanner/v2.dart deleted file mode 100644 index cef0928..0000000 --- a/lib/snippets/document_sdk/migration/document_scanner/v2.dart +++ /dev/null @@ -1,48 +0,0 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; - -Future documentScanner() async { - var configuration = DocumentScanningFlow(); - - var cameraScreenConfiguration = configuration.screens.camera; - - // Equivalent to autoSnappingSensitivity: 0.67 - cameraScreenConfiguration.cameraConfiguration.autoSnappingSensitivity = 0.67; - - // Ready-to-Use UI v2 contains an acknowledgment screen to - // verify the captured document with the built-in Document Quality Analyzer. - // You can still disable this step: - cameraScreenConfiguration.acknowledgement.acknowledgementMode = AcknowledgementMode.NONE; - - // When you disable the acknowledgment screen, you can enable the capture feedback, - // there are different options available, for example you can display a checkmark animation: - cameraScreenConfiguration.captureFeedback.snapFeedbackMode = PageSnapFunnelAnimation(); - - // You may hide the import button in the camera screen, if you don't need it: - cameraScreenConfiguration.bottomBar.importButton.visible = false; - - // Equivalent to bottomBarBackgroundColor: '#ffffff', but not recommended: - configuration.appearance.bottomBarBackgroundColor = ScanbotColor('#ffffff'); - - // However, now all the colors can be conveniently set using the Palette object: - var palette = configuration.palette; - palette.sbColorPrimary = ScanbotColor('#ffffff'); - palette.sbColorOnPrimary = ScanbotColor('#ffffff'); - // .. - - // Now all the text resources are in the localization object - var localization = configuration.localization; - // Equivalent to textHintOK: "Don't move.\nCapturing document...", - localization.cameraUserGuidanceReadyToCapture = - "Don't move. Capturing document..."; - - // Ready-to-Use UI v2 contains a review screen, you can disable it: - configuration.screens.review.enabled = false; - - // Multi Page button is always hidden in RTU v2 - // Therefore multiPageButtonHidden: true is not available - - // Equivalent to multiPageEnabled: false - configuration.outputSettings.pagesScanLimit = 1; - - var documentData = await ScanbotSdkUiV2.startDocumentScanner(configuration); -} \ No newline at end of file diff --git a/lib/snippets/document_sdk/migration/finder_document_scanner/v1.dart b/lib/snippets/document_sdk/migration/finder_document_scanner/v1.dart deleted file mode 100644 index d96bed0..0000000 --- a/lib/snippets/document_sdk/migration/finder_document_scanner/v1.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:scanbot_sdk/scanbot_sdk_ui.dart'; - -Future finderDocumentScanner() async { - var configuration = FinderDocumentScannerConfiguration( - topBarBackgroundColor: Colors.white, - shutterButtonHidden: true, - // finderAspectRatio: AspectRatio(width: 3, height: 4), - ); - - var pageResult = await ScanbotSdkUi.startFinderDocumentScanner(configuration); -} \ No newline at end of file diff --git a/lib/snippets/document_sdk/migration/finder_document_scanner/v2.dart b/lib/snippets/document_sdk/migration/finder_document_scanner/v2.dart deleted file mode 100644 index eb23991..0000000 --- a/lib/snippets/document_sdk/migration/finder_document_scanner/v2.dart +++ /dev/null @@ -1,30 +0,0 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; - -Future finderDocumentScanner() async { - var configuration = DocumentScanningFlow(); - - //Equivalent to topBarBackgroundColor: '#ffffff', using palete - var palette = configuration.palette; - palette.sbColorPrimary = ScanbotColor('#ffffff'); - palette.sbColorOnPrimary = ScanbotColor('#0027ff'); - // .. - - var cameraScreenConfiguration = configuration.screens.camera; - - var viewFinder = cameraScreenConfiguration.viewFinder; - viewFinder.visible = true; - // viewFinder.aspectRatio = AspectRatio(width: 3, height: 4); - - var bottomBar = cameraScreenConfiguration.bottomBar; - bottomBar.previewButton = NoButtonMode(); - bottomBar.autoSnappingModeButton.visible = false; - bottomBar.importButton.visible = false; - - cameraScreenConfiguration.acknowledgement.acknowledgementMode = AcknowledgementMode.NONE; - cameraScreenConfiguration.captureFeedback.snapFeedbackMode = PageSnapFunnelAnimation(); - - configuration.screens.review.enabled = false; - configuration.outputSettings.pagesScanLimit = 1; - - var documentData = await ScanbotSdkUiV2.startDocumentScanner(configuration); -} \ No newline at end of file diff --git a/lib/snippets/document_sdk/multi_page_scanning_snippet.dart b/lib/snippets/document_sdk/multi_page_scanning_snippet.dart index 2b1ebe2..e6fe880 100644 --- a/lib/snippets/document_sdk/multi_page_scanning_snippet.dart +++ b/lib/snippets/document_sdk/multi_page_scanning_snippet.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; DocumentScanningFlow multiPageScanningFlow() { // Create the default configuration object. @@ -12,16 +12,20 @@ DocumentScanningFlow multiPageScanningFlow() { // Hide/Reveal the auto snapping enable/disable button configuration.screens.camera.bottomBar.autoSnappingModeButton.visible = true; - configuration.screens.camera.bottomBar.manualSnappingModeButton.visible = true; + configuration.screens.camera.bottomBar.manualSnappingModeButton.visible = + true; // Set colors configuration.palette.sbColorPrimary = ScanbotColor("#C8193CFF"); configuration.palette.sbColorOnPrimary = ScanbotColor('#ffffff'); // Configure the hint texts for different scenarios - configuration.screens.camera.userGuidance.statesTitles.tooDark = 'Need more lighting to detect a document'; - configuration.screens.camera.userGuidance.statesTitles.tooSmall = 'Document too small'; - configuration.screens.camera.userGuidance.statesTitles.noDocumentFound = 'Could not detect a document'; + configuration.screens.camera.userGuidance.statesTitles.tooDark = + 'Need more lighting to detect a document'; + configuration.screens.camera.userGuidance.statesTitles.tooSmall = + 'Document too small'; + configuration.screens.camera.userGuidance.statesTitles.noDocumentFound = + 'Could not detect a document'; // Enable/Disable the review screen. configuration.screens.review.enabled = true; @@ -36,7 +40,8 @@ DocumentScanningFlow multiPageScanningFlow() { // Configure `more` popup on review screen configuration.screens.review.morePopup.reorderPages.icon.visible = true; configuration.screens.review.morePopup.deleteAll.icon.visible = true; - configuration.screens.review.morePopup.deleteAll.title.text = 'Delete all pages'; + configuration.screens.review.morePopup.deleteAll.title.text = + 'Delete all pages'; // Configure reorder pages screen configuration.screens.reorderPages.topBarTitle.text = 'Reorder Pages'; @@ -53,8 +58,12 @@ DocumentScanningFlow multiPageScanningFlow() { void runDocumentScanner() async { var configuration = multiPageScanningFlow(); - var documentResult = await ScanbotSdkUiV2.startDocumentScanner(configuration); - // Handle the document if the status is 'OK' - if(documentResult.status == OperationStatus.OK) { + var documentResult = await ScanbotSdk.document.startScanner(configuration); + // Handle the document if the result is 'Ok' + if (documentResult is Ok) { + var documentData = documentResult.value; + print(documentData); + } else { + print(documentResult.toString()); } } diff --git a/lib/snippets/document_sdk/palette_config_snippet.dart b/lib/snippets/document_sdk/palette_config_snippet.dart index efd420b..cdf682b 100644 --- a/lib/snippets/document_sdk/palette_config_snippet.dart +++ b/lib/snippets/document_sdk/palette_config_snippet.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; DocumentScanningFlow palleteConfigurationFlowSnippet() { return DocumentScanningFlow() @@ -23,8 +23,12 @@ DocumentScanningFlow palleteConfigurationFlowSnippet() { void runDocumentScanner() async { var configuration = palleteConfigurationFlowSnippet(); - var documentResult = await ScanbotSdkUiV2.startDocumentScanner(configuration); - // Handle the document if the status is 'OK' - if(documentResult.status == OperationStatus.OK) { + var documentResult = await ScanbotSdk.document.startScanner(configuration); + // Handle the document if the result is 'Ok' + if (documentResult is Ok) { + var documentData = documentResult.value; + print(documentData); + } else { + print(documentResult.toString()); } -} \ No newline at end of file +} diff --git a/lib/snippets/document_sdk/reorder_screen_snippet.dart b/lib/snippets/document_sdk/reorder_screen_snippet.dart index 2f4f80e..d96e986 100644 --- a/lib/snippets/document_sdk/reorder_screen_snippet.dart +++ b/lib/snippets/document_sdk/reorder_screen_snippet.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; void reorderScreen() async { // Create the default configuration object. @@ -16,8 +16,12 @@ void reorderScreen() async { reorderScreenConfiguration.pageTextStyle.color = ScanbotColor('#000000'); // Start the Document Scanner UI - var documentResult = await ScanbotSdkUiV2.startDocumentScanner(configuration); - // Handle the document if the status is 'OK' - if(documentResult.status == OperationStatus.OK) { + var documentResult = await ScanbotSdk.document.startScanner(configuration); + // Handle the document if the result is 'Ok' + if (documentResult is Ok) { + var documentData = documentResult.value; + print(documentData); + } else { + print(documentResult.toString()); } } diff --git a/lib/snippets/document_sdk/review_flow_config_snippet.dart b/lib/snippets/document_sdk/review_flow_config_snippet.dart index 3147028..054bf36 100644 --- a/lib/snippets/document_sdk/review_flow_config_snippet.dart +++ b/lib/snippets/document_sdk/review_flow_config_snippet.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; DocumentScanningFlow createDocumentScanningFlowConfiguration() { // Create the default configuration object. @@ -27,8 +27,12 @@ DocumentScanningFlow createDocumentScanningFlowConfiguration() { void runDocumentScanner() async { var configuration = createDocumentScanningFlowConfiguration(); - var documentResult = await ScanbotSdkUiV2.startDocumentScanner(configuration); - // Handle the document if the status is 'OK' - if(documentResult.status == OperationStatus.OK) { + var documentResult = await ScanbotSdk.document.startScanner(configuration); + // Handle the document if the result is 'Ok' + if (documentResult is Ok) { + var documentData = documentResult.value; + print(documentData); + } else { + print(documentResult.toString()); } } diff --git a/lib/snippets/document_sdk/scanning_screen_flow_config_snippet.dart b/lib/snippets/document_sdk/scanning_screen_flow_config_snippet.dart index e28abf5..64105c0 100644 --- a/lib/snippets/document_sdk/scanning_screen_flow_config_snippet.dart +++ b/lib/snippets/document_sdk/scanning_screen_flow_config_snippet.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; DocumentScanningFlow scanningScreenConfigurationScanningFlow() { // Create the default configuration object. @@ -24,17 +24,14 @@ DocumentScanningFlow scanningScreenConfigurationScanningFlow() { ..topUserGuidance.visible = true ..topUserGuidance.background.fillColor = ScanbotColor("#4A000000") ..topUserGuidance.title.text = "Scan your document" - // Configure the bottom user guidance. ..userGuidance.visibility = UserGuidanceVisibility.ENABLED ..userGuidance.background.fillColor = ScanbotColor("#4A000000") ..userGuidance.title.text = "Please hold your device over a document" - // Configure the the scanning assistance overlay. ..scanAssistanceOverlay.visible = true ..scanAssistanceOverlay.backgroundColor = ScanbotColor("#4A000000") ..scanAssistanceOverlay.foregroundColor = ScanbotColor("#FFFFFF") - // Configure the title of the bottom user guidance for different states. ..userGuidance.statesTitles.noDocumentFound = "No Document" ..userGuidance.statesTitles.badAspectRatio = "Bad Aspect Ratio" @@ -46,45 +43,45 @@ DocumentScanningFlow scanningScreenConfigurationScanningFlow() { ..userGuidance.statesTitles.energySaveMode = "Energy save mode is active" ..userGuidance.statesTitles.readyToCapture = "Ready to capture" ..userGuidance.statesTitles.capturing = "Capturing the document" - // The title of the user guidance when the document is ready to be captured in manual mode. - ..userGuidance.statesTitles.captureManual = "The document is ready to be captured" - + ..userGuidance.statesTitles.captureManual = + "The document is ready to be captured" // Import button is used to import an image from the gallery. ..bottomBar.importButton.visible = true ..bottomBar.importButton.title.visible = true ..bottomBar.importButton.title.text = "Import" - // Configure the auto/manual snap button. ..bottomBar.autoSnappingModeButton.title.visible = true ..bottomBar.autoSnappingModeButton.title.text = "Auto" ..bottomBar.manualSnappingModeButton.title.visible = true ..bottomBar.manualSnappingModeButton.title.text = "Manual" - // Configure the torch off/on button. ..bottomBar.torchOnButton.title.visible = true ..bottomBar.torchOnButton.title.text = "On" ..bottomBar.torchOffButton.title.visible = true ..bottomBar.torchOffButton.title.text = "Off" - // MARK: Configure the document capture feedback. // Configure the camera blink behavior when an image is captured. ..captureFeedback.cameraBlinkEnabled = true - // Configure the animation mode. You can choose between a checkmark animation or a document funnel animation. // Configure the checkmark animation. You can use the default colors or set your own desired colors for the checkmark. - ..captureFeedback.snapFeedbackMode = PageSnapFeedbackMode.pageSnapCheckMarkAnimation() - + ..captureFeedback.snapFeedbackMode = + PageSnapFeedbackMode.pageSnapCheckMarkAnimation() // Or you can choose the funnel animation. - ..captureFeedback.snapFeedbackMode = PageSnapFeedbackMode.pageSnapFunnelAnimation(); + ..captureFeedback.snapFeedbackMode = + PageSnapFeedbackMode.pageSnapFunnelAnimation(); return configuration; } void runDocumentScanner() async { var configuration = scanningScreenConfigurationScanningFlow(); - var documentResult = await ScanbotSdkUiV2.startDocumentScanner(configuration); - // Handle the document if the status is 'OK' - if(documentResult.status == OperationStatus.OK) { + var documentResult = await ScanbotSdk.document.startScanner(configuration); + // Handle the document if the result is 'Ok' + if (documentResult is Ok) { + var documentData = documentResult.value; + print(documentData); + } else { + print(documentResult.toString()); } } diff --git a/lib/snippets/document_sdk/single_page_scanning_finder_snippet.dart b/lib/snippets/document_sdk/single_page_scanning_finder_snippet.dart index f6dc724..893d519 100644 --- a/lib/snippets/document_sdk/single_page_scanning_finder_snippet.dart +++ b/lib/snippets/document_sdk/single_page_scanning_finder_snippet.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; DocumentScanningFlow singlePageWithFinderScanningFlow() { // Create the default configuration object. @@ -19,24 +19,32 @@ DocumentScanningFlow singlePageWithFinderScanningFlow() { // Hide the auto snapping enable/disable button configuration.screens.camera.bottomBar.autoSnappingModeButton.visible = false; - configuration.screens.camera.bottomBar.manualSnappingModeButton.visible = false; + configuration.screens.camera.bottomBar.manualSnappingModeButton.visible = + false; // Set colors configuration.palette.sbColorPrimary = ScanbotColor("#C8193CFF"); configuration.palette.sbColorOnPrimary = ScanbotColor('#ffffff'); // Configure the hint texts for different scenarios - configuration.screens.camera.userGuidance.statesTitles.tooDark = 'Need more lighting to detect a document'; - configuration.screens.camera.userGuidance.statesTitles.tooSmall = 'Document too small'; - configuration.screens.camera.userGuidance.statesTitles.noDocumentFound = 'Could not detect a document'; + configuration.screens.camera.userGuidance.statesTitles.tooDark = + 'Need more lighting to detect a document'; + configuration.screens.camera.userGuidance.statesTitles.tooSmall = + 'Document too small'; + configuration.screens.camera.userGuidance.statesTitles.noDocumentFound = + 'Could not detect a document'; return configuration; } void runDocumentScanner() async { var configuration = singlePageWithFinderScanningFlow(); - var documentResult = await ScanbotSdkUiV2.startDocumentScanner(configuration); - // Handle the document if the status is 'OK' - if(documentResult.status == OperationStatus.OK) { + var documentResult = await ScanbotSdk.document.startScanner(configuration); + // Handle the document if the result is 'Ok' + if (documentResult is Ok) { + var documentData = documentResult.value; + print(documentData); + } else { + print(documentResult.toString()); } } diff --git a/lib/snippets/document_sdk/single_page_scanning_snippet.dart b/lib/snippets/document_sdk/single_page_scanning_snippet.dart index 3983a5b..eea6b0c 100644 --- a/lib/snippets/document_sdk/single_page_scanning_snippet.dart +++ b/lib/snippets/document_sdk/single_page_scanning_snippet.dart @@ -1,4 +1,4 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; DocumentScanningFlow singlePageScanningFlow() { // Create the default configuration object. @@ -17,13 +17,16 @@ DocumentScanningFlow singlePageScanningFlow() { * Note: Both modes can be further configured to your liking * E.g., for genie animation */ - configuration.screens.camera.captureFeedback.snapFeedbackMode = PageSnapFunnelAnimation(); + configuration.screens.camera.captureFeedback.snapFeedbackMode = + PageSnapFunnelAnimation(); // or for checkmark animation - configuration.screens.camera.captureFeedback.snapFeedbackMode = PageSnapCheckMarkAnimation(); + configuration.screens.camera.captureFeedback.snapFeedbackMode = + PageSnapCheckMarkAnimation(); // Hide the auto snapping enable/disable button configuration.screens.camera.bottomBar.autoSnappingModeButton.visible = false; - configuration.screens.camera.bottomBar.manualSnappingModeButton.visible = false; + configuration.screens.camera.bottomBar.manualSnappingModeButton.visible = + false; configuration.screens.camera.bottomBar.importButton.title.visible = true; configuration.screens.camera.bottomBar.torchOnButton.title.visible = true; configuration.screens.camera.bottomBar.torchOffButton.title.visible = true; @@ -33,17 +36,24 @@ DocumentScanningFlow singlePageScanningFlow() { configuration.palette.sbColorOnPrimary = ScanbotColor('#ffffff'); // Configure the hint texts for different scenarios - configuration.screens.camera.userGuidance.statesTitles.tooDark = 'Need more lighting to detect a document'; - configuration.screens.camera.userGuidance.statesTitles.tooSmall = 'Document too small'; - configuration.screens.camera.userGuidance.statesTitles.noDocumentFound = 'Could not detect a document'; + configuration.screens.camera.userGuidance.statesTitles.tooDark = + 'Need more lighting to detect a document'; + configuration.screens.camera.userGuidance.statesTitles.tooSmall = + 'Document too small'; + configuration.screens.camera.userGuidance.statesTitles.noDocumentFound = + 'Could not detect a document'; return configuration; } void runDocumentScanner() async { var configuration = singlePageScanningFlow(); - var documentResult = await ScanbotSdkUiV2.startDocumentScanner(configuration); - // Handle the document if the status is 'OK' - if(documentResult.status == OperationStatus.OK) { + var documentResult = await ScanbotSdk.document.startScanner(configuration); + // Handle the document if the result is 'Ok' + if (documentResult is Ok) { + var documentData = documentResult.value; + print(documentData); + } else { + print(documentResult.toString()); } } diff --git a/lib/snippets/document_sdk/start_scanning_snippet.dart b/lib/snippets/document_sdk/start_scanning_snippet.dart index 9ff1816..6d03b1f 100644 --- a/lib/snippets/document_sdk/start_scanning_snippet.dart +++ b/lib/snippets/document_sdk/start_scanning_snippet.dart @@ -1,11 +1,15 @@ -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; void startScanning() async { // Create the default configuration object. var configuration = DocumentScanningFlow(); - var documentResult = await ScanbotSdkUiV2.startDocumentScanner(configuration); - // Handle the document if the status is 'OK' - if(documentResult.status == OperationStatus.OK) { + var documentResult = await ScanbotSdk.document.startScanner(configuration); + // Handle the document if the result is 'Ok' + if (documentResult is Ok) { + var documentData = documentResult.value; + print(documentData); + } else { + print(documentResult.toString()); } } diff --git a/lib/snippets/image_refs/create_image_ref_from_encoded_buffer.dart b/lib/snippets/image_refs/create_image_ref_from_encoded_buffer.dart new file mode 100644 index 0000000..259e986 --- /dev/null +++ b/lib/snippets/image_refs/create_image_ref_from_encoded_buffer.dart @@ -0,0 +1,23 @@ +import 'dart:math'; +import 'dart:typed_data'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; + +void createImageRefFromEncodedBuffer(Uint8List bytes) { + autorelease(() { + // Create ImageRef from buffer + var imageRef = ImageRef.fromEncodedBuffer(bytes); + + // Create ImageRef from buffer with options + var imageRefWithOptions = ImageRef.fromEncodedBuffer( + bytes, + options: BufferImageLoadOptions( + // Define crop rectangle + cropRect: const Rectangle(0, 0, 200, 200), + // Convert image to grayscale + colorConversion: ColorConversion.GRAY, + // Use lazy loading mode, image would be loaded into memory only when first used + loadMode: BufferLoadMode.LAZY, + ), + ); + }); +} diff --git a/lib/snippets/image_refs/create_image_ref_from_path.dart b/lib/snippets/image_refs/create_image_ref_from_path.dart new file mode 100644 index 0000000..a754521 --- /dev/null +++ b/lib/snippets/image_refs/create_image_ref_from_path.dart @@ -0,0 +1,26 @@ +import 'dart:math'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; + +void createImageRefFromPath(String imagePath) { + autorelease(() { + // Create ImageRef from path + var imageRef = ImageRef.fromPath(imagePath); + + // Create ImageRef from path with options + var imageRefWithOptions = ImageRef.fromPath( + imagePath, + options: PathImageLoadOptions( + // Define crop rectangle + cropRect: const Rectangle(0, 0, 200, 200), + // Convert image to grayscale + colorConversion: ColorConversion.GRAY, + // Use lazy loading mode, image would be loaded into memory only when first used + loadMode: PathLoadMode.LAZY_WITH_COPY, + // handle encryption automatically based on global ImageRef/ScanbotSdk encryption settings + encryptionMode: EncryptionMode.AUTO, + // to disable decryption while reading for this specific file (in case its not encrypted with SDK encryption ON), use + // encryptionMode: EncryptionMode.DISABLED, + ), + ); + }); +} diff --git a/lib/snippets/image_refs/get_image_info.dart b/lib/snippets/image_refs/get_image_info.dart new file mode 100644 index 0000000..69e1341 --- /dev/null +++ b/lib/snippets/image_refs/get_image_info.dart @@ -0,0 +1,12 @@ +import 'package:scanbot_sdk/scanbot_sdk.dart'; + +ImageInfo getImageInfo(ImageRef imageRef) { + var imageInfo = imageRef.info(); + + var width = imageInfo.width; + var height = imageInfo.height; + // size on disk or in memory depending on load mode + var maxByteSize = imageInfo.maxByteSize; + + return imageInfo; +} diff --git a/lib/snippets/image_refs/save_image.dart b/lib/snippets/image_refs/save_image.dart new file mode 100644 index 0000000..83c781d --- /dev/null +++ b/lib/snippets/image_refs/save_image.dart @@ -0,0 +1,16 @@ +import 'package:scanbot_sdk/scanbot_sdk.dart'; + +void saveImage(ImageRef imageRef, String destinationPath) { + imageRef.saveImage( + destinationPath, + options: SaveImageOptions( + quality: 100, + encryptionMode: EncryptionMode.AUTO, + // to disable decryption while saving this specific file, use + // encryptionMode: EncryptionMode.DISABLED, + ), + ); + + // Returns the stored image as a byte array. + final byteArray = imageRef.encodeImage(); +} diff --git a/lib/snippets/initialization/custom_storage.dart b/lib/snippets/initialization/custom_storage.dart new file mode 100644 index 0000000..f36a4cd --- /dev/null +++ b/lib/snippets/initialization/custom_storage.dart @@ -0,0 +1,14 @@ +import 'package:path_provider/path_provider.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; + +Future initialize() async { + var directory = await getApplicationSupportDirectory(); + var storageBaseDirectory = '${directory.path}/my-custom-storage'; + + var config = SdkConfiguration( + licenseKey: "", + storageBaseDirectory: storageBaseDirectory, + ); + + await ScanbotSdk.initialize(config); +} diff --git a/lib/snippets/initialization/encryption.dart b/lib/snippets/initialization/encryption.dart new file mode 100644 index 0000000..4cbd927 --- /dev/null +++ b/lib/snippets/initialization/encryption.dart @@ -0,0 +1,11 @@ +import 'package:scanbot_sdk/scanbot_sdk.dart'; + +Future initialize() async { + var config = SdkConfiguration( + licenseKey: "", + fileEncryptionPassword: 'SomeSecretPa\$\$w0rdForFileEncryption', + fileEncryptionMode: FileEncryptionMode.AES256, + ); + + await ScanbotSdk.initialize(config); +} diff --git a/lib/snippets/initialization/image_quality.dart b/lib/snippets/initialization/image_quality.dart new file mode 100644 index 0000000..0cdea1a --- /dev/null +++ b/lib/snippets/initialization/image_quality.dart @@ -0,0 +1,11 @@ +import 'package:scanbot_sdk/scanbot_sdk.dart'; + +Future initialize() async { + var config = SdkConfiguration( + licenseKey: "", + storageImageFormat: StorageImageFormat.JPG, + storageImageQuality: 80, + ); + + await ScanbotSdk.initialize(config); +} diff --git a/lib/snippets/initialization/license.dart b/lib/snippets/initialization/license.dart new file mode 100644 index 0000000..c151465 --- /dev/null +++ b/lib/snippets/initialization/license.dart @@ -0,0 +1,22 @@ +import 'package:scanbot_sdk/scanbot_sdk.dart'; + +Future initialize() async { + // Please note: this is just an example license key string (it is not a valid license) + var licenseKey = "fXbN2PmyqEAZ+btdkSIS36TuX2j/EE5qxVNcZMXYErbLQ" + + "3OBnE10aOQxYI8L4UKwHiZ63jthvoFwUevttctBk0wVJ7Z" + + "+Psz3/Ry8w7pXvfpB1o+JrnzGGcfwBnRi/5raQ2THDeokR" + + "RB1keky2VBOFYbCfYt3Hqms5txF2z70PE/SBTMTIVuxL7q" + + "1xcHDHclbEBriDtrHw8Pmhh9FqTg/r/4kRN/oEX37QGp+Y" + + "3ogwIBbSmV+Cv+VuwtI31uXY3/GkyN/pSJZspIl+exwQDv" + + "O0O1/R/oAURpfM4ydaWReRJtjW8+b1r9rUgPERguaXfcse" + + "HlnclItgDfBHzUUFJJU/g==\nU2NhbmJvdFNESwppby5zY" + + "2FuYm90LmRlbW8ueGFtYXJpbgoxNDg0NjExMTk5CjcxNjc" + + "KMw==\n"; + + var config = SdkConfiguration( + licenseKey: licenseKey, + loggingEnabled: true, + ); + + await ScanbotSdk.initialize(config); +} diff --git a/lib/snippets/initialization/logging.dart b/lib/snippets/initialization/logging.dart new file mode 100644 index 0000000..57a10ec --- /dev/null +++ b/lib/snippets/initialization/logging.dart @@ -0,0 +1,10 @@ +import 'package:scanbot_sdk/scanbot_sdk.dart'; + +Future initialize() async { + var config = SdkConfiguration( + licenseKey: "", + loggingEnabled: true, + ); + + await ScanbotSdk.initialize(config); +} diff --git a/lib/snippets/mock_camera.dart b/lib/snippets/mock_camera.dart index b86c912..e68ddc3 100644 --- a/lib/snippets/mock_camera.dart +++ b/lib/snippets/mock_camera.dart @@ -1,14 +1,11 @@ - import 'package:scanbot_sdk/scanbot_sdk.dart'; Future mockCamera() async { - var config = MockCameraParams(imageFileUri: "{path to your image file}"); - /** * For Android: * API >= 33, READ_MEDIA_IMAGES and READ_MEDIA_VIDEO permissions are required. * API < 33, READ_EXTERNAL_STORAGE permission is required. * The image must have even values for both width and height. */ - await ScanbotSdk.mockCamera(config); -} \ No newline at end of file + await ScanbotSdk.mockCamera("{path to your image file}"); +} diff --git a/lib/snippets/read_image_data.dart b/lib/snippets/read_image_data.dart new file mode 100644 index 0000000..fbdd212 --- /dev/null +++ b/lib/snippets/read_image_data.dart @@ -0,0 +1,16 @@ +import 'dart:convert'; +import 'dart:typed_data'; + +import 'package:flutter/widgets.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; + +Future readImageData(String imageFileUri) async { + final result = await ScanbotSdk.imageProcessor.readImageData(imageFileUri); + + if (result is Ok) { + Uint8List bytes = base64Decode(result.value); + + // use image widget to show preview + final image = Image.memory(bytes); + } +} diff --git a/lib/storage/_legacy_pages_repository.dart b/lib/storage/_legacy_pages_repository.dart deleted file mode 100644 index 90da51a..0000000 --- a/lib/storage/_legacy_pages_repository.dart +++ /dev/null @@ -1,85 +0,0 @@ -import 'dart:convert'; - -import 'package:scanbot_sdk/scanbot_sdk.dart'; -import 'package:shared_preferences/shared_preferences.dart'; - -class LegacyPageRepository { - static final LegacyPageRepository _instance = LegacyPageRepository._internal(); - - factory LegacyPageRepository() => _instance; - - LegacyPageRepository._internal() { - // init some stuff here - } - - final List _pages = []; - - List get pages => _pages.toList(); - - Future removePage(Page pageToRemove) async { - _pages.remove(pageToRemove); - await _storePages(); - } - - Future addPages(List newPages) async { - _pages.addAll(newPages); - await _storePages(); - } - - Future clearPages() async { - _pages.clear(); - await _storePages(); - } - - Future updatePage(Page page) async { - _pages.removeWhere((e) => page.pageId == e.pageId); - _pages.add(page); - await _storePages(); - } - - Future nextPage(Page page) async { - final index = _pages.indexOf(page); - if (index == -1) { - return page; - } - if (index + 1 < _pages.length) { - return _pages[index + 1]; - } - if (index + 1 == _pages.length) { - return _pages[0]; - } - return page; - } - - Future addPage(Page page) async { - _pages.add(page); - await _storePages(); - } - - Future loadPages() async { - final db = await _getDbInstance(); - var pagesJsonString = db.getString('pages'); - if (pagesJsonString == null) { - return; - } - List pagesJson = jsonDecode(pagesJsonString); - final loadedPages = - pagesJson.map((p) => Page.fromJson(p as Map)).toList(); - _pages.clear(); - if (loadedPages.isNotEmpty) { - var refreshPages = await ScanbotSdk.refreshImageUris( - loadedPages.map((e) => Page(e.pageId)).toList()); - _pages.addAll(refreshPages); - } - } - - Future _storePages() async { - final db = await _getDbInstance(); - await db.setString('pages', jsonEncode(_pages)); - } - - Future _getDbInstance() async { - // TODO use a SQLite DB based storage instead of SharedPreferences - return SharedPreferences.getInstance(); - } -} diff --git a/lib/ui/_legacy_operations_page_widget.dart b/lib/ui/_legacy_operations_page_widget.dart deleted file mode 100644 index 938e8e7..0000000 --- a/lib/ui/_legacy_operations_page_widget.dart +++ /dev/null @@ -1,237 +0,0 @@ -import 'dart:async'; - -import 'package:flutter/material.dart'; - -import 'package:logging/logging.dart'; -import 'package:scanbot_sdk/scanbot_sdk.dart'; -import 'package:scanbot_sdk/scanbot_sdk.dart' as sdk; -import 'package:scanbot_sdk/scanbot_sdk_ui.dart'; -import 'package:scanbot_sdk_example_flutter/ui/progress_dialog.dart'; -import 'package:scanbot_sdk_example_flutter/utility/utils.dart'; - -import '../classic_components/cropping_custom_ui.dart'; -import '../storage/_legacy_pages_repository.dart'; -import 'filter_page/filter_page_widget.dart'; -import 'pages_widget.dart'; - -class LegacyPageOperations extends StatefulWidget { - final sdk.Page initialPage; - - LegacyPageOperations(this.initialPage); - - @override - _LegacyPageOperationsState createState() => _LegacyPageOperationsState(); -} - -class _LegacyPageOperationsState extends State { - final LegacyPageRepository _pageRepository = LegacyPageRepository(); - late sdk.Page _page; - bool showProgressBar = false; - - @override - void initState() { - super.initState(); - _page = widget.initialPage; - } - - Future _updatePage(sdk.Page pageUpdated) async { - setState(() { - showProgressBar = true; - }); - await _pageRepository.updatePage(pageUpdated); - setState(() { - showProgressBar = false; - _page = pageUpdated; - }); - } - - @override - Widget build(BuildContext context) { - // Determine which widget to display based on encryption requirement - final imageUri = _page.documentPreviewImageFileUri!; - final pageView = shouldInitWithEncryption - ? EncryptedPageWidget(imageUri) - : PageWidget(imageUri); - - return Scaffold( - appBar: ScanbotAppBar('Image Preview', context: context, showBackButton: true, onBack: () => Navigator.of(context).pop(_page), actions: [ - Padding( - padding: const EdgeInsets.only(right: 20.0), - child: GestureDetector( - onTap: () => _analyzeQuality(), // Action for analyzing quality - child: const Icon( - Icons.image_search, - size: 26.0, - ), - ), - ), - ]), - body: Stack( - children: [ - Column( - children: [ - Expanded( - child: Container( - padding: const EdgeInsets.symmetric(vertical: 8.0), - child: Center(child: pageView), - ), - ), - ], - ), - // Show progress bar if `showProgressBar` is true - if (showProgressBar) - const Center( - child: SizedBox( - width: 100, - height: 100, - child: CircularProgressIndicator( - strokeWidth: 10, - ), - ), - ), - ], - ), - bottomNavigationBar: BottomAppBar( - padding: const EdgeInsets.all(8.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - _buildOptionButton( - icon: Icons.crop, - label: 'RTU Crop', - onPressed: () => _startCroppingScreen(), - ), - _buildOptionButton( - icon: Icons.crop, - label: 'Classic Crop', - onPressed: () => _startCustomUiCroppingScreen(), - ), - _buildOptionButton( - icon: Icons.filter, - label: 'Filter', - onPressed: () => _showFilterPage(), - ), - _buildOptionButton( - icon: Icons.delete, - label: 'Delete', - iconColor: Colors.red, - labelColor: Colors.red, - onPressed: () => _deletePage(), - ), - ], - ), - ), - ); - } - - Widget _buildOptionButton({ - required IconData icon, - required String label, - required VoidCallback onPressed, - Color iconColor = Colors.black, - Color labelColor = Colors.black, - }) { - return TextButton( - onPressed: onPressed, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon(icon, color: iconColor), - const SizedBox(height: 4), - Text( - label, - style: TextStyle(color: labelColor), - ), - ], - ), - ); - } - - Future _deletePage() async { - try { - await ScanbotSdk.deletePage(_page); - await _pageRepository.removePage(_page); - Navigator.of(context).pop(); - } catch (e) { - print(e); - } - } - - Future _showFilterPage() async { - if (!await checkLicenseStatus(context)) { - return; - } - - var resultPage = await Navigator.of(context).push( - MaterialPageRoute(builder: (context) => PageFiltering(_page)), - ); - - if (resultPage != null) { - await _updatePage(resultPage); - } - } - - Future _startCroppingScreen() async { - if (!await checkLicenseStatus(context)) { - return; - } - - try { - final config = CroppingScreenConfiguration( - bottomBarBackgroundColor: Colors.blue, - // polygonColor: Colors.yellow, - // polygonLineWidth: 10, - cancelButtonTitle: 'Cancel', - doneButtonTitle: 'Save', - // See further configs ... - ); - final result = await ScanbotSdkUi.startCroppingScreen(_page, config); - if (result.operationResult == OperationStatus.OK && result.page != null) { - await _updatePage(result.page!); - } - } catch (e) { - print(e); - } - } - - Future _startCustomUiCroppingScreen() async { - if (!await checkLicenseStatus(context)) { - return; - } - - try { - var newPage = await Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => CroppingScreenWidget(page: _page)), - ); - await _updatePage(newPage!); - } catch (e) { - print(e); - } - } - - Future _analyzeQuality() async { - if (!await checkLicenseStatus(context)) { - return; - } - var dialog = ProgressDialog(context, - type: ProgressDialogType.Normal, isDismissible: true); - dialog.style(message: 'Analysing ...'); - dialog.show(); - - try { - final result = await ScanbotSdk.analyzeQualityOfDocument(_page, - analyzerImageSizeLimit: Size(width: 2500, height: 2500)); - - await showAlertDialog( - context, - 'Document Quality value is: ${result.quality?.name}', - title: 'Result', - ); - } catch (e) { - Logger.root.severe(e); - } finally { - dialog.hide(); - } - } -} \ No newline at end of file diff --git a/lib/ui/filter_page/filter_button_widget.dart b/lib/ui/filter_page/filter_button_widget.dart index 0130224..0c0eb18 100644 --- a/lib/ui/filter_page/filter_button_widget.dart +++ b/lib/ui/filter_page/filter_button_widget.dart @@ -4,11 +4,8 @@ class FilterButton extends StatelessWidget { final String text; final VoidCallback onPressed; - const FilterButton({ - Key? key, - required this.text, - required this.onPressed, - }) : super(key: key); + const FilterButton({Key? key, required this.text, required this.onPressed}) + : super(key: key); @override Widget build(BuildContext context) { @@ -25,10 +22,7 @@ class FilterButton extends StatelessWidget { fontWeight: FontWeight.bold, ), ), - child: Align( - alignment: Alignment.centerLeft, - child: Text(text), - ), + child: Align(alignment: Alignment.centerLeft, child: Text(text)), ), ); } diff --git a/lib/ui/filter_page/filter_page_widget.dart b/lib/ui/filter_page/filter_page_widget.dart deleted file mode 100644 index 06e1136..0000000 --- a/lib/ui/filter_page/filter_page_widget.dart +++ /dev/null @@ -1,197 +0,0 @@ -import 'dart:typed_data'; -import 'package:flutter/material.dart'; -import 'package:scanbot_sdk/scanbot_sdk.dart' as sdk; -import 'package:scanbot_sdk/scanbot_sdk.dart'; -import 'package:scanbot_sdk_example_flutter/utility/utils.dart'; -import 'filter_button_widget.dart'; - -class PageFiltering extends StatefulWidget { - final sdk.Page initialPage; - - const PageFiltering(this.initialPage, {Key? key}) : super(key: key); - - @override - State createState() => _PageFilteringState(); -} - -class _PageFilteringState extends State { - late sdk.Page _page; - - @override - void initState() { - super.initState(); - _page = widget.initialPage; - } - - void _updatePage(sdk.Page updatedPage) => setState(() => _page = updatedPage); - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: ScanbotAppBar('Filtering', context: context, showBackButton: true, onBack: () => Navigator.of(context).pop(_page)), - body: FilterPreviewWidget(_page, _updatePage), - ); - } -} - -class FilterPreviewWidget extends StatefulWidget { - final sdk.Page page; - final ValueChanged onPageUpdated; - - const FilterPreviewWidget(this.page, this.onPageUpdated, {Key? key}) : super(key: key); - - @override - State createState() => _FilterPreviewWidgetState(); -} - -class _FilterPreviewWidgetState extends State { - late sdk.Page page; - Uri? filteredImageUri; - late ImageFilterType selectedFilter; - - @override - void initState() { - super.initState(); - page = widget.page; - filteredImageUri = page.documentImageFileUri; - selectedFilter = page.filter ?? ImageFilterType.NONE; - } - - Future applyParametricFilters( - sdk.Page page, List filters) async { - if (!await checkLicenseStatus(context)) return; - try { - final filteredPage = await ScanbotSdk.applyImageFilter(page, filters); - setState(() { - this.page = filteredPage; - filteredImageUri = page.documentImageFileUri; - widget.onPageUpdated(filteredPage); - }); - } catch (e) { - print(e); - } - } - - @override - Widget build(BuildContext context) { - return ListView( - padding: const EdgeInsets.all(10.0), - shrinkWrap: true, - children: [ - buildImageContainer(), - ..._buildFilterButtons(), - ], - ); - } - - Widget buildImageContainer() { - return Container( - height: 400, - padding: const EdgeInsets.symmetric(vertical: 8.0), - child: filteredImageUri != null - ? FutureBuilder( - future: ScanbotEncryptionHandler.getDecryptedDataFromFile(filteredImageUri!), - builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.done && - snapshot.data != null) { - return Image.memory(snapshot.data!); - } - return const Center(child: CircularProgressIndicator()); - }, - ) : const Center(child: Text('No image available')), - ); - } - - List _buildFilterButtons() { - return [ - FilterButton( - text: 'None', - onPressed: () => applyParametricFilters(page, [LegacyFilter(filterType: ImageFilterType.NONE.index)]), - ), - FilterButton( - text: 'Color Document Filter', - onPressed: () => applyParametricFilters(page, [ColorDocumentFilter()]), - ), - FilterButton( - text: 'Scanbot Binarization Filter', - onPressed: () => applyParametricFilters(page, [ScanbotBinarizationFilter()]), - ), - FilterButton( - text: 'Custom Binarization Filter', - onPressed: () => applyParametricFilters(page, [CustomBinarizationFilter(preset: BinarizationFilterPreset.PRESET_1)]), - ), - FilterButton( - text: 'Brightness Filter', - onPressed: () => applyParametricFilters(page, [BrightnessFilter(brightness: 0.5)]), - ), - FilterButton( - text: 'Contrast Filter', - onPressed: () => applyParametricFilters(page, [ContrastFilter(contrast: 125.0)]), - ), - FilterButton( - text: 'Grayscale Filter', - onPressed: () => applyParametricFilters(page, [GrayscaleFilter()]), - ), - FilterButton( - text: 'White Black Point Filter', - onPressed: () => applyParametricFilters(page, [WhiteBlackPointFilter(blackPoint: 0.5, whitePoint: 0.5)]), - ), - FilterButton( - text: 'Legacy Color Filter', - onPressed: () => applyParametricFilters(page, [LegacyFilter(filterType: ImageFilterType.COLOR.typeIndex)]), - ), - FilterButton( - text: 'Legacy Grayscale Filter', - onPressed: () => applyParametricFilters(page, [LegacyFilter(filterType: ImageFilterType.GRAYSCALE.typeIndex)]), - ), - FilterButton( - text: 'Legacy Binarized Filter', - onPressed: () => applyParametricFilters(page, [LegacyFilter(filterType: ImageFilterType.BINARIZED.typeIndex)]), - ), - FilterButton( - text: 'Legacy Color Document Filter', - onPressed: () => applyParametricFilters(page, [LegacyFilter(filterType: ImageFilterType.COLOR_DOCUMENT.typeIndex)]), - ), - FilterButton( - text: 'Legacy Pure Binarized Filter', - onPressed: () => applyParametricFilters(page, [LegacyFilter(filterType: ImageFilterType.PURE_BINARIZED.typeIndex)]), - ), - FilterButton( - text: 'Legacy Background Clean Filter', - onPressed: () => applyParametricFilters(page, [LegacyFilter(filterType: ImageFilterType.BACKGROUND_CLEAN.typeIndex)]), - ), - FilterButton( - text: 'Legacy Black & White Filter', - onPressed: () => applyParametricFilters(page, [LegacyFilter(filterType: ImageFilterType.BLACK_AND_WHITE.typeIndex)]), - ), - FilterButton( - text: 'Legacy Otsu Binarization Filter', - onPressed: () => applyParametricFilters(page, [LegacyFilter(filterType: ImageFilterType.OTSU_BINARIZATION.typeIndex)]), - ), - FilterButton( - text: 'Legacy Deep Binarization Filter', - onPressed: () => applyParametricFilters(page, [LegacyFilter(filterType: ImageFilterType.DEEP_BINARIZATION.typeIndex)]), - ), - FilterButton( - text: 'Legacy Edge Highlight Filter', - onPressed: () => applyParametricFilters(page, [LegacyFilter(filterType: ImageFilterType.EDGE_HIGHLIGHT.typeIndex)]), - ), - FilterButton( - text: 'Legacy Low Light Binarization Filter', - onPressed: () => applyParametricFilters(page, [LegacyFilter(filterType: ImageFilterType.LOW_LIGHT_BINARIZATION.typeIndex)]), - ), - FilterButton( - text: 'Legacy Low Light Binarization Filter 2', - onPressed: () => applyParametricFilters(page, [LegacyFilter(filterType: ImageFilterType.LOW_LIGHT_BINARIZATION_2.typeIndex)]), - ), - FilterButton( - text: 'Legacy Sensitive Binarization Filter', - onPressed: () => applyParametricFilters(page, [LegacyFilter(filterType: ImageFilterType.SENSITIVE_BINARIZATION.typeIndex)]), - ), - FilterButton( - text: 'Legacy Pure Gray Filter', - onPressed: () => applyParametricFilters(page, [LegacyFilter(filterType: ImageFilterType.PURE_GRAY.typeIndex)]), - ), - ]; - } -} diff --git a/lib/ui/menu_item_widget.dart b/lib/ui/menu_item_widget.dart index 217da13..4e0f514 100644 --- a/lib/ui/menu_item_widget.dart +++ b/lib/ui/menu_item_widget.dart @@ -20,11 +20,9 @@ class MenuItemWidget extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ ListTile( - leading: startIcon != null - ? Icon(startIcon, color: Colors.black) - : null, - trailing: - endIcon != null ? Icon(endIcon, color: Colors.black) : null, + leading: + startIcon != null ? Icon(startIcon, color: Colors.black) : null, + trailing: endIcon != null ? Icon(endIcon, color: Colors.black) : null, title: Text( title, style: const TextStyle( @@ -54,10 +52,7 @@ class MenuItemWidget extends StatelessWidget { class TitleItemWidget extends StatelessWidget { final String title; - const TitleItemWidget({ - required this.title, - Key? key, - }) : super(key: key); + const TitleItemWidget({required this.title, Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -79,4 +74,3 @@ class TitleItemWidget extends StatelessWidget { ); } } - diff --git a/lib/ui/operations_page_widget.dart b/lib/ui/operations_page_widget.dart index 3ce3a30..738ac96 100644 --- a/lib/ui/operations_page_widget.dart +++ b/lib/ui/operations_page_widget.dart @@ -3,7 +3,6 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter/material.dart' as material; import 'package:scanbot_sdk/scanbot_sdk.dart'; -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; import '../utility/utils.dart'; import 'filter_page/filter_button_widget.dart'; @@ -32,7 +31,7 @@ class _PageOperationsState extends State { @override Widget build(BuildContext context) { // Determine which widget to display based on encryption requirement - final imageUri = Uri(path: _page.documentImagePreviewURI?.replaceFirst('file://', '')); + final imageUri = _page.documentImagePreviewURI!; final pageView = shouldInitWithEncryption ? EncryptedPageWidget(imageUri) : PageWidget(imageUri); @@ -56,9 +55,7 @@ class _PageOperationsState extends State { child: SizedBox( width: 100, height: 100, - child: CircularProgressIndicator( - strokeWidth: 10, - ), + child: CircularProgressIndicator(strokeWidth: 10), ), ), ], @@ -102,10 +99,7 @@ class _PageOperationsState extends State { children: [ Icon(icon, color: Colors.white), const SizedBox(height: 4), - Text( - label, - style: const TextStyle(color: Colors.white), - ), + Text(label, style: const TextStyle(color: Colors.white)), ], ), ); @@ -119,39 +113,51 @@ class _PageOperationsState extends State { padding: const material.EdgeInsets.all(10.0), children: [ FilterButton( - text: 'None', - onPressed: () => applyParametricFilters([LegacyFilter(filterType: ImageFilterType.NONE.index)])), + text: 'None', + onPressed: () => applyParametricFilters([ + LegacyFilter(filterType: ImageFilterType.NONE.index), + ]), + ), FilterButton( - text: 'Color Document Filter', - onPressed: () => applyParametricFilters([ColorDocumentFilter()])), + text: 'Color Document Filter', + onPressed: () => applyParametricFilters([ColorDocumentFilter()]), + ), FilterButton( - text: 'Scanbot Binarization Filter', - onPressed: () => applyParametricFilters([ScanbotBinarizationFilter()])), + text: 'Scanbot Binarization Filter', + onPressed: () => + applyParametricFilters([ScanbotBinarizationFilter()]), + ), FilterButton( - text: 'Custom Binarization Filter', - onPressed: () => applyParametricFilters([CustomBinarizationFilter()])), + text: 'Custom Binarization Filter', + onPressed: () => + applyParametricFilters([CustomBinarizationFilter()]), + ), FilterButton( - text: 'Brightness Filter', - onPressed: () { - applyParametricFilters([BrightnessFilter(brightness: 0.5)]); - }), + text: 'Brightness Filter', + onPressed: () { + applyParametricFilters([BrightnessFilter(brightness: 0.5)]); + }, + ), FilterButton( - text: 'Contrast Filter', - onPressed: () { - applyParametricFilters([ContrastFilter(contrast: 125.0)]); - }), + text: 'Contrast Filter', + onPressed: () { + applyParametricFilters([ContrastFilter(contrast: 125.0)]); + }, + ), FilterButton( - text: 'Grayscale Filter', - onPressed: () { - applyParametricFilters([GrayscaleFilter()]); - }), + text: 'Grayscale Filter', + onPressed: () { + applyParametricFilters([GrayscaleFilter()]); + }, + ), FilterButton( - text: 'White Black Point Filter', - onPressed: () { - applyParametricFilters([ - WhiteBlackPointFilter(blackPoint: 0.5, whitePoint: 0.5) - ]); - }), + text: 'White Black Point Filter', + onPressed: () { + applyParametricFilters([ + WhiteBlackPointFilter(blackPoint: 0.5, whitePoint: 0.5), + ]); + }, + ), ], ); }, @@ -163,12 +169,8 @@ class _PageOperationsState extends State { return; } - try { - await ScanbotSdk.document.removePage(RemovePageParams(documentID: widget.documentID, pageID: _page.uuid)); - Navigator.of(context).pop(); - } catch (e) { - print(e); - } + await ScanbotSdk.document.removePages(widget.documentID, [_page.uuid]); + Navigator.of(context).pop(); } Future applyParametricFilters(List list) async { @@ -176,13 +178,17 @@ class _PageOperationsState extends State { return; } - try { - var updatedDocument = await ScanbotSdk.document.modifyPage(ModifyPageParams(documentID: widget.documentID, pageID: _page.uuid, filters: list)); + var result = await ScanbotSdk.document.modifyPage( + widget.documentID, + _page.uuid, + options: ModifyPageOptions(filters: list), + ); + if (result is Ok) { setState(() { - _page = updatedDocument.pages.firstWhere((x) => x.uuid == _page.uuid); + _page = result.value.pages.firstWhere((x) => x.uuid == _page.uuid); }); - } catch (e) { - print(e); + } else { + print(result.toString()); } } @@ -200,18 +206,18 @@ class _PageOperationsState extends State { /* Customize the configuration. */ configuration.cropping.bottomBar.rotateButton.visible = false; configuration.appearance.topBarBackgroundColor = ScanbotColor("#C8193C"); - configuration.cropping.topBarConfirmButton.foreground.color = ScanbotColor('#ffffff'); + configuration.cropping.topBarConfirmButton.foreground.color = ScanbotColor( + '#ffffff', + ); configuration.localization.croppingTopBarCancelButtonTitle = 'Cancel'; - try { - var result = await ScanbotSdkUiV2.startCroppingScreen(configuration); - if (result.status == OperationStatus.OK && result.data != null) { - setState(() { - _page = result.data!.pages.firstWhere((x) => x.uuid == _page.uuid); - }); - } - } catch (e) { - print(e); + var result = await ScanbotSdk.document.startCroppingScreen(configuration); + if (result is Ok) { + setState(() { + _page = result.value.pages.firstWhere((x) => x.uuid == _page.uuid); + }); + } else { + print(result.toString()); } } -} \ No newline at end of file +} diff --git a/lib/ui/pages_widget.dart b/lib/ui/pages_widget.dart index de8fdf8..a2dbfcd 100644 --- a/lib/ui/pages_widget.dart +++ b/lib/ui/pages_widget.dart @@ -1,3 +1,4 @@ +import 'dart:convert'; import 'dart:io'; import 'dart:typed_data'; @@ -5,13 +6,13 @@ import 'package:flutter/material.dart'; import 'package:scanbot_sdk/scanbot_sdk.dart'; class PageWidget extends StatelessWidget { - final Uri path; + final String path; PageWidget(this.path); @override Widget build(BuildContext context) { - var file = File.fromUri(path); + var file = File(Uri.parse(path).toFilePath()); var bytes = file.readAsBytesSync(); final image = Image.memory(bytes); return SizedBox( @@ -23,31 +24,36 @@ class PageWidget extends StatelessWidget { } class EncryptedPageWidget extends StatelessWidget { - final Uri path; + final String path; EncryptedPageWidget(this.path); @override Widget build(BuildContext context) { - final imageData = ScanbotEncryptionHandler.getDecryptedDataFromFile(path); + final imageDataFuture = ScanbotSdk.imageProcessor.readImageData(path); return SizedBox( height: double.infinity, width: double.infinity, - child: FutureBuilder( - future: imageData, - builder: (BuildContext context, AsyncSnapshot snapshot) { + child: FutureBuilder>( + future: imageDataFuture, + builder: + (BuildContext context, AsyncSnapshot> snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return const Center( - child: SizedBox( - width: 100, - height: 100, - child: CircularProgressIndicator( - strokeWidth: 10, - ), - )); + child: SizedBox( + width: 100, + height: 100, + child: CircularProgressIndicator(strokeWidth: 10), + ), + ); } - if (snapshot.data != null) { - final image = Image.memory(snapshot.data!); + + var result = snapshot.data; + if (result is Ok) { + Uint8List bytes = base64Decode( + result.value.replaceAll(RegExp(r'\s+'), ''), + ); + final image = Image.memory(bytes); return Center(child: image); } else { return Container(); diff --git a/lib/ui/preview/_custom_ui_document_preview.dart b/lib/ui/preview/_custom_ui_document_preview.dart deleted file mode 100644 index 8306ec2..0000000 --- a/lib/ui/preview/_custom_ui_document_preview.dart +++ /dev/null @@ -1,636 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:image_picker/image_picker.dart'; - -import 'package:scanbot_sdk/scanbot_sdk.dart'; -import 'package:scanbot_sdk/scanbot_sdk.dart' as sdk; -import 'package:scanbot_sdk/scanbot_sdk_ui.dart'; - -import 'package:scanbot_sdk_example_flutter/ui/progress_dialog.dart'; -import 'package:scanbot_sdk_example_flutter/utility/utils.dart'; - -import '../../storage/_legacy_pages_repository.dart'; -import '../filter_page/filter_button_widget.dart'; -import '../_legacy_operations_page_widget.dart'; -import '../pages_widget.dart'; - -class CustomUiDocumentPreview extends StatefulWidget { - @override - _CustomUiDocumentPreviewState createState() => _CustomUiDocumentPreviewState(); -} - -class _CustomUiDocumentPreviewState extends State { - final LegacyPageRepository _pageRepository = LegacyPageRepository(); - late List _pages; - - @override - void initState() { - _pages = _pageRepository.pages; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: ScanbotAppBar('Image results', showBackButton: true, context: context), - body: Column( - children: [ - Expanded( - child: Container( - padding: const EdgeInsets.all(8.0), - child: GridView.builder( - scrollDirection: Axis.vertical, - gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent( - maxCrossAxisExtent: 200, - ), - itemBuilder: (context, position) { - final imageUri = - _pages[position].documentPreviewImageFileUri!; - final pageView = shouldInitWithEncryption - ? EncryptedPageWidget(imageUri) - : PageWidget(imageUri); - - return GridTile( - child: GestureDetector( - onTap: () => _showOperationsPage(_pages[position]), - child: pageView, - ), - ); - }, - itemCount: _pages.length, - ), - ), - ), - BottomAppBar( - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - _buildButton( - icon: Icons.add_circle, - label: 'Add', - onPressed: () => _addPageModalBottomSheet(context), - ), - _buildButton( - icon: Icons.more_vert, - label: 'More', - onPressed: () => _settingModalBottomSheet(context), - ), - _buildButton( - icon: Icons.delete, - label: 'Delete All', - iconColor: Colors.red, - textColor: Colors.red, - onPressed: () => _showCleanupStorageDialog(), - ), - ], - ), - ), - ], - ), - ); - } - -// Helper method to build a button with an icon and text - Widget _buildButton({ - required IconData icon, - required String label, - Color iconColor = Colors.black, - Color textColor = Colors.black, - required VoidCallback onPressed, - }) { - return TextButton( - onPressed: onPressed, - child: Row( - children: [ - Icon(icon, color: iconColor), - const SizedBox(width: 4), - Text( - label, - style: TextStyle(color: textColor), - ), - ], - ), - ); - } - - Future _showOperationsPage(sdk.Page page) async { - await Navigator.of(context).push( - MaterialPageRoute(builder: (context) => LegacyPageOperations(page)), - ); - _updatePagesList(); - } - - void _settingModalBottomSheet(BuildContext context) { - showModalBottomSheet( - context: context, - builder: (BuildContext bc) { - return Wrap( - children: [ - ListTile( - leading: const Icon(Icons.text_fields), - title: const Text('Perform OCR'), - onTap: () { - Navigator.pop(context); - _performOcr(); - }, - ), - ListTile( - leading: const Icon(Icons.text_fields), - title: const Text('Save as PDF'), - onTap: () { - Navigator.pop(context); - _createPdf(); - }, - ), - ListTile( - leading: const Icon(Icons.picture_as_pdf), - title: const Text('Save as PDF with OCR'), - onTap: () { - Navigator.pop(context); - _createPdfWithOcr(); - }, - ), - ListTile( - leading: const Icon(Icons.image), - title: const Text('Save as TIFF with ScanbotBinarization'), - onTap: () { - Navigator.pop(context); - _createTiffWithScanbotBinarization(); - }, - ), - ListTile( - leading: const Icon(Icons.image), - title: const Text('Save as TIFF with LegacyBinarization'), - onTap: () { - Navigator.pop(context); - _createTiffWithLegacyBinarization(); - }, - ), - ListTile( - leading: const Icon(Icons.image), - title: const Text('Save as TIFF'), - onTap: () { - Navigator.pop(context); - _createTiffWithoutBinarization(); - }, - ), - ListTile( - leading: const Icon(Icons.filter), - title: const Text('Apply filter for all pages'), - onTap: () { - Navigator.pop(context); - _settingModalFiltersSheet(context); - }, - ), - ListTile( - leading: const Icon(Icons.close), - title: const Text('Cancel'), - onTap: () => Navigator.pop(context), - ), - ], - ); - }, - ); - } - - void _settingModalFiltersSheet(BuildContext context) { - showModalBottomSheet( - context: context, - builder: (BuildContext bc) { - return ListView( - padding: const EdgeInsets.all(10.0), - shrinkWrap: true, - children: [ - FilterButton( - text: 'None', - onPressed: () => applyParametricFilters(_pages, [LegacyFilter(filterType: ImageFilterType.NONE.index)])), - FilterButton( - text: 'Color Document Filter', - onPressed: () => applyParametricFilters(_pages, [ColorDocumentFilter()])), - FilterButton( - text: 'Scanbot Binarization Filter', - onPressed: () => applyParametricFilters(_pages, [ScanbotBinarizationFilter()])), - FilterButton( - text: 'Custom Binarization Filter', - onPressed: () => applyParametricFilters(_pages, [CustomBinarizationFilter()])), - FilterButton( - text: 'Brightness Filter', - onPressed: () { - applyParametricFilters( - _pages, [BrightnessFilter(brightness: 0.5)]); - }), - FilterButton( - text: 'Contrast Filter', - onPressed: () { - applyParametricFilters( - _pages, [ContrastFilter(contrast: 125.0)]); - }), - FilterButton( - text: 'Grayscale Filter', - onPressed: () { - applyParametricFilters(_pages, [GrayscaleFilter()]); - }), - FilterButton( - text: 'White Black Point Filter', - onPressed: () { - applyParametricFilters(_pages, [ - WhiteBlackPointFilter(blackPoint: 0.5, whitePoint: 0.5) - ]); - }), - FilterButton( - text: 'Legacy Color Filter', - onPressed: () { - applyParametricFilters(_pages, [ - LegacyFilter(filterType: ImageFilterType.COLOR.typeIndex) - ]); - }), - FilterButton( - text: 'Legacy Grayscale Filter', - onPressed: () { - applyParametricFilters(_pages, [ - LegacyFilter( - filterType: ImageFilterType.GRAYSCALE.typeIndex) - ]); - }), - FilterButton( - text: 'Legacy Binarized Filter', - onPressed: () { - applyParametricFilters(_pages, [ - LegacyFilter( - filterType: ImageFilterType.BINARIZED.typeIndex) - ]); - }), - FilterButton( - text: 'Legacy Color Document Filter', - onPressed: () { - applyParametricFilters(_pages, [ - LegacyFilter( - filterType: ImageFilterType.COLOR_DOCUMENT.typeIndex) - ]); - }), - FilterButton( - text: 'Legacy Pure Binarized Filter', - onPressed: () { - applyParametricFilters(_pages, [ - LegacyFilter( - filterType: ImageFilterType.PURE_BINARIZED.typeIndex) - ]); - }), - FilterButton( - text: 'Legacy Background Clean Filter', - onPressed: () { - applyParametricFilters(_pages, [ - LegacyFilter( - filterType: ImageFilterType.BACKGROUND_CLEAN.typeIndex) - ]); - }), - FilterButton( - text: 'Legacy Black & White Filter', - onPressed: () { - applyParametricFilters(_pages, [ - LegacyFilter( - filterType: ImageFilterType.BLACK_AND_WHITE.typeIndex) - ]); - }), - FilterButton( - text: 'Legacy Otsu Binarization Filter', - onPressed: () { - applyParametricFilters(_pages, [ - LegacyFilter( - filterType: ImageFilterType.OTSU_BINARIZATION.typeIndex) - ]); - }), - FilterButton( - text: 'Legacy Deep Binarization Filter', - onPressed: () { - applyParametricFilters(_pages, [ - LegacyFilter( - filterType: ImageFilterType.DEEP_BINARIZATION.typeIndex) - ]); - }), - FilterButton( - text: 'Legacy Edge Highlight Filter', - onPressed: () { - applyParametricFilters(_pages, [ - LegacyFilter( - filterType: ImageFilterType.EDGE_HIGHLIGHT.typeIndex) - ]); - }), - FilterButton( - text: 'Legacy Low Light Binarization Filter', - onPressed: () { - applyParametricFilters(_pages, [ - LegacyFilter( - filterType: - ImageFilterType.LOW_LIGHT_BINARIZATION.typeIndex) - ]); - }), - FilterButton( - text: 'Legacy Low Light Binarization Filter 2', - onPressed: () { - applyParametricFilters(_pages, [ - LegacyFilter( - filterType: - ImageFilterType.LOW_LIGHT_BINARIZATION_2.typeIndex) - ]); - }), - FilterButton( - text: 'Legacy Sensitive Binarization Filter', - onPressed: () { - applyParametricFilters(_pages, [ - LegacyFilter( - filterType: - ImageFilterType.SENSITIVE_BINARIZATION.typeIndex) - ]); - }), - FilterButton( - text: 'Legacy Pure Gray Filter', - onPressed: () { - applyParametricFilters(_pages, [ - LegacyFilter( - filterType: ImageFilterType.PURE_GRAY.typeIndex) - ]); - }), - ], - ); - }, - ); - } - - // Shows a modal bottom sheet for adding pages. - void _addPageModalBottomSheet(BuildContext context) { - showModalBottomSheet( - context: context, - builder: (BuildContext context) { - return Wrap( - children: [ - ListTile( - leading: const Icon(Icons.scanner), - title: const Text('Scan Page'), - onTap: () { - Navigator.pop(context); - _startDocumentScanning(); - }, - ), - ListTile( - leading: const Icon(Icons.photo_size_select_actual), - title: const Text('Import Page'), - onTap: () { - Navigator.pop(context); - _importImage(); - }, - ), - ListTile( - leading: const Icon(Icons.close), - title: const Text('Cancel'), - onTap: () { - Navigator.pop(context); - }, - ), - ], - ); - }, - ); - } - - // Applies a list of parametric filters to a list of pages. - Future applyParametricFilters( - List pages, List parametricFilters) async { - if (!await checkLicenseStatus(context)) return; - - try { - for (final page in pages) { - final filteredPage = await ScanbotSdk.applyImageFilter(page, parametricFilters); - await _pageRepository.updatePage(filteredPage); - } - _updatePagesList(); - Navigator.pop(context); - } catch (e) { - print(e); - } - } - - // Starts document scanning and adds the pages to the repository. - Future _startDocumentScanning() async { - if (!await checkLicenseStatus(context)) return; - - try { - final config = DocumentScannerScreenConfiguration( - orientationLockMode: OrientationLockMode.PORTRAIT, - cameraPreviewMode: CameraPreviewMode.FIT_IN, - multiPageEnabled: false, - multiPageButtonHidden: true, - ); - final result = await ScanbotSdkUi.startDocumentScanner(config); - - if (result.operationResult == OperationStatus.OK) { - await _pageRepository.addPages(result.pages); - _updatePagesList(); - } - } catch (e) { - print(e); - } - } - - // Shows a dialog for confirming storage cleanup. - void _showCleanupStorageDialog() { - showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - title: const Text('Delete all'), - content: const Text('Delete all images and generated files (PDF, TIFF, etc)?'), - contentPadding: const EdgeInsets.all(16.0), - actions: [ - TextButton( - onPressed: () { - _cleanupStorage(); - Navigator.of(context).pop(); - }, - child: const Text('OK'), - ), - TextButton( - onPressed: () => Navigator.of(context).pop(), - child: const Text('CANCEL'), - ), - ], - ); - }, - ); - } - - Future _cleanupStorage() async { - try { - await ScanbotSdk.cleanupStorage(); - await _pageRepository.clearPages(); - _updatePagesList(); - } catch (e) { - print(e); - } - } - - Future _createPdf() async { - if (!await _checkHasPages(context)) { - return; - } - if (!await checkLicenseStatus(context)) { - return; - } - - final dialog = ProgressDialog(context, type: ProgressDialogType.Normal, isDismissible: false); - dialog.style(message: 'Creating PDF ...'); - try { - dialog.show(); - var options = PdfConfiguration(pageSize: PageSize.A4); - final pdfFileUri = - await ScanbotSdk.createPdf(_pageRepository.pages, options, null); - await dialog.hide(); - await showAlertDialog(context, pdfFileUri.toString(), - title: 'PDF file URI'); - } catch (e) { - print(e); - await dialog.hide(); - } - } - - Future _importImage() async { - try { - final XFile? image = await selectImageFromLibrary(); - if (image?.path != null) { - await _createPage(Uri.file(image!.path)); - } - } catch (e) { - print(e); - } - } - - Future _createPage(Uri uri) async { - if (!await checkLicenseStatus(context)) { - return; - } - - var dialog = ProgressDialog(context, type: ProgressDialogType.Normal, isDismissible: true); - dialog.style(message: 'Processing ...'); - dialog.show(); - try { - var page = await ScanbotSdk.createPage(uri, false); - page = await ScanbotSdk.detectDocument(page); - await dialog.hide(); - await _pageRepository.addPage(page); - _updatePagesList(); - } catch (e) { - print(e); - await dialog.hide(); - } - } - - Future _createTiff(TiffGeneratorParameters Function() optionsProvider) async { - if (!await _checkHasPages(context)) { - return; - } - if (!await checkLicenseStatus(context)) { - return; - } - - final dialog = ProgressDialog(context, - type: ProgressDialogType.Normal, isDismissible: false); - dialog.style(message: 'Creating TIFF ...'); - dialog.show(); - - try { - var options = optionsProvider(); - final tiffFileUri = - await ScanbotSdk.createTiff(_pageRepository.pages, options); - await dialog.hide(); - await showAlertDialog(context, tiffFileUri.toString(), - title: 'TIFF file URI'); - } catch (e) { - print(e); - } finally { - await dialog.hide(); - } - } - - Future _createTiffWithScanbotBinarization() async { - await _createTiff(() => TiffGeneratorParameters( - binarizationFilter: ScanbotBinarizationFilter(), - dpi: 200, - compression: CompressionMode.CCITT_T4)); - } - - Future _createTiffWithLegacyBinarization() async { - await _createTiff(() => TiffGeneratorParameters( - binarizationFilter: LegacyFilter( - filterType: ImageFilterType.BINARIZED.typeIndex), - dpi: 200, - compression: CompressionMode.CCITT_T4)); - } - - Future _createTiffWithoutBinarization() async { - await _createTiff( - () => TiffGeneratorParameters(dpi: 200, compression: CompressionMode.LZW)); - } - - Future _performOcr() async { - if (!await _checkHasPages(context)) { - return; - } - if (!await checkLicenseStatus(context)) { - return; - } - - final dialog = ProgressDialog(context, - type: ProgressDialogType.Normal, isDismissible: false); - dialog.style(message: 'Performing OCR ...'); - dialog.show(); - try { - final result = await ScanbotSdk.performOcr( - _pages, OcrOptions(languages: ['en', 'de'])); - await dialog.hide(); - await showAlertDialog( - context, 'Plain text:\n' + (result.plainText ?? '')); - } catch (e) { - print(e); - await dialog.hide(); - } - } - - Future _createPdfWithOcr() async { - if (!await _checkHasPages(context)) { - return; - } - if (!await checkLicenseStatus(context)) { - return; - } - - var dialog = ProgressDialog(context, - type: ProgressDialogType.Normal, isDismissible: false); - dialog.style(message: 'Performing OCR with PDF ...'); - dialog.show(); - try { - var pdfFileUri = await ScanbotSdk.createPdf(_pages, PdfConfiguration(), OcrOptions(engineMode: OcrEngine.SCANBOT_OCR)); - await showAlertDialog(context, pdfFileUri.toString(), - title: 'PDF file URI'); - await dialog.hide(); - } catch (e) { - print(e); - await dialog.hide(); - } - } - - Future _checkHasPages(BuildContext context) async { - if (_pages.isNotEmpty) { - return true; - } - await showAlertDialog(context, - 'Please scan or import some documents to perform this function.', - title: 'Info'); - return false; - } - - Future _updatePagesList() async { - setState(() { - _pages = _pageRepository.pages; - }); - } -} \ No newline at end of file diff --git a/lib/ui/preview/check_preview.dart b/lib/ui/preview/check_preview.dart index e02d24a..6d4dcc7 100644 --- a/lib/ui/preview/check_preview.dart +++ b/lib/ui/preview/check_preview.dart @@ -11,8 +11,10 @@ class CheckDocumentResultPreview extends StatelessWidget { super.key, this.uiResult, this.scanningResult, - }) : assert(uiResult != null || scanningResult != null, - 'At least one result must be provided'); + }) : assert( + uiResult != null || scanningResult != null, + 'At least one result must be provided', + ); @override Widget build(BuildContext context) { @@ -20,7 +22,11 @@ class CheckDocumentResultPreview extends StatelessWidget { final croppedImage = uiResult?.croppedImage ?? scanningResult?.croppedImage; return Scaffold( - appBar: ScanbotAppBar('Check Document Preview', showBackButton: true, context: context), + appBar: ScanbotAppBar( + 'Check Document Preview', + showBackButton: true, + context: context, + ), body: genericDocument == null ? const Center(child: Text('No check data available')) : ListView( @@ -48,7 +54,8 @@ class CheckDocumentResultPreview extends StatelessWidget { void add(String title, String? value, {bool large = false}) { fields.add(Text(title, style: Theme.of(context).textTheme.titleMedium)); fields.add( - Text(value ?? '', style: Theme.of(context).textTheme.bodyMedium)); + Text(value ?? '', style: Theme.of(context).textTheme.bodyMedium), + ); fields.add(SizedBox(height: large ? 16 : 12)); } @@ -130,4 +137,4 @@ class CheckDocumentResultPreview extends StatelessWidget { return fields; } -} \ No newline at end of file +} diff --git a/lib/ui/preview/credit_card_preview.dart b/lib/ui/preview/credit_card_preview.dart index a0dab86..b38a61d 100644 --- a/lib/ui/preview/credit_card_preview.dart +++ b/lib/ui/preview/credit_card_preview.dart @@ -7,21 +7,25 @@ class CreditCardResultPreview extends StatelessWidget { final CreditCardScannerUiResult? uiResult; final CreditCardScanningResult? scanningResult; - const CreditCardResultPreview({ - super.key, - this.uiResult, - this.scanningResult, - }) : assert(uiResult != null || scanningResult != null, - 'At least one result must be provided'); + const CreditCardResultPreview({super.key, this.uiResult, this.scanningResult}) + : assert( + uiResult != null || scanningResult != null, + 'At least one result must be provided', + ); @override Widget build(BuildContext context) { final doc = uiResult?.creditCard ?? scanningResult?.creditCard; - final recognitionStatus = uiResult?.recognitionStatus.name ?? scanningResult?.scanningStatus.name; + final recognitionStatus = + uiResult?.recognitionStatus.name ?? scanningResult?.scanningStatus.name; if (doc == null) { return Scaffold( - appBar: ScanbotAppBar('Credit Card Result', showBackButton: true, context: context), + appBar: ScanbotAppBar( + 'Credit Card Result', + showBackButton: true, + context: context, + ), body: const Center(child: Text('No credit card data available')), ); } @@ -30,29 +34,53 @@ class CreditCardResultPreview extends StatelessWidget { List children = []; - void addField(String title, String? value, double? confidence, {bool largeGap = false}) { + void addField( + String title, + String? value, + double? confidence, { + bool largeGap = false, + }) { children.add(Text(title, style: Theme.of(context).textTheme.titleMedium)); if (value != null && value.isNotEmpty) { - children.add(Text(value, style: Theme.of(context).textTheme.bodyMedium)); + children.add( + Text(value, style: Theme.of(context).textTheme.bodyMedium), + ); } if (confidence != null && confidence.isFinite) { - children.add(Text('Confidence: ${confidence.toStringAsFixed(2)}', - style: Theme.of(context).textTheme.labelSmall)); + children.add( + Text( + 'Confidence: ${confidence.toStringAsFixed(2)}', + style: Theme.of(context).textTheme.labelSmall, + ), + ); } children.add(SizedBox(height: largeGap ? 16 : 12)); } addField('Recognition Status', recognitionStatus, null, largeGap: true); - addField('Card Number', creditCard.cardNumber.value?.text, creditCard.cardNumber.value?.confidence); - addField('Cardholder Name', creditCard.cardholderName?.value?.text, creditCard.cardholderName?.value?.confidence); - addField('Expiry Date', creditCard.expiryDate?.value?.text, creditCard.expiryDate?.value?.confidence); + addField( + 'Card Number', + creditCard.cardNumber.value?.text, + creditCard.cardNumber.value?.confidence, + ); + addField( + 'Cardholder Name', + creditCard.cardholderName?.value?.text, + creditCard.cardholderName?.value?.confidence, + ); + addField( + 'Expiry Date', + creditCard.expiryDate?.value?.text, + creditCard.expiryDate?.value?.confidence, + ); return Scaffold( - appBar: ScanbotAppBar('Credit Card Result', showBackButton: true, context: context), - body: ListView( - padding: const EdgeInsets.all(16), - children: children, + appBar: ScanbotAppBar( + 'Credit Card Result', + showBackButton: true, + context: context, ), + body: ListView(padding: const EdgeInsets.all(16), children: children), ); } } diff --git a/lib/ui/preview/document_preview.dart b/lib/ui/preview/document_preview.dart index c979444..65559f9 100644 --- a/lib/ui/preview/document_preview.dart +++ b/lib/ui/preview/document_preview.dart @@ -6,7 +6,6 @@ import '../operations_page_widget.dart'; import '../pages_widget.dart'; import 'package:scanbot_sdk/scanbot_sdk.dart'; -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; class DocumentPreview extends StatefulWidget { final DocumentData initialDocumentData; @@ -18,7 +17,6 @@ class DocumentPreview extends StatefulWidget { } class DocumentPreviewPreviewState extends State { - late DocumentData documentData; @override @@ -42,14 +40,16 @@ class DocumentPreviewPreviewState extends State { maxCrossAxisExtent: 200, ), itemBuilder: (context, position) { - final imageUri = Uri(path: documentData.pages[position].documentImagePreviewURI!.replaceFirst('file://', '')); + final imageUri = + documentData.pages[position].documentImagePreviewURI!; final pageView = shouldInitWithEncryption ? EncryptedPageWidget(imageUri) : PageWidget(imageUri); return GridTile( child: GestureDetector( - onTap: () => _showOperationsPage(documentData.pages[position]), + onTap: () => + _showOperationsPage(documentData.pages[position]), child: pageView, ), ); @@ -76,16 +76,10 @@ class DocumentPreviewPreviewState extends State { ); } - Widget _buildButton( - String label, - VoidCallback onPressed - ) { + Widget _buildButton(String label, VoidCallback onPressed) { return TextButton( onPressed: onPressed, - child: Text( - label, - style: const TextStyle(color: Colors.white), - ), + child: Text(label, style: const TextStyle(color: Colors.white)), ); } @@ -118,7 +112,7 @@ class DocumentPreviewPreviewState extends State { ListTile( leading: const Icon(Icons.cancel), title: const Text('Cancel'), - onTap: () => { Navigator.pop(context) }, + onTap: () => {Navigator.pop(context)}, ), ], ); @@ -128,36 +122,40 @@ class DocumentPreviewPreviewState extends State { Future startScan({ required BuildContext context, - required Future> Function() scannerFunction, + required Future> Function() scannerFunction, }) async { if (!await checkLicenseStatus(context)) { return; } - try { - var result = await scannerFunction(); - if (result.status == OperationStatus.OK && - result.data != null) { - setState(() { - documentData = result.data!; - }); - } - } catch (e) { - print(e); + + var result = await scannerFunction(); + if (result is Ok) { + setState(() { + documentData = result.value; + }); + } else { + await showAlertDialog(context, result.toString()); } } Future _showOperationsPage(PageData page) async { await Navigator.of(context).push( - MaterialPageRoute(builder: (context) => PageOperations(documentData.uuid, page)), + MaterialPageRoute( + builder: (context) => PageOperations(documentData.uuid, page), + ), ); if (!await checkLicenseStatus(context)) { return; } - var loadedData = await ScanbotSdk.document.loadDocument(documentData.uuid); - setState(() { - documentData = loadedData; - }); + var result = await ScanbotSdk.document.loadDocument(documentData.uuid); + if (result is Ok) { + setState(() { + documentData = result.value; + }); + } else { + await showAlertDialog(context, result.toString()); + } } Future _continueScanning() async { @@ -166,8 +164,9 @@ class DocumentPreviewPreviewState extends State { } await startScan( context: context, - scannerFunction: () => - ScanbotSdkUiV2.startDocumentScanner(DocumentScanningFlow(documentUuid: documentData.uuid)), + scannerFunction: () => ScanbotSdk.document.startScanner( + DocumentScanningFlow(documentUuid: documentData.uuid), + ), ); } @@ -175,13 +174,20 @@ class DocumentPreviewPreviewState extends State { if (!await checkLicenseStatus(context)) { return; } - final response = await selectImageFromLibrary(); - if (response?.path.isNotEmpty ?? false) { - var result = await ScanbotSdk.document.addPage(AddPageParams(documentID: documentData.uuid, imageFileUri: response!.path)); + final file = await selectImageFromLibrary(); + if (file == null || file.path.isEmpty) return; + + var result = await ScanbotSdk.document.addPagesFromImageFileUris( + documentData.uuid, + [file.path], + ); + if (result is Ok) { setState(() { - documentData = result; + documentData = result.value; }); + } else { + await showAlertDialog(context, result.toString()); } } @@ -190,17 +196,32 @@ class DocumentPreviewPreviewState extends State { return; } var result = await ScanbotSdk.document.removeAllPages(documentData.uuid); - setState(() { - documentData = result; - }); + if (result is Ok) { + setState(() { + documentData = result.value; + }); + } else { + await showAlertDialog(context, result.toString()); + } } Future _saveDocumentAsPDF() async { if (!await checkLicenseStatus(context)) { return; } - var result = await ScanbotSdk.document.createPDFForDocument(PDFFromDocumentParams(documentID: documentData.uuid, pdfConfiguration: PdfConfiguration())); - await showAlertDialog(context, 'Pdf File created: ${result.pdfFileUri}', title: 'Result'); + var result = await ScanbotSdk.pdfGenerator.generateFromDocument( + documentData.uuid, + PdfConfiguration(), + ); + if (result is Ok) { + await showAlertDialog( + context, + 'Pdf File created: ${result.value}', + title: 'Result', + ); + } else { + await showAlertDialog(context, result.toString()); + } } Future _saveDocumentAsPDFWithOCR() async { @@ -212,8 +233,20 @@ class DocumentPreviewPreviewState extends State { pageDirection: PageDirection.PORTRAIT, ); - var result = await ScanbotSdk.document.createPDFForDocument(PDFFromDocumentParams(documentID: documentData.uuid, pdfConfiguration: pdfOptions, ocrConfiguration: OcrOptions(engineMode: OcrEngine.SCANBOT_OCR))); - await showAlertDialog(context, 'Pdf File created: ${result.pdfFileUri}', title: 'Result'); + var result = await ScanbotSdk.pdfGenerator.generateFromDocument( + documentData.uuid, + pdfOptions, + ocrConfiguration: OcrConfiguration(engineMode: OcrEngine.SCANBOT_OCR), + ); + if (result is Ok) { + await showAlertDialog( + context, + 'Pdf File created: ${result.value}', + title: 'Result', + ); + } else { + await showAlertDialog(context, result.toString()); + } } Future _saveDocumentAsTIFFBinarized() async { @@ -221,16 +254,42 @@ class DocumentPreviewPreviewState extends State { return; } - var options = TiffGeneratorParameters(binarizationFilter: ScanbotBinarizationFilter(), dpi: 300, compression: CompressionMode.CCITT_T6); - var result = await ScanbotSdk.document.createTIFFForDocument(TIFFFromDocumentParams(documentID: documentData.uuid, configuration: options)); - await showAlertDialog(context, 'Tiff Binarized File created: ${result.tiffFileUri}', title: 'Result'); + var options = TiffGeneratorParameters( + binarizationFilter: ScanbotBinarizationFilter(), + dpi: 300, + compression: CompressionMode.CCITT_T6, + ); + var result = await ScanbotSdk.tiffGenerator.generateFromDocument( + documentData.uuid, + options, + ); + if (result is Ok) { + await showAlertDialog( + context, + 'Tiff Binarized File created: ${result.value}', + title: 'Result', + ); + } else { + await showAlertDialog(context, result.toString()); + } } Future _saveDocumentAsTIFF() async { if (!await checkLicenseStatus(context)) { return; } - var result = await ScanbotSdk.document.createTIFFForDocument(TIFFFromDocumentParams(documentID: documentData.uuid, configuration: TiffGeneratorParameters())); - await showAlertDialog(context, 'Tiff File created: ${result.tiffFileUri}', title: 'Result'); + var result = await ScanbotSdk.tiffGenerator.generateFromDocument( + documentData.uuid, + TiffGeneratorParameters(), + ); + if (result is Ok) { + await showAlertDialog( + context, + 'Tiff File created: ${result.value}', + title: 'Result', + ); + } else { + await showAlertDialog(context, result.toString()); + } } } diff --git a/lib/ui/preview/ehic_preview.dart b/lib/ui/preview/ehic_preview.dart deleted file mode 100644 index 22da592..0000000 --- a/lib/ui/preview/ehic_preview.dart +++ /dev/null @@ -1,44 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter/material.dart' as material; -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; - -import '../../utility/utils.dart'; - -class EuropeanHealthInsuranceCardResultPreview extends StatelessWidget { - final EuropeanHealthInsuranceCardRecognitionResult result; - - const EuropeanHealthInsuranceCardResultPreview(this.result, {super.key}); - - @override - Widget build(BuildContext context) { - final fields = result.fields; - - List children = []; - - void addField(String title, String? value, double? confidence, {bool largeGap = false}) { - children.add(Text(title, style: Theme.of(context).textTheme.titleMedium)); - if (value != null && value.isNotEmpty) { - children.add(Text(value, style: Theme.of(context).textTheme.bodyMedium)); - } - if (confidence != null && confidence.isFinite) { - children.add(Text('Confidence: ${confidence.toStringAsFixed(2)}', - style: Theme.of(context).textTheme.labelSmall)); - } - children.add(SizedBox(height: largeGap ? 16 : 12)); - } - - addField('Recognition Status', result.status.name, null, largeGap: true); - - for (final field in fields) { - addField(field.type.name, field.value, field.confidence); - } - - return Scaffold( - appBar: ScanbotAppBar('Health Insurance Card Result', showBackButton: true, context: context), - body: ListView( - padding: const material.EdgeInsets.all(16), - children: children, - ), - ); - } -} diff --git a/lib/ui/preview/extracted_document_data_preview.dart b/lib/ui/preview/extracted_document_data_preview.dart index ae3eef1..5fae55d 100644 --- a/lib/ui/preview/extracted_document_data_preview.dart +++ b/lib/ui/preview/extracted_document_data_preview.dart @@ -11,8 +11,10 @@ class ExtractedDocumentDataPreview extends StatelessWidget { super.key, this.uiResult, this.scanningResult, - }) : assert(uiResult != null || scanningResult != null, - 'At least one result must be provided'); + }) : assert( + uiResult != null || scanningResult != null, + 'At least one result must be provided', + ); @override Widget build(BuildContext context) { @@ -24,16 +26,25 @@ class ExtractedDocumentDataPreview extends StatelessWidget { const SizedBox(height: 16), ]; - void addField(String title, String? value, double? confidence, - {bool largeGap = false}) { + void addField( + String title, + String? value, + double? confidence, { + bool largeGap = false, + }) { children.add(Text(title, style: Theme.of(context).textTheme.titleMedium)); if (value != null && value.isNotEmpty) { - children - .add(Text(value, style: Theme.of(context).textTheme.bodyMedium)); + children.add( + Text(value, style: Theme.of(context).textTheme.bodyMedium), + ); } if (confidence != null && confidence.isFinite) { - children.add(Text('Confidence: ${confidence.toStringAsFixed(2)}', - style: Theme.of(context).textTheme.labelSmall)); + children.add( + Text( + 'Confidence: ${confidence.toStringAsFixed(2)}', + style: Theme.of(context).textTheme.labelSmall, + ), + ); } children.add(SizedBox(height: largeGap ? 16 : 12)); } @@ -44,194 +55,428 @@ class ExtractedDocumentDataPreview extends StatelessWidget { switch (document.type.name) { case MRZ.DOCUMENT_TYPE: final mrz = MRZ(document); - addField('Birth Date', mrz.birthDate.value?.text, - mrz.birthDate.value?.confidence); - addField('Expiry Date', mrz.expiryDate?.value?.text, - mrz.expiryDate?.value?.confidence); - addField('Given Names', mrz.givenNames.value?.text, - mrz.givenNames.value?.confidence); - addField('TravelDocType', mrz.travelDocType?.value?.text, - mrz.travelDocType?.value?.confidence); - addField('Document Number', mrz.documentNumber?.value?.text, - mrz.documentNumber?.value?.confidence); - addField('Nationality', mrz.nationality.value?.text, - mrz.nationality.value?.confidence); - addField( - 'Pin', mrz.pinCode?.value?.text, mrz.pinCode?.value?.confidence); - addField('Surname', mrz.surname.value?.text, - mrz.surname.value?.confidence); + addField( + 'Birth Date', + mrz.birthDate.value?.text, + mrz.birthDate.value?.confidence, + ); + addField( + 'Expiry Date', + mrz.expiryDate?.value?.text, + mrz.expiryDate?.value?.confidence, + ); + addField( + 'Given Names', + mrz.givenNames.value?.text, + mrz.givenNames.value?.confidence, + ); + addField( + 'TravelDocType', + mrz.travelDocType?.value?.text, + mrz.travelDocType?.value?.confidence, + ); + addField( + 'Document Number', + mrz.documentNumber?.value?.text, + mrz.documentNumber?.value?.confidence, + ); + addField( + 'Nationality', + mrz.nationality.value?.text, + mrz.nationality.value?.confidence, + ); + addField( + 'Pin', + mrz.pinCode?.value?.text, + mrz.pinCode?.value?.confidence, + ); + addField( + 'Surname', + mrz.surname.value?.text, + mrz.surname.value?.confidence, + ); break; case DeHealthInsuranceCardFront.DOCUMENT_TYPE: final hic = DeHealthInsuranceCardFront(document); addField('Name', hic.name.value?.text, hic.name.value?.confidence); - addField('CardAccessNumber', hic.cardAccessNumber?.value?.text, - hic.cardAccessNumber?.value?.confidence); - addField('IssuerName', hic.issuerName.value?.text, - hic.issuerName.value?.confidence); - addField('IssuerNumber', hic.issuerNumber.value?.text, - hic.issuerNumber.value?.confidence); - addField('PersonalNumber', hic.personalNumber.value?.text, - hic.personalNumber.value?.confidence); + addField( + 'CardAccessNumber', + hic.cardAccessNumber?.value?.text, + hic.cardAccessNumber?.value?.confidence, + ); + addField( + 'IssuerName', + hic.issuerName.value?.text, + hic.issuerName.value?.confidence, + ); + addField( + 'IssuerNumber', + hic.issuerNumber.value?.text, + hic.issuerNumber.value?.confidence, + ); + addField( + 'PersonalNumber', + hic.personalNumber.value?.text, + hic.personalNumber.value?.confidence, + ); break; case DeIdCardFront.DOCUMENT_TYPE: final doc = DeIdCardFront(document); - addField('Birth Date', doc.birthDate.value?.text, - doc.birthDate.value?.confidence); - addField('Birth Place', doc.birthplace.value?.text, - doc.birthplace.value?.confidence); - addField('Expiry Date', doc.expiryDate.value?.text, - doc.expiryDate.value?.confidence); - addField('Given Names', doc.givenNames.value?.text, - doc.givenNames.value?.confidence); + addField( + 'Birth Date', + doc.birthDate.value?.text, + doc.birthDate.value?.confidence, + ); + addField( + 'Birth Place', + doc.birthplace.value?.text, + doc.birthplace.value?.confidence, + ); + addField( + 'Expiry Date', + doc.expiryDate.value?.text, + doc.expiryDate.value?.confidence, + ); + addField( + 'Given Names', + doc.givenNames.value?.text, + doc.givenNames.value?.confidence, + ); addField('Id', doc.id.value?.text, doc.id.value?.confidence); - addField('Maiden Name', doc.maidenName?.value?.text, - doc.maidenName?.value?.confidence); - addField('Nationality', doc.nationality.value?.text, - doc.nationality.value?.confidence); - addField('Surname', doc.surname.value?.text, - doc.surname.value?.confidence); + addField( + 'Maiden Name', + doc.maidenName?.value?.text, + doc.maidenName?.value?.confidence, + ); + addField( + 'Nationality', + doc.nationality.value?.text, + doc.nationality.value?.confidence, + ); + addField( + 'Surname', + doc.surname.value?.text, + doc.surname.value?.confidence, + ); break; case DeResidencePermitFront.DOCUMENT_TYPE: final doc = DeResidencePermitFront(document); - addField('Birth Date', doc.birthDate?.value?.text, - doc.birthDate?.value?.confidence); - addField('Birth Place', doc.birthDate?.value?.text, - doc.birthDate?.value?.confidence); - addField('Expiry Date', doc.expiryDate.value?.text, - doc.expiryDate.value?.confidence); - addField('Given Names', doc.givenNames.value?.text, - doc.givenNames.value?.confidence); + addField( + 'Birth Date', + doc.birthDate?.value?.text, + doc.birthDate?.value?.confidence, + ); + addField( + 'Birth Place', + doc.birthDate?.value?.text, + doc.birthDate?.value?.confidence, + ); + addField( + 'Expiry Date', + doc.expiryDate.value?.text, + doc.expiryDate.value?.confidence, + ); + addField( + 'Given Names', + doc.givenNames.value?.text, + doc.givenNames.value?.confidence, + ); addField('Id', doc.id.value?.text, doc.id.value?.confidence); - addField('Nationality', doc.nationality?.value?.text, - doc.nationality?.value?.confidence); - addField('Surname', doc.surname.value?.text, - doc.surname.value?.confidence); + addField( + 'Nationality', + doc.nationality?.value?.text, + doc.nationality?.value?.confidence, + ); + addField( + 'Surname', + doc.surname.value?.text, + doc.surname.value?.confidence, + ); break; case DeResidencePermitBack.DOCUMENT_TYPE: final doc = DeResidencePermitBack(document); - addField('Address', doc.address.value?.text, - doc.address.value?.confidence); - addField('Birth Date', doc.birthDate?.value?.text, - doc.birthDate?.value?.confidence); - addField('Eye Color', doc.eyeColor.value?.text, - doc.eyeColor.value?.confidence); - addField( - 'Gender', doc.gender?.value?.text, doc.gender?.value?.confidence); - addField( - 'Height', doc.height.value?.text, doc.height.value?.confidence); - addField('Issuing Authority', doc.issuingAuthority.value?.text, - doc.issuingAuthority.value?.confidence); - addField('Nationality', doc.nationality?.value?.text, - doc.nationality?.value?.confidence); - addField( - 'Raw MRZ', doc.rawMRZ.value?.text, doc.rawMRZ.value?.confidence); - addField('Remarks', doc.remarks?.value?.text, - doc.remarks?.value?.confidence); + addField( + 'Address', + doc.address.value?.text, + doc.address.value?.confidence, + ); + addField( + 'Birth Date', + doc.birthDate?.value?.text, + doc.birthDate?.value?.confidence, + ); + addField( + 'Eye Color', + doc.eyeColor.value?.text, + doc.eyeColor.value?.confidence, + ); + addField( + 'Gender', + doc.gender?.value?.text, + doc.gender?.value?.confidence, + ); + addField( + 'Height', + doc.height.value?.text, + doc.height.value?.confidence, + ); + addField( + 'Issuing Authority', + doc.issuingAuthority.value?.text, + doc.issuingAuthority.value?.confidence, + ); + addField( + 'Nationality', + doc.nationality?.value?.text, + doc.nationality?.value?.confidence, + ); + addField( + 'Raw MRZ', + doc.rawMRZ.value?.text, + doc.rawMRZ.value?.confidence, + ); + addField( + 'Remarks', + doc.remarks?.value?.text, + doc.remarks?.value?.confidence, + ); break; case DeIdCardBack.DOCUMENT_TYPE: final doc = DeIdCardBack(document); - addField('Address', doc.address.value?.text, - doc.address.value?.confidence); - addField('Eye Color', doc.eyeColor.value?.text, - doc.eyeColor.value?.confidence); - addField( - 'Height', doc.height.value?.text, doc.height.value?.confidence); - addField('Issue Date', doc.issueDate.value?.text, - doc.issueDate.value?.confidence); - addField('Issuing Authority', doc.issuingAuthority.value?.text, - doc.issuingAuthority.value?.confidence); - addField('Pseudonym', doc.pseudonym?.value?.text, - doc.pseudonym?.value?.confidence); - addField( - 'Raw MRZ', doc.rawMRZ.value?.text, doc.rawMRZ.value?.confidence); + addField( + 'Address', + doc.address.value?.text, + doc.address.value?.confidence, + ); + addField( + 'Eye Color', + doc.eyeColor.value?.text, + doc.eyeColor.value?.confidence, + ); + addField( + 'Height', + doc.height.value?.text, + doc.height.value?.confidence, + ); + addField( + 'Issue Date', + doc.issueDate.value?.text, + doc.issueDate.value?.confidence, + ); + addField( + 'Issuing Authority', + doc.issuingAuthority.value?.text, + doc.issuingAuthority.value?.confidence, + ); + addField( + 'Pseudonym', + doc.pseudonym?.value?.text, + doc.pseudonym?.value?.confidence, + ); + addField( + 'Raw MRZ', + doc.rawMRZ.value?.text, + doc.rawMRZ.value?.confidence, + ); break; case DePassport.DOCUMENT_TYPE: final doc = DePassport(document); - addField('Birth Date', doc.birthDate.value?.text, - doc.birthDate.value?.confidence); - addField('Birth Place', doc.birthplace.value?.text, - doc.birthplace.value?.confidence); - addField('Country Code', doc.countryCode.value?.text, - doc.countryCode.value?.confidence); - addField('Expiry Date', doc.expiryDate.value?.text, - doc.expiryDate.value?.confidence); - addField( - 'Gender', doc.gender.value?.text, doc.gender.value?.confidence); - addField('Given Names', doc.givenNames.value?.text, - doc.givenNames.value?.confidence); + addField( + 'Birth Date', + doc.birthDate.value?.text, + doc.birthDate.value?.confidence, + ); + addField( + 'Birth Place', + doc.birthplace.value?.text, + doc.birthplace.value?.confidence, + ); + addField( + 'Country Code', + doc.countryCode.value?.text, + doc.countryCode.value?.confidence, + ); + addField( + 'Expiry Date', + doc.expiryDate.value?.text, + doc.expiryDate.value?.confidence, + ); + addField( + 'Gender', + doc.gender.value?.text, + doc.gender.value?.confidence, + ); + addField( + 'Given Names', + doc.givenNames.value?.text, + doc.givenNames.value?.confidence, + ); addField('Id', doc.id.value?.text, doc.id.value?.confidence); - addField('Issue Date', doc.issueDate.value?.text, - doc.issueDate.value?.confidence); - addField('Issuing Authority', doc.issuingAuthority.value?.text, - doc.issuingAuthority.value?.confidence); - addField('Maiden Name', doc.maidenName?.value?.text, - doc.maidenName?.value?.confidence); - addField('Nationality', doc.nationality.value?.text, - doc.nationality.value?.confidence); - addField('Passport Type', doc.passportType.value?.text, - doc.passportType.value?.confidence); - addField('Surname', doc.surname.value?.text, - doc.surname.value?.confidence); - addField( - 'Raw MRZ', doc.rawMRZ.value?.text, doc.rawMRZ.value?.confidence); + addField( + 'Issue Date', + doc.issueDate.value?.text, + doc.issueDate.value?.confidence, + ); + addField( + 'Issuing Authority', + doc.issuingAuthority.value?.text, + doc.issuingAuthority.value?.confidence, + ); + addField( + 'Maiden Name', + doc.maidenName?.value?.text, + doc.maidenName?.value?.confidence, + ); + addField( + 'Nationality', + doc.nationality.value?.text, + doc.nationality.value?.confidence, + ); + addField( + 'Passport Type', + doc.passportType.value?.text, + doc.passportType.value?.confidence, + ); + addField( + 'Surname', + doc.surname.value?.text, + doc.surname.value?.confidence, + ); + addField( + 'Raw MRZ', + doc.rawMRZ.value?.text, + doc.rawMRZ.value?.confidence, + ); break; case EuropeanHealthInsuranceCard.DOCUMENT_TYPE: final doc = EuropeanHealthInsuranceCard(document); - addField('Barcode', doc.barcode?.value?.text, - doc.barcode?.value?.confidence); - addField('BirthDate', doc.expiryDate.value?.text, - doc.expiryDate.value?.confidence); - addField('CardNumber', doc.cardNumber.value?.text, - doc.cardNumber.value?.confidence); - addField('CountryCode', doc.countryCode.value?.text, - doc.countryCode.value?.confidence); - addField('ExpiryDate', doc.expiryDate.value?.text, - doc.expiryDate.value?.confidence); - addField('GivenNames', doc.givenNames.value?.text, - doc.givenNames.value?.confidence); - addField('IssuerName', doc.issuerName.value?.text, - doc.issuerName.value?.confidence); - addField('IssuerNumber', doc.issuerNumber.value?.text, - doc.issuerNumber.value?.confidence); - addField('PersonalNumber', doc.personalNumber.value?.text, - doc.personalNumber.value?.confidence); - addField('Signature', doc.signature?.value?.text, - doc.signature?.value?.confidence); - addField('Surname', doc.surname.value?.text, - doc.surname.value?.confidence); + addField( + 'Barcode', + doc.barcode?.value?.text, + doc.barcode?.value?.confidence, + ); + addField( + 'BirthDate', + doc.expiryDate.value?.text, + doc.expiryDate.value?.confidence, + ); + addField( + 'CardNumber', + doc.cardNumber.value?.text, + doc.cardNumber.value?.confidence, + ); + addField( + 'CountryCode', + doc.countryCode.value?.text, + doc.countryCode.value?.confidence, + ); + addField( + 'ExpiryDate', + doc.expiryDate.value?.text, + doc.expiryDate.value?.confidence, + ); + addField( + 'GivenNames', + doc.givenNames.value?.text, + doc.givenNames.value?.confidence, + ); + addField( + 'IssuerName', + doc.issuerName.value?.text, + doc.issuerName.value?.confidence, + ); + addField( + 'IssuerNumber', + doc.issuerNumber.value?.text, + doc.issuerNumber.value?.confidence, + ); + addField( + 'PersonalNumber', + doc.personalNumber.value?.text, + doc.personalNumber.value?.confidence, + ); + addField( + 'Signature', + doc.signature?.value?.text, + doc.signature?.value?.confidence, + ); + addField( + 'Surname', + doc.surname.value?.text, + doc.surname.value?.confidence, + ); break; case EuropeanDriverLicenseFront.DOCUMENT_TYPE: final doc = EuropeanDriverLicenseFront(document); - addField('BirthDate', doc.expiryDate.value?.text, - doc.expiryDate.value?.confidence); - addField('Issue Date', doc.issueDate?.value?.text, - doc.issueDate?.value?.confidence); - addField('Issuing Authority', doc.issuingAuthority?.value?.text, - doc.issuingAuthority?.value?.confidence); - addField('ExpiryDate', doc.expiryDate.value?.text, - doc.expiryDate.value?.confidence); - addField('GivenNames', doc.givenNames.value?.text, - doc.givenNames.value?.confidence); - addField('LicenseCategories', doc.licenseCategories?.value?.text, - doc.licenseCategories?.value?.confidence); + addField( + 'BirthDate', + doc.expiryDate.value?.text, + doc.expiryDate.value?.confidence, + ); + addField( + 'Issue Date', + doc.issueDate?.value?.text, + doc.issueDate?.value?.confidence, + ); + addField( + 'Issuing Authority', + doc.issuingAuthority?.value?.text, + doc.issuingAuthority?.value?.confidence, + ); + addField( + 'ExpiryDate', + doc.expiryDate.value?.text, + doc.expiryDate.value?.confidence, + ); + addField( + 'GivenNames', + doc.givenNames.value?.text, + doc.givenNames.value?.confidence, + ); + addField( + 'LicenseCategories', + doc.licenseCategories?.value?.text, + doc.licenseCategories?.value?.confidence, + ); addField('Photo', doc.photo.value?.text, doc.photo.value?.confidence); - addField('SerialNumber', doc.serialNumber?.value?.text, - doc.serialNumber?.value?.confidence); - addField('Signature', doc.signature.value?.text, - doc.signature.value?.confidence); - addField('Surname', doc.surname.value?.text, - doc.surname.value?.confidence); + addField( + 'SerialNumber', + doc.serialNumber?.value?.text, + doc.serialNumber?.value?.confidence, + ); + addField( + 'Signature', + doc.signature.value?.text, + doc.signature.value?.confidence, + ); + addField( + 'Surname', + doc.surname.value?.text, + doc.surname.value?.confidence, + ); break; case EuropeanDriverLicenseBack.DOCUMENT_TYPE: final doc = EuropeanDriverLicenseBack(document); - addField('Restrictions', doc.restrictions?.value?.text, - doc.restrictions?.value?.confidence); - addField('Categories A1', doc.categories.a1.validFrom?.value?.text, - doc.categories.a1.validFrom?.value?.confidence); - addField('Categories A2', doc.categories.a2.validFrom?.value?.text, - doc.categories.a2.validFrom?.value?.confidence); - addField('Categories B1', doc.categories.b1?.validFrom?.value?.text, - doc.categories.b1?.validFrom?.value?.confidence); + addField( + 'Restrictions', + doc.restrictions?.value?.text, + doc.restrictions?.value?.confidence, + ); + addField( + 'Categories A1', + doc.categories.a1.validFrom?.value?.text, + doc.categories.a1.validFrom?.value?.confidence, + ); + addField( + 'Categories A2', + doc.categories.a2.validFrom?.value?.text, + doc.categories.a2.validFrom?.value?.confidence, + ); + addField( + 'Categories B1', + doc.categories.b1?.validFrom?.value?.text, + doc.categories.b1?.validFrom?.value?.confidence, + ); //... break; default: @@ -250,8 +495,11 @@ class ExtractedDocumentDataPreview extends StatelessWidget { } return Scaffold( - appBar: ScanbotAppBar('Extracted Documents Data', - showBackButton: true, context: context), + appBar: ScanbotAppBar( + 'Extracted Documents Data', + showBackButton: true, + context: context, + ), body: SingleChildScrollView( padding: const EdgeInsets.all(16), child: Column( @@ -272,4 +520,4 @@ class ExtractedDocumentDataPreview extends StatelessWidget { return const Text('No image available'); } } -} \ No newline at end of file +} diff --git a/lib/ui/preview/medical_certificate_preview.dart b/lib/ui/preview/medical_certificate_preview.dart deleted file mode 100644 index ddbf59b..0000000 --- a/lib/ui/preview/medical_certificate_preview.dart +++ /dev/null @@ -1,76 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:scanbot_sdk/scanbot_sdk_ui.dart'; - -import '../../utility/utils.dart'; - -class MedicalCertificatePreviewWidget extends StatelessWidget { - final MedicalCertificateScanningResult result; - - const MedicalCertificatePreviewWidget(this.result, {super.key}); - - @override - Widget build(BuildContext context) { - final checkBoxes = result.checkBoxes; - final patientFields = result.patientInfoBox.fields; - final dateFields = result.dates; - - return Scaffold( - appBar: ScanbotAppBar('Scanned Certificate', showBackButton: true, context: context), - body: ListView( - padding: const EdgeInsets.all(16), - children: [ - _buildImagePreview(result.croppedImage), - const SizedBox(height: 24), - ..._buildFields(context, checkBoxes, patientFields, dateFields), - ], - ), - ); - } - - Widget _buildImagePreview(ImageRef? image) { - if (image?.buffer != null) { - return Image.memory(image!.buffer!, fit: BoxFit.contain); - } else { - return const Text('No image available'); - } - } - - List _buildFields( - BuildContext context, - List checkBoxes, - List patientFields, - List dateFields, - ) { - final List children = []; - - void add(String title, String? value, double? confidence, - {bool large = false}) { - children.add(Text(title, style: Theme.of(context).textTheme.titleMedium)); - if (value != null && value.isNotEmpty) { - children - .add(Text(value, style: Theme.of(context).textTheme.bodyMedium)); - } - if (confidence != null && confidence.isFinite) { - children.add(Text( - 'Confidence: ${confidence.toStringAsFixed(2)}', - style: Theme.of(context).textTheme.labelSmall, - )); - } - children.add(SizedBox(height: large ? 16 : 12)); - } - - for (var cb in checkBoxes) { - add(cb.type.name, cb.checked.toString(), cb.checkedConfidence); - } - - for (var pf in patientFields) { - add(pf.type.name, pf.value, pf.recognitionConfidence); - } - - for (var df in dateFields) { - add(df.type.name, df.value, df.recognitionConfidence); - } - - return children; - } -} diff --git a/lib/ui/preview/mrz_document_preview.dart b/lib/ui/preview/mrz_document_preview.dart index ad29516..a3fd4c8 100644 --- a/lib/ui/preview/mrz_document_preview.dart +++ b/lib/ui/preview/mrz_document_preview.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/material.dart' as material; -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; import '../../utility/utils.dart'; @@ -8,11 +8,11 @@ class MrzDocumentResultPreview extends StatelessWidget { final MrzScannerUiResult? uiResult; final MrzScannerResult? scannerResult; - const MrzDocumentResultPreview({ - super.key, - this.uiResult, - this.scannerResult, - }) : assert(uiResult != null || scannerResult != null, 'At least one result must be provided'); + const MrzDocumentResultPreview({super.key, this.uiResult, this.scannerResult}) + : assert( + uiResult != null || scannerResult != null, + 'At least one result must be provided', + ); @override Widget build(BuildContext context) { @@ -21,7 +21,11 @@ class MrzDocumentResultPreview extends StatelessWidget { if (document == null) { return Scaffold( - appBar: ScanbotAppBar('MRZ Document Preview', showBackButton: true, context: context), + appBar: ScanbotAppBar( + 'MRZ Document Preview', + showBackButton: true, + context: context, + ), body: const Center(child: Text('No MRZ data available')), ); } @@ -32,7 +36,9 @@ class MrzDocumentResultPreview extends StatelessWidget { void addField(String title, String? value, {bool largeGap = false}) { children.add(Text(title, style: Theme.of(context).textTheme.titleMedium)); - children.add(Text(value ?? '', style: Theme.of(context).textTheme.bodyMedium)); + children.add( + Text(value ?? '', style: Theme.of(context).textTheme.bodyMedium), + ); children.add(SizedBox(height: largeGap ? 16 : 12)); } @@ -46,7 +52,11 @@ class MrzDocumentResultPreview extends StatelessWidget { addField('Expiry Date', mrz.expiryDate?.value?.text); return Scaffold( - appBar: ScanbotAppBar('MRZ Document Preview', showBackButton: true, context: context), + appBar: ScanbotAppBar( + 'MRZ Document Preview', + showBackButton: true, + context: context, + ), body: ListView( padding: const material.EdgeInsets.all(16), children: children, diff --git a/lib/ui/preview/text_pattern_preview.dart b/lib/ui/preview/text_pattern_preview.dart index 9f7364e..5586967 100644 --- a/lib/ui/preview/text_pattern_preview.dart +++ b/lib/ui/preview/text_pattern_preview.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/material.dart' as material; -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; import '../../utility/utils.dart'; @@ -13,14 +13,25 @@ class TextPatternScannerUiResultPreview extends StatelessWidget { Widget build(BuildContext context) { List children = []; - void addField(String title, String? value, double? confidence, {bool largeGap = false}) { + void addField( + String title, + String? value, + double? confidence, { + bool largeGap = false, + }) { children.add(Text(title, style: Theme.of(context).textTheme.titleMedium)); if (value != null && value.isNotEmpty) { - children.add(Text(value, style: Theme.of(context).textTheme.bodyMedium)); + children.add( + Text(value, style: Theme.of(context).textTheme.bodyMedium), + ); } if (confidence != null && confidence.isFinite) { - children.add(Text('Confidence: ${confidence.toStringAsFixed(2)}', - style: Theme.of(context).textTheme.labelSmall)); + children.add( + Text( + 'Confidence: ${confidence.toStringAsFixed(2)}', + style: Theme.of(context).textTheme.labelSmall, + ), + ); } children.add(SizedBox(height: largeGap ? 16 : 12)); } @@ -34,7 +45,11 @@ class TextPatternScannerUiResultPreview extends StatelessWidget { } return Scaffold( - appBar: ScanbotAppBar('Text Pattern Result', showBackButton: true, context: context), + appBar: ScanbotAppBar( + 'Text Pattern Result', + showBackButton: true, + context: context, + ), body: ListView( padding: const material.EdgeInsets.all(16), children: children, diff --git a/lib/ui/preview/vin_preview.dart b/lib/ui/preview/vin_preview.dart index 8520ca4..ab1b0d4 100644 --- a/lib/ui/preview/vin_preview.dart +++ b/lib/ui/preview/vin_preview.dart @@ -1,41 +1,55 @@ import 'package:flutter/material.dart'; import 'package:flutter/material.dart' as material; -import 'package:scanbot_sdk/scanbot_sdk_ui_v2.dart'; +import 'package:scanbot_sdk/scanbot_sdk.dart'; import '../../utility/utils.dart'; class VinScannerResultPreview extends StatelessWidget { - final VinScannerUiResult? uiResult; - final VinScannerResult? scanningResult; + final VinScannerUiResult? uiResult; + final VinScannerResult? scanningResult; - const VinScannerResultPreview({ - super.key, - this.uiResult, - this.scanningResult, - }) : assert(uiResult != null || scanningResult != null, - 'At least one result must be provided'); + const VinScannerResultPreview({super.key, this.uiResult, this.scanningResult}) + : assert( + uiResult != null || scanningResult != null, + 'At least one result must be provided', + ); - @override + @override Widget build(BuildContext context) { final textResult = scanningResult?.textResult ?? uiResult?.textResult; - final barcodeResult = scanningResult?.barcodeResult ?? uiResult?.barcodeResult; + final barcodeResult = + scanningResult?.barcodeResult ?? uiResult?.barcodeResult; List children = []; - void addField(String title, String? value, [double? confidence, bool largeGap = false]) { + void addField( + String title, + String? value, [ + double? confidence, + bool largeGap = false, + ]) { children.add(Text(title, style: Theme.of(context).textTheme.titleMedium)); if (value != null && value.isNotEmpty) { - children.add(Text(value, style: Theme.of(context).textTheme.bodyMedium)); + children.add( + Text(value, style: Theme.of(context).textTheme.bodyMedium), + ); } if (confidence != null && confidence.isFinite) { - children.add(Text('Confidence: ${confidence.toStringAsFixed(2)}', - style: Theme.of(context).textTheme.labelSmall)); + children.add( + Text( + 'Confidence: ${confidence.toStringAsFixed(2)}', + style: Theme.of(context).textTheme.labelSmall, + ), + ); } children.add(SizedBox(height: largeGap ? 16 : 12)); } addField('Text VIN', textResult!.rawText, textResult.confidence, true); - addField('Validation', textResult.validationSuccessful ? 'Valid' : 'Invalid'); + addField( + 'Validation', + textResult.validationSuccessful ? 'Valid' : 'Invalid', + ); for (final word in textResult.wordBoxes) { addField('Word', word.text, word.recognitionConfidence); @@ -45,12 +59,17 @@ class VinScannerResultPreview extends StatelessWidget { addField('Barcode Extraction Status', barcodeResult.status.name); if (barcodeResult.rectangle.isNotEmpty) { - final rectText = barcodeResult.rectangle.map((p) => '(${p.x}, ${p.y})').join(', '); + final rectText = + barcodeResult.rectangle.map((p) => '(${p.x}, ${p.y})').join(', '); addField('Barcode Rectangle', rectText); } return Scaffold( - appBar: ScanbotAppBar('VIN Scanner Result', showBackButton: true, context: context), + appBar: ScanbotAppBar( + 'VIN Scanner Result', + showBackButton: true, + context: context, + ), body: ListView( padding: const material.EdgeInsets.all(16), children: children, diff --git a/lib/ui/progress_dialog.dart b/lib/ui/progress_dialog.dart index 986c893..ea5b3d0 100644 --- a/lib/ui/progress_dialog.dart +++ b/lib/ui/progress_dialog.dart @@ -11,9 +11,15 @@ ProgressDialogType? _progressDialogType; bool _barrierDismissible = true, _showLogs = false; TextStyle _progressTextStyle = const TextStyle( - color: Colors.black, fontSize: 13.0, fontWeight: FontWeight.w400), + color: Colors.black, + fontSize: 13.0, + fontWeight: FontWeight.w400, + ), _messageStyle = const TextStyle( - color: Colors.black, fontSize: 19.0, fontWeight: FontWeight.w600); + color: Colors.black, + fontSize: 19.0, + fontWeight: FontWeight.w600, + ); double _dialogElevation = 8.0, _borderRadius = 8.0; Color _backgroundColor = Colors.white; @@ -24,25 +30,30 @@ Widget _progressWidget = Container(); class ProgressDialog { late _Body _dialog; - ProgressDialog(BuildContext context, - {ProgressDialogType? type, bool? isDismissible, bool? showLogs}) { + ProgressDialog( + BuildContext context, { + ProgressDialogType? type, + bool? isDismissible, + bool? showLogs, + }) { _context = context; _progressDialogType = type ?? ProgressDialogType.Normal; _barrierDismissible = isDismissible ?? true; _showLogs = showLogs ?? false; } - void style( - {double? progress, - double? maxProgress, - String? message, - Widget? progressWidget, - Color? backgroundColor, - TextStyle? progressTextStyle, - TextStyle? messageTextStyle, - double? elevation, - double? borderRadius, - Curve? insetAnimCurve}) { + void style({ + double? progress, + double? maxProgress, + String? message, + Widget? progressWidget, + Color? backgroundColor, + TextStyle? progressTextStyle, + TextStyle? messageTextStyle, + double? elevation, + double? borderRadius, + Curve? insetAnimCurve, + }) { if (_isShowing) return; if (_progressDialogType == ProgressDialogType.Download) { _progress = progress ?? _progress; @@ -59,13 +70,14 @@ class ProgressDialog { _insetAnimCurve = insetAnimCurve ?? _insetAnimCurve; } - void update( - {double? progress, - double? maxProgress, - String? message, - Widget? progressWidget, - TextStyle? progressTextStyle, - TextStyle? messageTextStyle}) { + void update({ + double? progress, + double? maxProgress, + String? message, + Widget? progressWidget, + TextStyle? progressTextStyle, + TextStyle? messageTextStyle, + }) { if (_progressDialogType == ProgressDialogType.Download) { _progress = progress ?? _progress; } @@ -132,16 +144,15 @@ class ProgressDialog { return Future.value(_barrierDismissible); }, child: Dialog( - backgroundColor: _backgroundColor, - insetAnimationCurve: _insetAnimCurve, - insetAnimationDuration: const Duration(milliseconds: 100), - elevation: _dialogElevation, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.all( - Radius.circular(_borderRadius), - ), - ), - child: _dialog), + backgroundColor: _backgroundColor, + insetAnimationCurve: _insetAnimCurve, + insetAnimationDuration: const Duration(milliseconds: 100), + elevation: _dialogElevation, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(_borderRadius)), + ), + child: _dialog, + ), ); }, ); @@ -181,35 +192,38 @@ class _BodyState extends State<_Body> { Widget build(BuildContext context) { return SizedBox( height: 100.0, - child: Row(children: [ - const SizedBox(width: 10.0), - SizedBox( - width: 60.0, - height: 60.0, - child: _progressWidget, - ), - const SizedBox(width: 15.0), - Expanded( - child: _progressDialogType == ProgressDialogType.Normal - ? Text(_dialogMessage, - textAlign: TextAlign.justify, style: _messageStyle) - : Stack( - children: [ - Positioned( - top: 30.0, - child: Text(_dialogMessage, style: _messageStyle), - ), - Positioned( - bottom: 10.0, - right: 10.0, - child: Text('$_progress/$_maxProgress', - style: _progressTextStyle), - ), - ], - ), - ), - const SizedBox(width: 10.0) - ]), + child: Row( + children: [ + const SizedBox(width: 10.0), + SizedBox(width: 60.0, height: 60.0, child: _progressWidget), + const SizedBox(width: 15.0), + Expanded( + child: _progressDialogType == ProgressDialogType.Normal + ? Text( + _dialogMessage, + textAlign: TextAlign.justify, + style: _messageStyle, + ) + : Stack( + children: [ + Positioned( + top: 30.0, + child: Text(_dialogMessage, style: _messageStyle), + ), + Positioned( + bottom: 10.0, + right: 10.0, + child: Text( + '$_progress/$_maxProgress', + style: _progressTextStyle, + ), + ), + ], + ), + ), + const SizedBox(width: 10.0), + ], + ), ); } } diff --git a/lib/utility/generic_document_helper.dart b/lib/utility/generic_document_helper.dart index 99e7346..646c195 100644 --- a/lib/utility/generic_document_helper.dart +++ b/lib/utility/generic_document_helper.dart @@ -9,18 +9,17 @@ class GenericDocumentHelper { return Padding( padding: const EdgeInsets.all(8.0), - child: Text( - ''' + child: Text(''' Document: ${genericDocument.type.name} Field: ${wrappedGenericFieldValue?.type.name ?? "N/A"} Value: ${wrappedGenericFieldValue?.value?.text ?? "N/A"} -''', - style: const TextStyle(inherit: true, color: Colors.black), - ), +''', style: const TextStyle(inherit: true, color: Colors.black)), ); } - static TextFieldWrapper? _getGenericFieldValue(GenericDocument genericDocument) { + static TextFieldWrapper? _getGenericFieldValue( + GenericDocument genericDocument, + ) { switch (genericDocument.type.name) { case BoardingPass.DOCUMENT_TYPE: return BoardingPass(genericDocument).electronicTicketIndicator; diff --git a/lib/utility/utils.dart b/lib/utility/utils.dart index 6d369c3..d04586e 100644 --- a/lib/utility/utils.dart +++ b/lib/utility/utils.dart @@ -9,7 +9,7 @@ const bool shouldInitWithEncryption = false; const enableImagesInScannedBarcodesResults = false; final selectedFormatsNotifier = ValueNotifier>( - BarcodeFormats.all.toSet() + BarcodeFormats.all.toSet(), ); const Color ScanbotRedColor = Color(0xFFc8193c); @@ -22,36 +22,32 @@ const AppBarTitleTextStyle = TextStyle( ); AppBar ScanbotAppBar( - String title, { - bool showBackButton = false, - BuildContext? context, - VoidCallback? onBack, - List? actions, - }) { + String title, { + bool showBackButton = false, + BuildContext? context, + VoidCallback? onBack, + List? actions, +}) { return AppBar( - iconTheme: const IconThemeData( - color: Colors.white, - ), + iconTheme: const IconThemeData(color: Colors.white), backgroundColor: ScanbotRedColor, leading: showBackButton && context != null ? GestureDetector( - onTap: onBack ?? () => Navigator.of(context).pop(), - child: const Icon(Icons.arrow_back, color: Colors.white), - ) + onTap: onBack ?? () => Navigator.of(context).pop(), + child: const Icon(Icons.arrow_back, color: Colors.white), + ) : null, - title: Text( - title, - style: AppBarTitleTextStyle, - ), + title: Text(title, style: AppBarTitleTextStyle), actions: actions, ); } -Future showAlertDialog(BuildContext context, String textToShow, - {String? title}) async { - Widget text = SimpleDialogOption( - child: Text(textToShow), - ); +Future showAlertDialog( + BuildContext context, + String textToShow, { + String? title, +}) async { + Widget text = SimpleDialogOption(child: Text(textToShow)); final dialog = AlertDialog( title: title != null ? Text(title) : null, @@ -85,9 +81,7 @@ void showResultTextDialog(BuildContext context, result) { var alert = AlertDialog( title: const Text('Result'), content: Text(result), - actions: [ - okButton, - ], + actions: [okButton], ); showDialog( @@ -99,23 +93,22 @@ void showResultTextDialog(BuildContext context, result) { } Future checkLicenseStatus(BuildContext context) async { - final result = await ScanbotSdk.getLicenseStatus(); - if (result.isLicenseValid) { + final result = await ScanbotSdk.getLicenseInfo(); + if (result is Ok && result.value.isValid) { return true; } await showAlertDialog( - context, 'Scanbot SDK (trial) period or license has expired.', - title: 'Info'); + context, + 'Scanbot SDK (trial) period or license has expired.', + title: 'Info', + ); return false; } Future _launchScanbotSDKURL() async { var url = Uri.parse("https://scanbot.io/"); if (await canLaunchUrl(url)) { - await launchUrl( - url, - mode: LaunchMode.externalApplication, - ); + await launchUrl(url, mode: LaunchMode.externalApplication); } else { throw 'Could not launch $url'; } @@ -136,18 +129,13 @@ Widget buildBottomNavigationBar(BuildContext context) { ), child: const Text( 'Learn More About Scanbot SDK', - style: TextStyle( - color: ScanbotRedColor, - ), + style: TextStyle(color: ScanbotRedColor), ), ), const SizedBox(height: 4), const Text( - 'Copyright 2025 Scanbot SDK GmbH. All rights reserved.', - style: TextStyle( - fontSize: 10, - color: Colors.black, - ), + 'Copyright 2026 Scanbot SDK GmbH. All rights reserved.', + style: TextStyle(fontSize: 10, color: Colors.black), textAlign: TextAlign.center, ), const SizedBox(height: 16), @@ -159,4 +147,3 @@ Widget buildBottomNavigationBar(BuildContext context) { Future selectImageFromLibrary() async { return await ImagePicker().pickImage(source: picker.ImageSource.gallery); } - diff --git a/pubspec.yaml b/pubspec.yaml index ec53683..6fc83ee 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ version: 1.0.0+1 environment: sdk: ">=3.0.0 <4.0.0" - flutter: '>=3.24.0' + flutter: '>=3.27.0' dependencies: flutter: