Just test the Flutter ffi pattern
Learn from the article:
https://www.raywenderlich.com/21512310-calling-native-libraries-in-flutter-with-dart-ffi
In the process, you’ll learn:
- About FFI and how it lets Dart code invoke code written in other languages.
- How FFI differs from Flutter platform channels.
- To automatically compile and link C code when building a Flutter app.
- How a Flutter app can use FFI to call code written in C.
- Wrote a C function.
- Compiled this function into a shared object and linked it into your Flutter app.
- Used FFI to locate the library and function signature.
- Bound the native function to a Dart function.
- Invoked the Dart function to return a double from the C function.
--
- Obtain a native char pointer.
- Convert the pointer to a UTF8/Dart String.
- Free the allocated memory.
- Pass the String back to your Flutter widget.
--
- Accepts a bool indicating whether to return Celsius or Fahrenheit values.
- Instantiates a struct with some very boring and static values, representing the forecasted temperature over the next three days.
- Converts these values to Celsius if useCelsius is true.
- Returns the struct.