GetStream / stream-chat-flutter

Flutter Chat SDK - Build your own chat app experience using Dart, Flutter and the Stream Chat Messaging API.
https://getstream.io/chat/sdk/flutter/
Other
880 stars 313 forks source link

"Invalid argument(s): No host specified in URI" when channel has no image #1931

Closed Jonny1987 closed 2 weeks ago

Jonny1987 commented 4 weeks ago

Which packages are you using?

stream_chat_flutter

On what platforms did you experience the issue?

Android

What version are you using?

7.1.0 flutter 3.22.0

What happened?

════════ Exception caught by image resource service ════════════════════════════
The following ArgumentError was thrown resolving an image codec:
Invalid argument(s): No host specified in URI

When the exception was thrown, this was the stack:
#0      _HttpClient._openUrl (dart:_http/http_impl.dart:2749:9)
http_impl.dart:2749
#1      _HttpClient.openUrl (dart:_http/http_impl.dart:2620:7)
http_impl.dart:2620
#2      IOClient.send (package:http/src/io_client.dart:117:38)
io_client.dart:117
#3      HttpFileService.get (package:flutter_cache_manager/src/web/file_service.dart:37:44)
file_service.dart:37
#4      WebHelper._download (package:flutter_cache_manager/src/web/web_helper.dart:115:24)
web_helper.dart:115
#5      WebHelper._updateFile (package:flutter_cache_manager/src/web/web_helper.dart:97:28)
web_helper.dart:97
<asynchronous suspension>
#6      WebHelper._downloadOrAddToQueue (package:flutter_cache_manager/src/web/web_helper.dart:65:7)
web_helper.dart:65
<asynchronous suspension>

Image provider: CachedNetworkImageProvider("", scale: 1.0) 
 Image key: CachedNetworkImageProvider("", scale: 1.0): CachedNetworkImageProvider("", scale: 1.0)

Steps to reproduce

Ensure there is a channel which has no image associated.

Open any page in the app which pushes a screen using gorouter that is not wrapped with StreamChat 
(context.pushNamed())

(I'm still confused why this happens but not when the actual channel page is opened or loads)

Supporting info to reproduce

inside app.dart:

StreamChatTheme(
  data: streamChatTheme,
  child: MaterialApp.router(
    builder: (context, child) {
      return StreamChat(
        client: streamChatClient,
        useMaterial3: true,
        child: child,
      );
    },
    routerConfig: goRouter,
    ...
  },
)

Relevant log output

No response

Flutter analyze output

No issues

Flutter doctor output

[✓] Flutter (Channel stable, 3.22.0, on Ubuntu 22.04.4 LTS 6.5.0-28-generic, locale en_US.UTF-8)
    • Flutter version 3.22.0 on channel stable at /home/john/dev/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5dcb86f68f (3 weeks ago), 2024-05-09 07:39:20 -0500
    • Engine revision f6344b75dc
    • Dart version 3.4.0
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /home/john/Android/Sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /opt/android-studio/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • Ubuntu clang version 14.0.0-1ubuntu1.1
    • cmake version 3.22.1
    • ninja version 1.10.1
    • pkg-config version 0.29.2

[✓] Android Studio (version 2023.3)
    • Android Studio at /opt/android-studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)

[✓] VS Code (version 1.88.1)
    • VS Code at /usr/share/code
    • Flutter extension version 3.90.0

[✓] Connected device (4 available)
    • Pixel 3a (mobile)          • 05BAY1X5F2    • android-arm64  • Android 12 (API 32)
    • sdk gphone x86 64 (mobile) • emulator-5554 • android-x64    • Android 13 (API 33) (emulator)
    • Linux (desktop)            • linux         • linux-x64      • Ubuntu 22.04.4 LTS 6.5.0-28-generic
    • Chrome (web)               • chrome        • web-javascript • Google Chrome 123.0.6312.86

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Code of Conduct

Jonny1987 commented 4 weeks ago

This issue doesn't happen when I remove the channel tile's image by doing the following:

          child: StreamChannelListView(
            itemBuilder: (context, channels, index, defaultTile) {
                return defaultTile.copyWith(
                  leading: Container(width: 0),
                );
              },
           )
deven98 commented 2 weeks ago

Hey @Jonny1987, thanks for the report! #1949 will fix this bug. The image is no longer used if the channel does not have a set image. Just a note that CachedNetworkImage will still be used if the channel image is set but the image or link itself is not valid for some reason.

Thanks again for reporting and the fix should be rolled out in the next release.