From bddd166a1c93166c083387961049d9450964bc76 Mon Sep 17 00:00:00 2001 From: Bruno Tavares Date: Fri, 22 Jul 2022 13:00:57 -0300 Subject: [PATCH] Implement new method channels to avoid warnings Since the upgrade to Flutter 3.0 there were new method channels introduced. This commit implement a new method channel specific for macos to avoid the warnings and restore functionality --- path_provider/plugin.go | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/path_provider/plugin.go b/path_provider/plugin.go index 72f2e02..046b285 100644 --- a/path_provider/plugin.go +++ b/path_provider/plugin.go @@ -11,7 +11,10 @@ import ( "github.com/go-flutter-desktop/go-flutter/plugin" ) -const channelName = "plugins.flutter.io/path_provider" +var channelNames = []string{ + "plugins.flutter.io/path_provider", + "plugins.flutter.io/path_provider_macos", +} // PathProviderPlugin implements flutter.Plugin and handles method calls to // the plugins.flutter.io/path_provider channel. @@ -38,15 +41,18 @@ func (p *PathProviderPlugin) InitPlugin(messenger plugin.BinaryMessenger) error return errors.New("PathProviderPlugin.ApplicationName must be set") } - channel := plugin.NewMethodChannel(messenger, channelName, plugin.StandardMethodCodec{}) - channel.HandleFunc("getTemporaryDirectory", p.handleTempDir) - channel.HandleFunc("getApplicationSupportDirectory", p.handleAppSupportDir) - channel.HandleFunc("getLibraryDirectory", p.handleLibraryDir) // MacOS only - channel.HandleFunc("getApplicationDocumentsDirectory", p.handleAppDocumentsDir) - channel.HandleFunc("getStorageDirectory", p.returnError) // Android only - channel.HandleFunc("getExternalCacheDirectories", p.returnError) // Android only - channel.HandleFunc("getExternalStorageDirectories", p.returnError) // Android only - channel.HandleFunc("getDownloadsDirectory", p.handleDownloadsDir) + for _, channelName := range channelNames { + channel := plugin.NewMethodChannel(messenger, channelName, plugin.StandardMethodCodec{}) + channel.HandleFunc("getTemporaryDirectory", p.handleTempDir) + channel.HandleFunc("getApplicationSupportDirectory", p.handleAppSupportDir) + channel.HandleFunc("getLibraryDirectory", p.handleLibraryDir) // MacOS only + channel.HandleFunc("getApplicationDocumentsDirectory", p.handleAppDocumentsDir) + channel.HandleFunc("getStorageDirectory", p.returnError) // Android only + channel.HandleFunc("getExternalCacheDirectories", p.returnError) // Android only + channel.HandleFunc("getExternalStorageDirectories", p.returnError) // Android only + channel.HandleFunc("getDownloadsDirectory", p.handleDownloadsDir) + } + return nil }