Skip to content

happymanx/Weather_FFI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Weather_FFI

Just test the Flutter ffi pattern

Learn from the article:

Calling Native Libraries in Flutter with Dart FFI

https://www.raywenderlich.com/21512310-calling-native-libraries-in-flutter-with-dart-ffi

In the process, you’ll learn:

  1. About FFI and how it lets Dart code invoke code written in other languages.
  2. How FFI differs from Flutter platform channels.
  3. To automatically compile and link C code when building a Flutter app.
  4. How a Flutter app can use FFI to call code written in C.

  1. Wrote a C function.
  2. Compiled this function into a shared object and linked it into your Flutter app.
  3. Used FFI to locate the library and function signature.
  4. Bound the native function to a Dart function.
  5. Invoked the Dart function to return a double from the C function.

--

  1. Obtain a native char pointer.
  2. Convert the pointer to a UTF8/Dart String.
  3. Free the allocated memory.
  4. Pass the String back to your Flutter widget.

--

  1. Accepts a bool indicating whether to return Celsius or Fahrenheit values.
  2. Instantiates a struct with some very boring and static values, representing the forecasted temperature over the next three days.
  3. Converts these values to Celsius if useCelsius is true.
  4. Returns the struct.

About

Just test the Flutter ffi pattern

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published