Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base64 decode not decoding large base64 encoded png images. #33860

Closed
pneves001 opened this issue Jul 14, 2018 · 11 comments
Closed

Base64 decode not decoding large base64 encoded png images. #33860

pneves001 opened this issue Jul 14, 2018 · 11 comments
Labels
closed-as-intended Closed as the reported issue is expected behavior

Comments

@pneves001
Copy link

pneves001 commented Jul 14, 2018

The current version of dart-lang/sdk I'm using is the one used in flutter.

The decode function throwing an exception. It doesn't matter which Base64 decoder I use.

BASE64.decode()
Base64Decode()
BASE64URL.decode()

None of these functions work properly with larger images.

I've added the image in a pastebin that is generating the problem. https://pastebin.com/tDV4NfPV

The version of dart-lang/sdk is the version used by flutter. I've also tried importing the image using new Image.network. Nothing I do seems to fix this issue.

The exception it is throwing is as follows:

2018-07-14 07:03:42.403259-0700 Runner[846:1232425] flutter: ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
2018-07-14 07:03:42.457603-0700 Runner[846:1232425] flutter: The following FormatException was thrown building MediaQuery(MediaQueryData(size: Size(320.0,
2018-07-14 07:03:42.457720-0700 Runner[846:1232425] flutter: 568.0), devicePixelRatio: 2.0, textScaleFactor: 1.0, padding: EdgeInsets.zero, viewInsets:
2018-07-14 07:03:42.457816-0700 Runner[846:1232425] flutter: EdgeInsets.zero, alwaysUse24HourFormat: false)):
2018-07-14 07:03:42.457930-0700 Runner[846:1232425] flutter: Invalid character (at character 5)
2018-07-14 07:03:42.458020-0700 Runner[846:1232425] flutter: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASAAAADACAIAAAAr0inhAAAABGdBT...
2018-07-14 07:03:42.458106-0700 Runner[846:1232425] flutter:     ^
2018-07-14 07:03:42.462946-0700 Runner[846:1232425] flutter:
2018-07-14 07:03:42.463034-0700 Runner[846:1232425] flutter: When the exception was thrown, this was the stack:
2018-07-14 07:03:42.475493-0700 Runner[846:1232425] flutter: #0      _Base64Decoder.decodeChunk (dart:convert/base64.dart:737:7)
2018-07-14 07:03:42.475748-0700 Runner[846:1232425] flutter: #1      _Base64Decoder.decode (dart:convert/base64.dart:658:14)
2018-07-14 07:03:42.476184-0700 Runner[846:1232425] flutter: #2      Base64Decoder.convert (dart:convert/base64.dart:520:32)
2018-07-14 07:03:42.476605-0700 Runner[846:1232425] flutter: #3      Base64Codec.decode (dart:convert/base64.dart:95:47)
2018-07-14 07:03:42.477007-0700 Runner[846:1232425] flutter: #4      _Giftcards._makeElement (package:loyality/Giftcards.dart:170:41)
2018-07-14 07:03:42.477355-0700 Runner[846:1232425] flutter: #5      _Giftcards.build.<anonymous closure> (package:loyality/Giftcards.dart:126:83)
2018-07-14 07:03:42.477775-0700 Runner[846:1232425] flutter: #6      SliverChildBuilderDelegate.build (package:flutter/src/widgets/sliver.dart:197:20)
2018-07-14 07:03:42.478191-0700 Runner[846:1232425] flutter: #7      SliverMultiBoxAdaptorElement._build.<anonymous closure> (package:flutter/src/widgets/sliver.dart:716:67)
2018-07-14 07:03:42.478607-0700 Runner[846:1232425] flutter: #8      _HashMap.putIfAbsent (dart:collection/runtime/libcollection_patch.dart:143:29)
2018-07-14 07:03:42.479009-0700 Runner[846:1232425] flutter: #9      SliverMultiBoxAdaptorElement._build (package:flutter/src/widgets/sliver.dart:716:26)
2018-07-14 07:03:42.479758-0700 Runner[846:1232425] flutter: #10     SliverMultiBoxAdaptorElement.performRebuild (package:flutter/src/widgets/sliver.dart:702:69)
2018-07-14 07:03:42.479990-0700 Runner[846:1232425] flutter: #11     SliverMultiBoxAdaptorElement.update (package:flutter/src/widgets/sliver.dart:671:7)
2018-07-14 07:03:42.480465-0700 Runner[846:1232425] flutter: #12     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.480841-0700 Runner[846:1232425] flutter: #13     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3666:16)
2018-07-14 07:03:42.481236-0700 Runner[846:1232425] flutter: #14     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
2018-07-14 07:03:42.481677-0700 Runner[846:1232425] flutter: #15     ProxyElement.update (package:flutter/src/widgets/framework.dart:3922:5)
2018-07-14 07:03:42.482136-0700 Runner[846:1232425] flutter: #16     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.482570-0700 Runner[846:1232425] flutter: #17     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4674:14)
2018-07-14 07:03:42.483041-0700 Runner[846:1232425] flutter: #18     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.483454-0700 Runner[846:1232425] flutter: #19     RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:4392:32)
2018-07-14 07:03:42.483860-0700 Runner[846:1232425] flutter: #20     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4782:17)
2018-07-14 07:03:42.484251-0700 Runner[846:1232425] flutter: #21     _ViewportElement.update (package:flutter/src/widgets/viewport.dart:192:11)
2018-07-14 07:03:42.484631-0700 Runner[846:1232425] flutter: #22     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.485069-0700 Runner[846:1232425] flutter: #23     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3666:16)
2018-07-14 07:03:42.485482-0700 Runner[846:1232425] flutter: #24     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
2018-07-14 07:03:42.485958-0700 Runner[846:1232425] flutter: #25     ProxyElement.update (package:flutter/src/widgets/framework.dart:3922:5)
2018-07-14 07:03:42.486319-0700 Runner[846:1232425] flutter: #26     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.487020-0700 Runner[846:1232425] flutter: #27     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4674:14)
2018-07-14 07:03:42.487329-0700 Runner[846:1232425] flutter: #28     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.487828-0700 Runner[846:1232425] flutter: #29     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4674:14)
2018-07-14 07:03:42.488148-0700 Runner[846:1232425] flutter: #30     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.488624-0700 Runner[846:1232425] flutter: #31     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4674:14)
2018-07-14 07:03:42.489013-0700 Runner[846:1232425] flutter: #32     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.489471-0700 Runner[846:1232425] flutter: #33     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4674:14)
2018-07-14 07:03:42.489867-0700 Runner[846:1232425] flutter: #34     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.490593-0700 Runner[846:1232425] flutter: #35     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3666:16)
2018-07-14 07:03:42.491284-0700 Runner[846:1232425] flutter: #36     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
2018-07-14 07:03:42.491972-0700 Runner[846:1232425] flutter: #37     StatefulElement.update (package:flutter/src/widgets/framework.dart:3812:5)
2018-07-14 07:03:42.492376-0700 Runner[846:1232425] flutter: #38     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.492760-0700 Runner[846:1232425] flutter: #39     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4674:14)
2018-07-14 07:03:42.493117-0700 Runner[846:1232425] flutter: #40     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.493527-0700 Runner[846:1232425] flutter: #41     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3666:16)
2018-07-14 07:03:42.493926-0700 Runner[846:1232425] flutter: #42     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
2018-07-14 07:03:42.494300-0700 Runner[846:1232425] flutter: #43     StatefulElement.update (package:flutter/src/widgets/framework.dart:3812:5)
2018-07-14 07:03:42.494631-0700 Runner[846:1232425] flutter: #44     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.495005-0700 Runner[846:1232425] flutter: #45     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3666:16)
2018-07-14 07:03:42.495437-0700 Runner[846:1232425] flutter: #46     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
2018-07-14 07:03:42.495941-0700 Runner[846:1232425] flutter: #47     ProxyElement.update (package:flutter/src/widgets/framework.dart:3922:5)
2018-07-14 07:03:42.496312-0700 Runner[846:1232425] flutter: #48     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.496728-0700 Runner[846:1232425] flutter: #49     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3666:16)
2018-07-14 07:03:42.497136-0700 Runner[846:1232425] flutter: #50     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
2018-07-14 07:03:42.497511-0700 Runner[846:1232425] flutter: #51     StatelessElement.update (package:flutter/src/widgets/framework.dart:3715:5)
2018-07-14 07:03:42.497980-0700 Runner[846:1232425] flutter: #52     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.498404-0700 Runner[846:1232425] flutter: #53     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4674:14)
2018-07-14 07:03:42.498791-0700 Runner[846:1232425] flutter: #54     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.499187-0700 Runner[846:1232425] flutter: #55     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3666:16)
2018-07-14 07:03:42.499717-0700 Runner[846:1232425] flutter: #56     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
2018-07-14 07:03:42.500067-0700 Runner[846:1232425] flutter: #57     ProxyElement.update (package:flutter/src/widgets/framework.dart:3922:5)
2018-07-14 07:03:42.500423-0700 Runner[846:1232425] flutter: #58     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.500792-0700 Runner[846:1232425] flutter: #59     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3666:16)
2018-07-14 07:03:42.501445-0700 Runner[846:1232425] flutter: #60     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
2018-07-14 07:03:42.501681-0700 Runner[846:1232425] flutter: #61     ProxyElement.update (package:flutter/src/widgets/framework.dart:3922:5)
2018-07-14 07:03:42.502145-0700 Runner[846:1232425] flutter: #62     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.502528-0700 Runner[846:1232425] flutter: #63     RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:4392:32)
2018-07-14 07:03:42.503506-0700 Runner[846:1232425] flutter: #64     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4782:17)
2018-07-14 07:03:42.503762-0700 Runner[846:1232425] flutter: #65     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.504123-0700 Runner[846:1232425] flutter: #66     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3666:16)
2018-07-14 07:03:42.504562-0700 Runner[846:1232425] flutter: #67     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
2018-07-14 07:03:42.504936-0700 Runner[846:1232425] flutter: #68     StatefulElement.update (package:flutter/src/widgets/framework.dart:3812:5)
2018-07-14 07:03:42.505337-0700 Runner[846:1232425] flutter: #69     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.505710-0700 Runner[846:1232425] flutter: #70     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3666:16)
2018-07-14 07:03:42.506109-0700 Runner[846:1232425] flutter: #71     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
2018-07-14 07:03:42.506441-0700 Runner[846:1232425] flutter: #72     ProxyElement.update (package:flutter/src/widgets/framework.dart:3922:5)
2018-07-14 07:03:42.506778-0700 Runner[846:1232425] flutter: #73     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.507129-0700 Runner[846:1232425] flutter: #74     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3666:16)
2018-07-14 07:03:42.507550-0700 Runner[846:1232425] flutter: #75     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
2018-07-14 07:03:42.508265-0700 Runner[846:1232425] flutter: #76     StatefulElement.update (package:flutter/src/widgets/framework.dart:3812:5)
2018-07-14 07:03:42.508630-0700 Runner[846:1232425] flutter: #77     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.509087-0700 Runner[846:1232425] flutter: #78     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4674:14)
2018-07-14 07:03:42.509404-0700 Runner[846:1232425] flutter: #79     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.509879-0700 Runner[846:1232425] flutter: #80     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3666:16)
2018-07-14 07:03:42.510188-0700 Runner[846:1232425] flutter: #81     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
2018-07-14 07:03:42.510673-0700 Runner[846:1232425] flutter: #82     StatelessElement.update (package:flutter/src/widgets/framework.dart:3715:5)
2018-07-14 07:03:42.511076-0700 Runner[846:1232425] flutter: #83     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.511526-0700 Runner[846:1232425] flutter: #84     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4674:14)
2018-07-14 07:03:42.512139-0700 Runner[846:1232425] flutter: #85     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.512515-0700 Runner[846:1232425] flutter: #86     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3666:16)
2018-07-14 07:03:42.512918-0700 Runner[846:1232425] flutter: #87     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
2018-07-14 07:03:42.513388-0700 Runner[846:1232425] flutter: #88     StatefulElement.update (package:flutter/src/widgets/framework.dart:3812:5)
2018-07-14 07:03:42.513782-0700 Runner[846:1232425] flutter: #89     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.514175-0700 Runner[846:1232425] flutter: #90     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3666:16)
2018-07-14 07:03:42.514572-0700 Runner[846:1232425] flutter: #91     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
2018-07-14 07:03:42.515013-0700 Runner[846:1232425] flutter: #92     StatefulElement.update (package:flutter/src/widgets/framework.dart:3812:5)
2018-07-14 07:03:42.515439-0700 Runner[846:1232425] flutter: #93     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.515858-0700 Runner[846:1232425] flutter: #94     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3666:16)
2018-07-14 07:03:42.516350-0700 Runner[846:1232425] flutter: #95     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
2018-07-14 07:03:42.516744-0700 Runner[846:1232425] flutter: #96     ProxyElement.update (package:flutter/src/widgets/framework.dart:3922:5)
2018-07-14 07:03:42.517209-0700 Runner[846:1232425] flutter: #97     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.517643-0700 Runner[846:1232425] flutter: #98     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3666:16)
2018-07-14 07:03:42.518067-0700 Runner[846:1232425] flutter: #99     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
2018-07-14 07:03:42.518459-0700 Runner[846:1232425] flutter: #100    ProxyElement.update (package:flutter/src/widgets/framework.dart:3922:5)
2018-07-14 07:03:42.518821-0700 Runner[846:1232425] flutter: #101    Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.519225-0700 Runner[846:1232425] flutter: #102    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3666:16)
2018-07-14 07:03:42.519671-0700 Runner[846:1232425] flutter: #103    Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
2018-07-14 07:03:42.520106-0700 Runner[846:1232425] flutter: #104    StatefulElement.update (package:flutter/src/widgets/framework.dart:3812:5)
2018-07-14 07:03:42.520528-0700 Runner[846:1232425] flutter: #105    Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
2018-07-14 07:03:42.520883-0700 Runner[846:1232425] flutter: #106    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3666:16)
2018-07-14 07:03:42.521333-0700 Runner[846:1232425] flutter: #107    Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
2018-07-14 07:03:42.521679-0700 Runner[846:1232425] flutter: #108    BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2255:33)
2018-07-14 07:03:42.522089-0700 Runner[846:1232425] flutter: #109    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:626:20)
2018-07-14 07:03:42.522588-0700 Runner[846:1232425] flutter: #110    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:208:5)
2018-07-14 07:03:42.522918-0700 Runner[846:1232425] flutter: #111    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
2018-07-14 07:03:42.523158-0700 Runner[846:1232425] flutter: #112    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
2018-07-14 07:03:42.523686-0700 Runner[846:1232425] flutter: #113    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
2018-07-14 07:03:42.523977-0700 Runner[846:1232425] flutter: #114    _invoke (dart:ui/hooks.dart:120:13)
2018-07-14 07:03:42.524215-0700 Runner[846:1232425] flutter: #115    _drawFrame (dart:ui/hooks.dart:109:3)
2018-07-14 07:03:42.525499-0700 Runner[846:1232425] flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
2018-07-14 07:03:42.579820-0700 Runner[846:1232425] flutter: Another exception was thrown: A RenderSliverPadding expected a child of type RenderSliver but received a child of type RenderErrorBox.
2018-07-14 07:03:42.594939-0700 Runner[846:1232425] flutter: Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3510 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
2018-07-14 07:03:42.603003-0700 Runner[846:1232425] flutter: Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3510 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
2018-07-14 07:03:42.606890-0700 Runner[846:1232425] flutter: Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3510 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
2018-07-14 07:03:42.615159-0700 Runner[846:1232425] flutter: Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3510 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
2018-07-14 07:03:42.618720-0700 Runner[846:1232425] flutter: Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3510 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
2018-07-14 07:03:42.623599-0700 Runner[846:1232425] flutter: Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3510 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
2018-07-14 07:03:42.630714-0700 Runner[846:1232425] flutter: Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3510 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
2018-07-14 07:03:42.648642-0700 Runner[846:1232425] flutter: Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3510 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
2018-07-14 07:03:42.659015-0700 Runner[846:1232425] flutter: Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3510 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
2018-07-14 07:03:43.670257-0700 Runner[846:1232425] flutter: Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3510 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
2018-07-14 07:03:43.670467-0700 Runner[846:1232425] flutter: Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3510 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
2018-07-14 07:03:43.670597-0700 Runner[846:1232425] flutter: Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3510 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
2018-07-14 07:03:43.670722-0700 Runner[846:1232425] flutter: Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3510 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
2018-07-14 07:03:43.670845-0700 Runner[846:1232425] flutter: Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3510 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
2018-07-14 07:03:43.684430-0700 Runner[846:1232425] flutter: Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3510 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
2018-07-14 07:03:43.684588-0700 Runner[846:1232425] flutter: Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3510 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
2018-07-14 07:03:43.684714-0700 Runner[846:1232425] flutter: Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3510 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
2018-07-14 07:04:00.102795-0700 Runner[846:1232378] Status bar could not find cached time string image. Rendering in-process.
2018-07-14 07:08:00.018015-0700 Runner[846:1232378] Status bar could not find cached time string image. Rendering in-process.
2018-07-14 07:19:00.004282-0700 Runner[846:1232378] Status bar could not find cached time string image. Rendering in-process.
2018-07-14 07:20:00.003828-0700 Runner[846:1232378] Status bar could not find cached time string image. Rendering in-process.
2018-07-14 07:21:00.003619-0700 Runner[846:1232378] Status bar could not find cached time string image. Rendering in-process.
2018-07-14 07:22:00.003714-0700 Runner[846:1232378] Status bar could not find cached time string image. Rendering in-process.
2018-07-14 07:23:00.004148-0700 Runner[846:1232378] Status bar could not find cached time string image. Rendering in-process.
2018-07-14 07:24:00.003910-0700 Runner[846:1232378] Status bar could not find cached time string image. Rendering in-process.
@mraleph
Copy link
Member

mraleph commented Jul 15, 2018

Note that you are decoding a data:-URI and not a normal Base64 encoded string, so the error you are getting is absolutely correct. To decode data:-URI you can use Uri class, for example like this:

final UriData data = Uri.parse(yourString).data;
print(data.isBase64);  // Should print true
print(data.contentAsBytes());  // Would returns your image a Uint8List

@pneves001
Copy link
Author

You know that there is no documentation telling us this.

@mraleph
Copy link
Member

mraleph commented Jul 15, 2018

Could you clarify what exactly is missing from the documentation?

When you need to parse a URI then you need to use a Uri class, which is documented here.

Base64Decoder is documented here where it explicitly says “Decoder for base64 encoded data.“

If you have any concrete ideas of how this documentation can be improved please feel free to make a suggestion here or send a PR improving the documentation.

@pneves001
Copy link
Author

Reference documentation is pretty useless when there are no examples to show us how the class is used. There are no docs to suggest that we use the Uri.parse class to process a base 64 encoded image. I just assumed I worked pretty much the same way it worked when I generated the image on the server but in reverse. I had actually removed the leading data tag from the image before I attempted to base64 decode the image. It still didn't work.

Thanks for the help. The Uri.parse function worked. I just wish the docs had more examples to show us how to use the API. I find issues like this all over the internet when it comes to using different api. It's always a crapshoot as to figuring out what some of these classes are for or even how to use them.

@stevenwsg
Copy link

Did you solve this problem? Today i meet the same quuestion....

@Miedziaq
Copy link

Miedziaq commented Feb 16, 2022

i have the same issue at using any html viewer library :/
invalid character at base64 image...

looks like there is newlines/spaces in base64 generated by outlook,
this is issue of dart but flutter devs on github says that it is not supported characters in base64.

but every other technology works like a harm with it :) even html 🤣
what a kind of embarrassing explanation of issue :|
and unprofessional approach to the subject
flutter/flutter#98585

@mraleph
Copy link
Member

mraleph commented Feb 17, 2022

@Miedziaq you are free to remove new space characters from your string before passing them to Base64Decoder. Dart implements Base64 decoder per RFC 4648 which is rather strict and requires rejecting incorrectly formatted strings. What you get from Outlook is MIME Base64 encoding which is slightly different (RFC 2045), it splits base64 data into lines (max 76 characters in a line) and thus introduces CRLF breaks. If you expect to decode MIME Base64 you can just sanitise your input to remove new lines before passing it to the decoder.

We could theoretically add an option to Base64Decoder to accept MIME Base64 (by simply ignoring CRLF in the input). /cc @lrhn any opinion Lasse?

@lrhn
Copy link
Member

lrhn commented Feb 17, 2022

Base64 is really annoying to decode because you want to know the size of the decoded output first, so you can allocate a correctly sized Uint8List.
That's possible by counting the number of input characters and parsing the trailing padding. (But not if streaming the input, then you just need to grow your buffer occasionally. It would really have been a much better format if it started with the output length, even if just written as decimal.)
Or it's possible if you know the size ahead-of-time because of metadata, which is at least possible for the MIME encodings.

If we allow \n or \r\n or other whitespace sequences inside the encoded text, then we either have to scan the entire input once to find the length, then do it again to decode, or we risk over-allocating and needing to return a view on the (unnecessarily) larger buffer.

So, I wouldn't want to allow whitespace by default. It could be something you opt in to, getting wither a slower set-up or a larger allocation (and a slower decoding in any case, since you have to check every character for being whitespace).

So possible, but not desirable as a generally enabled feature. I'd probably want to do a Base64Mime codec for it, to keep the two decoders separate and individually tree-shakeable.

@Miedziaq
Copy link

Miedziaq commented Feb 17, 2022

basically yes I can, but if I want to use some html viewer library and pass html to it, (like outlook email or some other) the base64 is only inside img tag, so this is not that easy to read the html file from internet and then remove spaces/newlines only from the img instances. since probably every technology has no problem with it, why this is that problem in flutter/dart...

for angular, for html, for c# its doesnt matter if you have this spaces/newlines or not

this technology aspire to be very useful and non-problematic, but it is more than others in this topic on example. There is mess, and non informative error messages like in lovely JAVA :>

@Miedziaq
Copy link

Base64 is really annoying to decode because you want to know the size of the decoded output first, so you can allocate a correctly sized Uint8List. That's possible by counting the number of input characters and parsing the trailing padding. (But not if streaming the input, then you just need to grow your buffer occasionally. It would really have been a much better format if it started with the output length, even if just written as decimal.) Or it's possible if you know the size ahead-of-time because of metadata, which is at least possible for the MIME encodings.

If we allow \n or \r\n or other whitespace sequences inside the encoded text, then we either have to scan the entire input once to find the length, then do it again to decode, or we risk over-allocating and needing to return a view on the (unnecessarily) larger buffer.

So, I wouldn't want to allow whitespace by default. It could be something you opt in to, getting wither a slower set-up or a larger allocation (and a slower decoding in any case, since you have to check every character for being whitespace).

So possible, but not desirable as a generally enabled feature. I'd probably want to do a Base64Mime codec for it, to keep the two decoders separate and individually tree-shakeable.

so, maybe it will be a good idea to provide overloaded methods for sync and async calls / or some switch to be more strict or less?

in basic use its not a really problem to remove this spaces/new lines, but in complicated cases, removing this spaces from the whole html file and generally editing it can be problematic time consuming and slower than just ignore this chars by decoder.

maybe I should request this feature to providers of html libraries on flutter? Im passing html file only there and i cannot control it completely.

https://pub.dev/packages/flutter_html
https://pub.dev/documentation/flutter_html_view/latest/

this works properly only in flutter webview

@mraleph
Copy link
Member

mraleph commented Feb 17, 2022

Im passing html file only there and i cannot control it completely.

It does sound like it is a bug in those packages. If they implement some specification like HTML which is support a different form of Base64 which is more lenient than RFC 4648 then they should not directly pass the data to the Base64Decoder that Dart has.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-as-intended Closed as the reported issue is expected behavior
Projects
None yet
Development

No branches or pull requests

5 participants