Skip to content

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

@dkbast

Description

@dkbast

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpackage_info_plusstuff related to package_info_plus

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions