Было выдано другое исключение: FormatException: недопустимый символ (на символе 6)

#dart #flutter

#dart #трепетание

Вопрос:

Я использую библиотеку flutter_advanced_networkimage для загрузки изображений с сервера с помощью заголовка. Но это приводит меня к исключению. Вот мой код:

           Image(
            image: AdvancedNetworkImage(
              '${widget.imageURL}',
              header: {
                "Authorization": this.authCode,
              },
              useDiskCache: true,
            ),
            fit: BoxFit.cover,
          ),
  

Ошибка:

 flutter: This is image URL https://WEBSITEURL.ch/static/activities/picmee/1_01032019203603_0.png
flutter: ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
flutter: The following FormatException was thrown building PicMeeTile(dirty, state: _PicMeeTileState#0993e):
flutter: Invalid character (at character 6)
flutter: https://WEBSITEURL.ch/static/activities/picmee/1_01032019203603_0.png
flutter:      ^
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0      _Base64Decoder.decodeChunk (dart:convert/base64.dart:675:7)
flutter: #1      _Base64Decoder.decode (dart:convert/base64.dart:600:14)
flutter: #2      Base64Decoder.convert (dart:convert/base64.dart:480:26)
flutter: #3      Base64Codec.decode (dart:convert/base64.dart:77:47)
flutter: #4      _PicMeeTileState.build (package:app/screens/picmee/list/picmeetile.dart:87:27)
flutter: #5      StatefulElement.build (package:flutter/src/widgets/framework.dart:3809:27)
flutter: #6      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3721:15)
flutter: #7      Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
flutter: #8      ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
flutter: #9      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
flutter: #10     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
flutter: #11     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
flutter: #12     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
flutter: #13     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
flutter: #14     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
flutter: #15     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
flutter: #16     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
flutter: #17     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
flutter: #18     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
flutter: #19     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
flutter: #20     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
flutter: #21     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
flutter: #22     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
flutter: #23     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
flutter: #24     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
flutter: #25     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
flutter: #26     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
flutter: #27     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
flutter: #28     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
flutter: #29     ParentDataElement.mount (package:flutter/src/widgets/framework.dart:4047:11)
flutter: #30     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
flutter: #31     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
flutter: #32     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
flutter: #33     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
flutter: #34     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
flutter: #35     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
flutter: #36     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
flutter: #37     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
flutter: #38     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
flutter: #39     SliverMultiBoxAdaptorElement.updateChild (package:flutter/src/widgets/sliver.dart:1030:36)
flutter: #40     SliverMultiBoxAdaptorElement.createChild.<anonymous closure> (package:flutter/src/widgets/sliver.dart:1015:20)
flutter: #41     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2266:19)
flutter: #42     SliverMultiBoxAdaptorElement.createChild (package:flutter/src/widgets/sliver.dart:1008:11)
flutter: #43     RenderSliverMultiBoxAdaptor._createOrObtainChild.<anonymous closure> (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:274:23)
flutter: #44     RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:1730:58)
flutter: #45     PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:799:15)
flutter: #46     RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:1730:13)
flutter: #47     RenderSliverMultiBoxAdaptor._createOrObtainChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:263:5)
flutter: #48     RenderSliverMultiBoxAdaptor.addInitialChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:347:5)
flutter: #49     RenderSliverList.performLayout (package:flutter/src/rendering/sliver_list.dart:78:12)
flutter: #50     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #51     RenderSliverPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:182:11)
flutter: #52     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #53     RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:405:13)
flutter: #54     RenderViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1316:12)
flutter: #55     RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1234:20)
flutter: #56     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #57     _RenderProxyBoxamp;RenderBoxamp;RenderObjectWithChildMixinamp;RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #58     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #59     _RenderProxyBoxamp;RenderBoxamp;RenderObjectWithChildMixinamp;RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #60     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #61     _RenderProxyBoxamp;RenderBoxamp;RenderObjectWithChildMixinamp;RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #62     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #63     _RenderProxyBoxamp;RenderBoxamp;RenderObjectWithChildMixinamp;RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #64     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #65     _RenderProxyBoxamp;RenderBoxamp;RenderObjectWithChildMixinamp;RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #66     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #67     MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:142:11)
flutter: #68     _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:339:7)
flutter: #69     MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:212:7)
flutter: #70     RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:356:14)
flutter: #71     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #72     _RenderProxyBoxamp;RenderBoxamp;RenderObjectWithChildMixinamp;RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #73     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #74     _RenderProxyBoxamp;RenderBoxamp;RenderObjectWithChildMixinamp;RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #75     _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1203:11)
flutter: #76     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #77     MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:142:11)
flutter: #78     _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:339:7)
flutter: #79     MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:212:7)
flutter: #80     RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:356:14)
flutter: #81     RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1509:7)
flutter: #82     PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:768:18)
flutter: #83     _WidgetsFlutterBindingamp;BindingBaseamp;GestureBindingamp;ServicesBindingamp;SchedulerBindingamp;PaintingBindingamp;SemanticsBindingamp;RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:281:19)
flutter: #84     _WidgetsFlutterBindingamp;BindingBaseamp;GestureBindingamp;ServicesBindingamp;SchedulerBindingamp;PaintingBindingamp;SemanticsBindingamp;RendererBindingamp;WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:686:13)
flutter: #85     _WidgetsFlutterBindingamp;BindingBaseamp;GestureBindingamp;ServicesBindingamp;SchedulerBindingamp;PaintingBindingamp;SemanticsBindingamp;RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:219:5)
flutter: #86     _WidgetsFlutterBindingamp;BindingBaseamp;GestureBindingamp;ServicesBindingamp;SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
flutter: #87     _WidgetsFlutterBindingamp;BindingBaseamp;GestureBindingamp;ServicesBindingamp;SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
flutter: #88     _WidgetsFlutterBindingamp;BindingBaseamp;GestureBindingamp;ServicesBindingamp;SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
flutter: #89     _invoke (dart:ui/hooks.dart:159:13)
flutter: #90     _drawFrame (dart:ui/hooks.dart:148:3)
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: This is image URL https://WEBSITEURL.ch/static/activities/picmee/1_01032019203603_0.png
flutter: Another exception was thrown: FormatException: Invalid character (at character 6)
  

Ответ №1:

Трассировка стека, похоже, не связана с показанным кодом. Похоже, что оно из picmeetile.dart line 87 , где есть декодирование base 64. По-видимому, декодируемая строка не является допустимой базой 64.

Комментарии:

1. Я обнаружил, что это не связано с этим кодом. Он генерируется откуда-то еще.