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

[Bug]: PackageInfo does not overwrite Hashcode and equals #1321

Closed
7 tasks done
dkbast opened this issue Nov 7, 2022 · 1 comment · Fixed by #1328
Closed
7 tasks done

[Bug]: PackageInfo does not overwrite Hashcode and equals #1321

dkbast opened this issue Nov 7, 2022 · 1 comment · Fixed by #1328
Labels
enhancement New feature or request package_info_plus stuff related to package_info_plus

Comments

@dkbast
Copy link
Contributor

dkbast commented Nov 7, 2022

Platform

testing

Plugin

package_info_plus

Version

3.0.1

Flutter SDK

3.3.6

Steps to reproduce

I stumbled across this issue when I wanted to use PackageInfo in a test and could not properly compare two instances as hashcode and equals is not overwritten.

https://github.com/fluttercommunity/plus_plugins/blob/main/packages/package_info_plus/package_info_plus/lib/package_info_plus.dart

Code Sample

mockValue = PackageInfo(
            appName: 'test',
            packageName: 'test',
            version: 'test',
            buildNumber: 'test',
          );

... execute test

expect(result, equals(PackageInfo(
          appName: 'test',
          packageName: 'test',
          version: 'test',
          buildNumber: 'test',
        )));

Logs

Expected: [Instance of 'PackageInfo']
    Actual: [Instance of 'PackageInfo']
     Which: at location [0] is <Instance of 'PackageInfo'> instead of <Instance of 'PackageInfo'>
  
  WARNING: Please ensure state instances extend Equatable, override == and hashCode, or implement Comparable.

Flutter Doctor

[✓] Flutter (Channel stable, 3.3.6, on macOS 12.3.1 21E258 darwin-arm, locale en-DE)
    • Flutter version 3.3.6 on channel stable at /opt/homebrew/Caskroom/flutter/2.5.3/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 6928314d50 (13 days ago), 2022-10-25 16:34:41 -0400
    • Engine revision 3ad69d7be3
    • Dart version 2.18.2
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0-rc1)
    • Android SDK at /Users/damianbast/Library/Android/sdk
    • Platform android-33, build-tools 32.0.0-rc1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 13A1030d
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • 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 11.0.11+0-b60-7772763)

[✓] Connected device (3 available)
    • iPhone 11 (mobile) • F17849CC-2710-40F5-BA75-3B7D81242F91 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)
    • macOS (desktop)    • macos                                • darwin-arm64   • macOS 12.3.1 21E258 darwin-arm
    • Chrome (web)       • chrome                               • web-javascript • Google Chrome 107.0.5304.87

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Checklist before submitting a bug

  • I Google'd a solution and I couldn't find it
  • I searched on StackOverflow for a solution and I couldn't find it
  • I read the README.md file of the plugin
  • I'm using the latest version of the plugin
  • All dependencies are up to date with flutter pub upgrade
  • I did a flutter clean
  • I tried running the example project
@dkbast dkbast added bug Something isn't working triage labels Nov 7, 2022
@miquelbeltran
Copy link
Member

It is always a good idea to use your own data objects instead of using the ones provided by 3rd parties in situations like this. But a PR with the overrides for equals and toString would be welcome if anyone wants to submit it.

@miquelbeltran miquelbeltran added enhancement New feature or request package_info_plus stuff related to package_info_plus and removed bug Something isn't working triage labels Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request package_info_plus stuff related to package_info_plus
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants