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

message_widget_content_components.dart is not accessible #1941

Closed guplem closed 2 weeks ago

guplem commented 2 weeks ago

Which packages are you using?

stream_chat_flutter

On what platforms did you experience the issue?

iOS, Android, Web, Windows, MacOS, Linux

What version are you using?

^7.2.1

What happened?

I am unable to access the file \stream_chat_flutter-7.2.1\lib\src\message_widget\message_widget_content_components.dart in a "safe" or "recommended" manner.

The warning arises from the following import statement:

import 'package:stream_chat_flutter/src/message_widget/message_widget_content_components.dart';

The warning is:

Import of a library in the 'lib/src' directory of another package. Try importing a public library that exports this library, or removing the import.

This is explained here: Dart Linter Rule: implementation_imports.

Issue: I am using StreamMessageListView with its messageBuilder parameter. Inside this, I am modifying the "default message" with a custom one and I want to modify bottomRowBuilderWithDefaultWidget's default widget. However, I can't do this because the type BottomRow cannot be imported since it is exported by message_widget_content_components.dart and not by stream_chat_flutter.dart.

Code:

                    StreamMessageListView(
                      messageBuilder: (BuildContext context, MessageDetails details, List<Message> messages, StreamMessageWidget defaultMessage) {
                        return defaultMessage.copyWith(
                          bottomRowBuilderWithDefaultWidget: (BuildContext context, Message message, BottomRow defaultWidget) {
                            return defaultWidget.copyWith(
                                // Do something with the default widget, but I can't because the type BottomRow can not be imported since it is exported by message_widget_content_components.dart and it is not exported by stream_chat_flutter.dart
                                );
                          },
                        );
                      },
                    )

Steps to reproduce

1. Implement my code
2. Try to access the BottomRow class to be able to implement a type-safe "copy with" of the default widget.

Supporting info to reproduce

No response

Relevant log output

No response

Flutter analyze output

info - 'appBarHeight' is deprecated and shouldn't be used. Use SafeArea instead - lib\V2\components\custom_app_bar_v2.dart:67:45 -
          deprecated_member_use_from_same_package
   info - 'appBarHeight' is deprecated and shouldn't be used. Use SafeArea instead - lib\V2\components\custom_app_bar_v2.dart:69:38 -
          deprecated_member_use_from_same_package
   info - The imported package 'http' isn't a dependency of the importing package - lib\V2\data_engine\clients\rest_client.dart:16:8 - depend_on_referenced_packages    
   info - The file name 'deleteAccount_page.dart' isn't a lower_case_with_underscores identifier - lib\V2\modules\auth\pages\deleteAccount_page.dart:1:1 - file_names   
   info - 'appBarHeight' is deprecated and shouldn't be used. Use SafeArea instead - lib\V2\modules\chat_v3\components\appbar\chat_appbar.dart:44:45 -
          deprecated_member_use_from_same_package
   info - Don't return 'null' from a method with a return type of 'void' - lib\V2\modules\chat_v3\components\input_bar\media_menu.dart:217:25 -
          avoid_returning_null_for_void
   info - Import of a library in the 'lib/src' directory of another package - lib\V2\modules\chat_v3\pages\chat.dart:28:8 - implementation_imports
   info - 'fetchOne' is deprecated and shouldn't be used. Use [fetch] instead - lib\V2\modules\chat_v3\repository.dart:40:43 - deprecated_member_use_from_same_package  
   info - The imported package 'http' isn't a dependency of the importing package - lib\V2\modules\create\components\create_modal_gallery.dart:23:8 -
          depend_on_referenced_packages
   info - The imported package 'http' isn't a dependency of the importing package - lib\V2\modules\create\components\create_modal_location.dart:22:8 -
          depend_on_referenced_packages
   info - Don't use 'BuildContext's across async gaps, guarded by an unrelated 'mounted' check - lib\V2\modules\create\components\create_modal_location.dart:81:11 -    
          use_build_context_synchronously
   info - 'clearAllData' is deprecated and shouldn't be used. Use remove() instead.
This Should not be used because some data should be permanent (like deviceId) and is not supposed to be deleted -
       lib\V2\modules\dev_tools\components\shared_preferences.dart:30:60 - deprecated_member_use_from_same_package
   info - Use 'const' with the constructor to improve performance - lib\V2\modules\feed\components\feed.dart:65:34 - prefer_const_constructors
   info - The import of 'package:flutter/widgets.dart' is unnecessary because all of the used elements are also provided by the import of
          'package:flutter/cupertino.dart' - lib\V2\modules\feed\components\feed_top_bar.dart:25:8 - unnecessary_import
   info - Don't use 'BuildContext's across async gaps - lib\V2\modules\live\pages\live_page.dart:122:40 - use_build_context_synchronously
   info - 'fetchOne' is deprecated and shouldn't be used. Use [fetch] instead - lib\V2\modules\live\pages\live_page.dart:207:24 -
          deprecated_member_use_from_same_package
   info - 'fetchOne' is deprecated and shouldn't be used. Use [fetch] instead - lib\V2\modules\live\pages\live_page.dart:604:66 -
          deprecated_member_use_from_same_package
   info - Don't use 'BuildContext's across async gaps - lib\V2\modules\location\map_page.dart:53:122 - use_build_context_synchronously
   info - The file name 'topInfo_tile.dart' isn't a lower_case_with_underscores identifier - lib\V2\modules\people\components\topInfo_tile.dart:1:1 - file_names        
   info - 'fetchOne' is deprecated and shouldn't be used. Use [fetch] instead - lib\V2\modules\plan\components\plan_participants_modal.dart:38:24 -
          deprecated_member_use_from_same_package
   info - 'fetchOne' is deprecated and shouldn't be used. Use [fetch] instead - lib\V2\modules\plan\components\plan_participants_modal.dart:89:28 -
          deprecated_member_use_from_same_package
   info - 'fetchOne' is deprecated and shouldn't be used. Use [fetch] instead - lib\V2\modules\plan\components\plan_share_modal.dart:57:41 -
          deprecated_member_use_from_same_package
   info - 'fetchOne' is deprecated and shouldn't be used. Use [fetch] instead - lib\V2\modules\plan\components\plan_share_modal.dart:89:53 -
          deprecated_member_use_from_same_package
   info - 'fetchOne' is deprecated and shouldn't be used. Use [fetch] instead - lib\V2\modules\plan\components\plan_share_modal.dart:93:43 -
          deprecated_member_use_from_same_package
   info - Don't use 'BuildContext's across async gaps - lib\V2\modules\plan\components\plan_share_modal.dart:107:25 - use_build_context_synchronously
   info - Don't use 'BuildContext's across async gaps - lib\V2\modules\plan\components\plan_share_modal.dart:110:95 - use_build_context_synchronously
   info - The import of 'package:flutter/widgets.dart' is unnecessary because all of the used elements are also provided by the import of
          'package:flutter/material.dart' - lib\V2\modules\plan\pages\plan_view.dart:47:8 - unnecessary_import
   info - 'fetchOne' is deprecated and shouldn't be used. Use [fetch] instead - lib\V2\modules\plan\pages\plan_view.dart:106:24 -
          deprecated_member_use_from_same_package
   info - Empty catch block - lib\V2\modules\push_notifications\service.dart:146:17 - empty_catches
   info - Empty catch block - lib\V2\modules\push_notifications\service.dart:164:17 - empty_catches
   info - Don't use 'BuildContext's across async gaps - lib\V2\modules\settings\components\modal_link_google.dart:89:87 - use_build_context_synchronously
   info - Don't use 'BuildContext's across async gaps - lib\V2\modules\settings\components\modal_link_google.dart:92:47 - use_build_context_synchronously
   info - Don't use 'BuildContext's across async gaps - lib\V2\modules\settings\components\modal_link_google.dart:113:87 - use_build_context_synchronously
   info - Don't use 'BuildContext's across async gaps - lib\V2\modules\settings\components\modal_link_google.dart:116:47 - use_build_context_synchronously
   info - Don't use 'BuildContext's across async gaps - lib\V2\modules\settings\page\settings_page.dart:261:121 - use_build_context_synchronously
   info - Don't use 'BuildContext's across async gaps - lib\V2\modules\settings\page\settings_page.dart:264:81 - use_build_context_synchronously
   info - Don't use 'BuildContext's across async gaps - lib\V2\modules\settings\page\settings_page.dart:289:121 - use_build_context_synchronously
   info - Don't use 'BuildContext's across async gaps - lib\V2\modules\settings\page\settings_page.dart:292:81 - use_build_context_synchronously
   info - The imported package 'http' isn't a dependency of the importing package - lib\V2\modules\url_data\models\urldata.dart:6:8 - depend_on_referenced_packages     
   info - Unnecessary empty statement - lib\V2\modules\user\pages\profile_page.dart:185:35 - empty_statements
   info - The file name 'inputFormat.dart' isn't a lower_case_with_underscores identifier - lib\V2\utils\extensions\inputFormat.dart:1:1 - file_names
   info - The imported package 'image' isn't a dependency of the importing package - lib\utils\utils.dart:11:8 - depend_on_referenced_packages

Flutter doctor output

[!] Flutter (Channel [user-branch], 3.19.6, on Microsoft Windows [Version 10.0.22631.3593], locale en-US)
    ! Flutter version 3.19.6 on channel [user-branch] at C:\Users\guill\DevFiles\flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install.
    ! Upstream repository unknown source is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
    • Framework revision 54e66469a9 (8 weeks ago), 2024-04-17 13:08:03 -0700
    • Engine revision c4cd48e186
    • Dart version 3.3.4
    • DevTools version 2.31.1
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at C:\Users\guill\AppData\Local\Android\sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0--11572160)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[!] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.31)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
    • Visual Studio Build Tools 2019 version 16.11.34114.132
    X The current Visual Studio installation is incomplete.
      Please use Visual Studio Installer to complete the installation or reinstall Visual Studio.

[√] Android Studio (version 2023.3)
    • Android Studio at C:\Program Files\Android\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--11572160)

[√] VS Code (version 1.90.0)
    • VS Code at C:\Users\guill\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from:
       https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (4 available)
    • CPH2493 (mobile)  • TSEY9LBYK7YHQO4X • android-arm64  • Android 14 (API 34)
    • Windows (desktop) • windows          • windows-x64    • Microsoft Windows [Version 10.0.22631.3593]
    • Chrome (web)      • chrome           • web-javascript • Google Chrome 125.0.6422.142
    • Edge (web)        • edge             • web-javascript • Microsoft Edge 125.0.2535.92

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

! Doctor found issues in 2 categories.

Code of Conduct

guplem commented 2 weeks ago

Adding the following line to the lib\stream_chat_flutter.dart would fix this issue:

export 'src/message_widget/message_widget_content_components.dart';
deven98 commented 2 weeks ago

I see the issue, I'm adding this to an additional export PR I have.

deven98 commented 2 weeks ago

Ah I see you created a PR as well :)