Native APIs
Fluuter:Platform Channels
path_provider
致力於封裝生態系統。作用是找出文件儲存在特定平台上的位置。
path_provider. dart
Future<Directory> getTemporaryDirectory() async {
final String path =
await _channel. invokeMethod('get TemporaryDocumentsDirectory'); //呼叫
if (path == null) {
return null;
}
return Directory(path);
PathProviderplugin.m
[channel setMethodCallHandler:^(FlutterMethodCall* call,
FlutterResult result) {
if ([@"getTemporaryDirectory" isEqualToString:call. method]) { //傳回
result ([self getTemporaryDirectory]);
}else (...) {
...
}];