Skip to content

[camera_platform_interface] VideoRecordedEvent == and hashCode disagree #195396

Open
flutter/packages
#13452

Description

@ChandraChaan

Steps to reproduce

final a = VideoRecordedEvent(1, XFile('/tmp/video.mp4'), null);
final b = VideoRecordedEvent(1, XFile('/tmp/video.mp4'), null);
print(a == b);                 // true
print(a.hashCode == b.hashCode); // false

final c = VideoRecordedEvent(1, XFile('/tmp/other.mp4'), null);
print(a == c);                 // true

Expected results

Events that are == have the same hashCode, and events for different video files aren't equal.

Actual results

VideoRecordedEvent.operator == doesn't compare file, but hashCode hashes the XFile object itself. XFile has no value equality, so:

  • two events for the same recording (for example, one created by VideoRecordedEvent.fromJson) are == but have different hash codes, which breaks the ==/hashCode contract and makes them misbehave in sets and maps;
  • two events for different files compare equal.

Package version

camera_platform_interface 2.15.0 (main as of today)

Activity

  1. suryaKommana2662 commented on Oct 27, 2026

    @suryaKommana2662
    Contributor

    @ChandraChaan Thanks for the report. I was able to reproduce the issue locally. Routing to team-ecosystem for further investigation.

    Reproduction code

    import 'package:material_ui/material_ui.dart';
    import 'package:camera_platform_interface/camera_platform_interface.dart';
    
    void main() {
      final a = VideoRecordedEvent(
        1,
        XFile('/tmp/video.mp4'),
        null,
      );
    
      final b = VideoRecordedEvent(
        1,
        XFile('/tmp/video.mp4'),
        null,
      );
    
      final c = VideoRecordedEvent(
        1,
        XFile('/tmp/other.mp4'),
        null,
      );
    
      debugPrint('a == b: ${a == b}');
      debugPrint('a.hashCode == b.hashCode: ${a.hashCode == b.hashCode}');
      debugPrint('a == c: ${a == c}');
    
      runApp(
        const MaterialApp(
          home: Scaffold(
            body: Center(
              child: Text('Check the terminal for reproduction results.'),
            ),
          ),
        ),
      );
    }
    

    Output:

    a == b: true
    a.hashCode == b.hashCode: false
    a == c: true
    

    Flutter Doctor Output

    [✓] Flutter (Channel master, 3.50.0-1.0.pre-209, on macOS 27.0 26A428 darwin-arm64, locale en-IN) [1,160ms]
        • Flutter version 3.50.0-1.0.pre-209 on channel master at /Users/suryakommana/develop/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 7b0a985e54 (4 days ago), 2026-10-23 00:20:16 +0000
        • Engine revision 7b0a985e54
        • Dart version 3.15.0 (build 3.15.0-67.0.dev)
        • DevTools version 2.61.0
        • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets,
          enable-record-use, enable-swift-package-manager, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration, enable-riscv64, enable-hcpp
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [1,289ms]
        • Android SDK at /Users/suryakommana/Library/Android/sdk
        • Emulator version 37.1.11.0 (build_id 15917651) (CL:N/A)
        • Platform android-37.0, build-tools 36.0.0
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
          This is the JDK bundled with the latest Android Studio installation on this machine.
          To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
        • Java version OpenJDK Runtime Environment (build 25.0.2+-15348964-b329.117)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 27.1) [589ms]
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 27A9275
        • CocoaPods version 1.17.0
    
    [✓] Chrome - develop for the web [3ms]
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Connected device (3 available) [5.9s]
        • iPhone 18 Pro (mobile) • D80F2104-E911-4251-BEDD-E67D9B7EBF58 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-27-0 (simulator)
        • macOS (desktop)        • macos                                • darwin-arm64   • macOS 27.0 26A428 darwin-arm64
        • Chrome (web)           • chrome                               • web-javascript • Google Chrome 156.0.8078.48
    
    [✓] Network resources [455ms]
        • All expected network resources are available.
    
    • No issues found!
  2. added
    packageflutter/packages repository. See also p: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Oct 27, 2026
  3. ChandraChaan commented on Oct 27, 2026

    @ChandraChaan
    Author

    Thanks for confirming! The fix is in flutter/packages#13452. Its tests cover both cases from your sample: equal events now have equal hash codes, and events with different files are no longer equal. It's a draft for now because I already have two open PRs in flutter/packages; I'll mark it ready for review as soon as one of them lands.

  4. added
    P2Important issues not at the top of the work list
    on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listhas reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: cameraThe camera pluginpackageflutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions