Skip to content

Commit bddd166

Browse files
committed
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
1 parent c068143 commit bddd166

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

path_provider/plugin.go

+16-10
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ import (
1111
"github.com/go-flutter-desktop/go-flutter/plugin"
1212
)
1313

14-
const channelName = "plugins.flutter.io/path_provider"
14+
var channelNames = []string{
15+
"plugins.flutter.io/path_provider",
16+
"plugins.flutter.io/path_provider_macos",
17+
}
1518

1619
// PathProviderPlugin implements flutter.Plugin and handles method calls to
1720
// the plugins.flutter.io/path_provider channel.
@@ -38,15 +41,18 @@ func (p *PathProviderPlugin) InitPlugin(messenger plugin.BinaryMessenger) error
3841
return errors.New("PathProviderPlugin.ApplicationName must be set")
3942
}
4043

41-
channel := plugin.NewMethodChannel(messenger, channelName, plugin.StandardMethodCodec{})
42-
channel.HandleFunc("getTemporaryDirectory", p.handleTempDir)
43-
channel.HandleFunc("getApplicationSupportDirectory", p.handleAppSupportDir)
44-
channel.HandleFunc("getLibraryDirectory", p.handleLibraryDir) // MacOS only
45-
channel.HandleFunc("getApplicationDocumentsDirectory", p.handleAppDocumentsDir)
46-
channel.HandleFunc("getStorageDirectory", p.returnError) // Android only
47-
channel.HandleFunc("getExternalCacheDirectories", p.returnError) // Android only
48-
channel.HandleFunc("getExternalStorageDirectories", p.returnError) // Android only
49-
channel.HandleFunc("getDownloadsDirectory", p.handleDownloadsDir)
44+
for _, channelName := range channelNames {
45+
channel := plugin.NewMethodChannel(messenger, channelName, plugin.StandardMethodCodec{})
46+
channel.HandleFunc("getTemporaryDirectory", p.handleTempDir)
47+
channel.HandleFunc("getApplicationSupportDirectory", p.handleAppSupportDir)
48+
channel.HandleFunc("getLibraryDirectory", p.handleLibraryDir) // MacOS only
49+
channel.HandleFunc("getApplicationDocumentsDirectory", p.handleAppDocumentsDir)
50+
channel.HandleFunc("getStorageDirectory", p.returnError) // Android only
51+
channel.HandleFunc("getExternalCacheDirectories", p.returnError) // Android only
52+
channel.HandleFunc("getExternalStorageDirectories", p.returnError) // Android only
53+
channel.HandleFunc("getDownloadsDirectory", p.handleDownloadsDir)
54+
}
55+
5056
return nil
5157
}
5258

0 commit comments

Comments
 (0)