Skip to content

[DartError] RangeError: Invalid value: Only valid value is 0: 1; #0 Array._checkIndex (dart:ffi-patch/ffi_patch.dart:349:7)#1 main (package:swiftsoft/main.dart)<asynchronous suspension> #1200

Open
@krll-kov

Description

@krll-kov

After updating flutter i started having errors everywhere where i use FFI Array in Structs when i try to access index greater then 0, why?

/// The TOKEN_PRIVILEGES structure contains information about a set
/// of privileges for an access token.
/// The LUID_AND_ATTRIBUTES structure represents a locally unique identifier
/// (LUID) and its attributes.
sealed class LuidAndAttributes extends Struct {
  external LUID luid;
  @Uint32()
  external int attributes;
}

base class LUID extends Struct {
  @Uint32()
  external int LowPart;

  @Int32()
  external int HighPart;
}

sealed class TokenPriviliges extends Struct {
  @Uint32()
  external int privilegeCount;
  @Array(1)
  external Array<LuidAndAttributes> privileges;
}

  final Pointer<TokenPriviliges> token = malloc<TokenPriviliges>();
  token.ref.privileges[0].luid.HighPart = 1;
  token.ref.privileges[0].luid.LowPart = 2;

  token.ref.privileges[1].luid.HighPart = 1;
  token.ref.privileges[1].luid.LowPart = 2;

  print([token.ref.privileges[0].luid.HighPart, token.ref.privileges[1].luid.HighPart]);
[DartError] RangeError: Invalid value: Only valid value is 0: 1; #0      Array._checkIndex (dart:ffi-patch/ffi_patch.dart:349:7)#1      main (package:swiftsoft/main.dart)<asynchronous suspension>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions