Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement new method channels to avoid warnings #83

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions path_provider/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
}

Expand Down