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
HRESULTnow throwWindowsExceptionon failure - Logical return values are returned directly instead of via out-parameters
- APIs returning
-
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
- Such APIs now return
-
Strongly typed Win32 handles
- Opaque handles (e.g.,
HKEY,HWND,HICON) are now extension types instead of plainintorPointervalues
- Opaque handles (e.g.,
-
Win32
BOOLmapped to Dartbool- Applies uniformly to return values, parameters, and struct fields
-
Enums are now extension types
- Replaces raw
intconstants with strongly typed extension types
- Replaces raw
-
Explicit COM lifetime management
- Automatic cleanup via
Finalizerhas been removed - COM objects must be released explicitly or managed with
Arena
- Automatic cleanup via
-
COM and
HRESULTAPI simplificationsQueryInterface-style methods now return interfaces directly- Manual
HRESULTchecks and pointer plumbing are eliminated
-
Major string API cleanup
- Renamed and simplified string conversion helpers
- Removed
TEXT(),BSTRclass, and legacy helpers
-
GUID API redesign
- Removed
Guidclass and string-based helpers GUIDstruct is now the single, explicit representation
- Removed
-
winsock2library removed- All Winsock APIs are now exported directly from
win32.dart
- All Winsock APIs are now exported directly from
-
Dispatcher API redesign
- Strongly typed results
- No manual
VARIANTorDISPPARAMSconstruction - Explicit ownership and cleanup
See the Migration Guide with examples and mechanical migration steps.
🚀 Features​
-
Scope-based lifetime management
- New extensions for
Arenato manage native memory and COM lifetimes
- New extensions for
-
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 viaWin32Result<T>
- Atomic capture of
-
Cleaner, more consistent conversion APIs
- Unified naming and semantics for strings, binary data, and
FILETIMEvalues
- Unified naming and semantics for strings, binary data, and
-
Native memory leak detection via
package:ffi_leak_tracker- Tracks allocations with call stacks and timestamps; see the Leak Tracking guide for details