Skip to main content

6.0.0

🔄 Breaking Changes​

This release introduces a major redesign of the Win32 Dart API with a strong focus on type safety, deterministic resource management, and idiomatic Dart usage. Most changes are mechanical but widespread.

Key breaking changes include:

  • Exception-based error handling

    • APIs returning HRESULT now throw WindowsException on failure
    • Logical return values are returned directly instead of via out-parameters
  • New error model for APIs that call SetLastError()

    • Such APIs now return Win32Result<T> which captures both the logical return value and the associated last-error code atomically on the native side, ensuring the error state is preserved
  • Strongly typed Win32 handles

    • Opaque handles (e.g., HKEY, HWND, HICON) are now extension types instead of plain int or Pointer values
  • Win32 BOOL mapped to Dart bool

    • Applies uniformly to return values, parameters, and struct fields
  • Enums are now extension types

    • Replaces raw int constants with strongly typed extension types
  • Explicit COM lifetime management

    • Automatic cleanup via Finalizer has been removed
    • COM objects must be released explicitly or managed with Arena
  • COM and HRESULT API simplifications

    • QueryInterface-style methods now return interfaces directly
    • Manual HRESULT checks and pointer plumbing are eliminated
  • Major string API cleanup

    • Renamed and simplified string conversion helpers
    • Removed TEXT(), BSTR class, and legacy helpers
  • GUID API redesign

    • Removed Guid class and string-based helpers
    • GUID struct is now the single, explicit representation
  • winsock2 library removed

    • All Winsock APIs are now exported directly from win32.dart
  • Dispatcher API redesign

    • Strongly typed results
    • No manual VARIANT or DISPPARAMS construction
    • Explicit ownership and cleanup

See the Migration Guide with examples and mechanical migration steps.

🚀 Features​

  • Scope-based lifetime management

    • New extensions for Arena to manage native memory and COM lifetimes
  • Much stronger type safety across the API surface

    • Typed handles, enums, booleans, GUIDs, and COM interfaces
  • More idiomatic Dart APIs

    • Fewer pointers, fewer out-parameters, clearer ownership rules
  • Reliable error handling

    • Atomic capture of GetLastError() values on native side, exposed via Win32Result<T>
  • Cleaner, more consistent conversion APIs

    • Unified naming and semantics for strings, binary data, and FILETIME values
  • Native memory leak detection via package:ffi_leak_tracker

    • Tracks allocations with call stacks and timestamps; see the Leak Tracking guide for details