To send a message to native we use invokeMethod , as below. invokeMethod is an async method so we must add await and wrap the call inside an async (Future) method. If there is a result that’s sent back from native it will be assigned to the response variable.
Read moreHow do I add native code to Flutter?
Writing custom platform-specific code
Read moreHow do you make a Flutter plugin?
How to write a Flutter plugin
Read moreHow do you specify a platform in flutter?
Writing custom platform-specific code
Read moreHow do I know if my device is on flutter?
Run the app
Read moreHow do I know what platform my flutter is on?
Step 1: Add the import statement import ‘package:flutter/foundation. dart’; to your file. The above code snippet checks if the current platform is Android or not. It first detects the current platform using defaultTargetPlatform and compares it with the values inside the TargetPlatform.22 Kas 2021
Read more