To convert a vector within a 2D array into Dart/Flutter, you can use the following steps:
int
, the struct definition in Dart/Flutter would look like this:import 'dart:ffi' as ffi;
class ExampleStruct extends ffi.Struct {
@ffi.Array.multi([10, 10]) // 10x10 2D array
late ffi.Array<ffi.Array<ffi.Int32>> vector;
}
ffi.Pointer
class to obtain a pointer to the 2D array. This pointer can be passed to an FFI function in order to operate on the array.// assuming the 2D array is named `myArray`:
var struct = ExampleStruct()
..vector = ffi.Array<ffi.Array<ffi.Int32>>.generate(
10, // outer dimension
(i) => ffi.Array<ffi.Int32>.generate(
10, // inner dimension
(j) => myArray[i][j],
),
);
var structPointer = struct.addressOf;
structPointer
to an FFI function to operate on the array.// assuming an FFI function named `operateOnArray`:
operateOnArray(structPointer);
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2021-12-27 11:00:00 +0000
Seen: 10 times
Last updated: Sep 09 '21
How can zooming similar to desktop be achieved in HTML webview browser using Flutter?
In what way can the appleID signin be utilized in flutter?
How to maintain state across different pages using flutter?
How can I change a CameraImage Stream into bytes or a file in Flutter?
How can the current page context be obtained by a Flutter GetX controller?