A Flutter project demo for package Pigeon.
- Android native:
- Call open rest api from OpenWeather-API.
- Handling network response, error, exception.
- Load video from assets and convert to byte array.
- Flutter:
- Call native code via package Pigeon.
- Return custom Object values.
- Load video player from uint8List(get from native byte array response).
- IOS source code for Pigeon here including call native to get Response, nothing else.
- Pigeon input file
import 'package:pigeon/pigeon.dart';
@HostApi()
abstract class WeatherApi {
@async
String getWeatherByCityName(String cityName);
}
- Pigeon custom Object sample usage
import 'package:pigeon/pigeon.dart';
class VideoInfo {
String? title;
double? length;
}
class Video {
VideoInfo? videoInfo;
Uint8List? bytes;
}
@HostApi()
abstract class VideoApi {
Video sendVideoFromNative();
}
- Sample implement of Pigeon in native
WeatherApi.setup(
flutterEngine.dartExecutor.binaryMessenger,
WeatherPlatformApi(repository)
)
class WeatherPlatformApi(repository: IWeatherRepository) : WeatherApi {
...
}