Skip to content

Implement new method channels to avoid warnings #669

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

Merged
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions application.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func NewApplication(opt ...Option) *Application {
opt = append(opt, AddPlugin(defaultAccessibilityPlugin))
opt = append(opt, AddPlugin(defaultIsolatePlugin))
opt = append(opt, AddPlugin(defaultMousecursorPlugin))
opt = append(opt, AddPlugin(defaultRestorationPlugin))

// apply all configs
for _, o := range opt {
Expand Down
6 changes: 6 additions & 0 deletions navigation.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ var defaultNavigationPlugin = &navigationPlugin{}

func (p *navigationPlugin) InitPlugin(messenger plugin.BinaryMessenger) error {
p.channel = plugin.NewMethodChannel(messenger, navigationChannelName, plugin.JSONMethodCodec{})

// Ignored: This information isn't properly formated to set the window.SetTitle
p.channel.HandleFuncSync("routeUpdated", func(_ interface{}) (interface{}, error) { return nil, nil })

// Currently ignored on platforms other than web
p.channel.HandleFuncSync("selectSingleEntryHistory", func(_ interface{}) (interface{}, error) { return nil, nil })
p.channel.HandleFuncSync("routeInformationUpdated", func(_ interface{}) (interface{}, error) { return nil, nil })

return nil
}
14 changes: 14 additions & 0 deletions platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ func (p *platformPlugin) InitPlugin(messenger plugin.BinaryMessenger) error {

channel.HandleFuncSync("Clipboard.setData", p.handleClipboardSetData)
channel.HandleFuncSync("Clipboard.getData", p.handleClipboardGetData)
channel.HandleFuncSync("Clipboard.hasStrings", p.handleClipboardHasString)

channel.HandleFuncSync("SystemNavigator.pop", p.handleSystemNavigatorPop)
channel.HandleFunc("SystemChrome.setApplicationSwitcherDescription", p.handleWindowSetTitle)

Expand Down Expand Up @@ -89,6 +91,18 @@ func (p *platformPlugin) handleClipboardGetData(arguments interface{}) (reply in
return reply, nil
}

func (p *platformPlugin) handleClipboardHasString(arguments interface{}) (reply interface{}, err error) {
var clipText string
clipText = p.window.GetClipboardString()

reply = struct {
Value bool `json:"value"`
}{
Value: len(clipText) > 0,
}
return reply, nil
}

func (p *platformPlugin) handleWindowSetTitle(arguments interface{}) (reply interface{}, err error) {
// triggers flutter framework initialized callbacks
for _, f := range p.flutterInitialized {
Expand Down
19 changes: 19 additions & 0 deletions restoration.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package flutter

import (
"github.com/go-flutter-desktop/go-flutter/plugin"
)

type restorationPlugin struct{}

// all hardcoded because theres not pluggable renderer system.
var defaultRestorationPlugin = &restorationPlugin{}

var _ Plugin = &restorationPlugin{} // compile-time type check

func (p *restorationPlugin) InitPlugin(messenger plugin.BinaryMessenger) error {
channel := plugin.NewMethodChannel(messenger, "flutter/restoration", plugin.StandardMethodCodec{})
// Ignored: desktop doesn't need application "restoration"
channel.HandleFunc("get", func(_ interface{}) (interface{}, error) { return nil, nil })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this, desktop CAN support restoration so it's better to either:

  • Implement it
  • Leave the warning

Copy link
Member

@pchampio pchampio Jul 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Humm, acutally, I don't know if this is a feature for desktop: https://api.flutter.dev/flutter/services/RestorationManager-class.html

Mobile operating systems use the concept of state restoration to provide the illusion that apps continue to run in the background forever

What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it's not intended for desktop

return nil
}
2 changes: 2 additions & 0 deletions text-input.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ func (p *textinputPlugin) InitPlugin(messenger plugin.BinaryMessenger) error {
})
// Ignored: This information is used by the flutter Web Engine
p.channel.HandleFuncSync("TextInput.setStyle", func(_ interface{}) (interface{}, error) { return nil, nil })
// Ignored: Used on MacOS to position accent selection menu
p.channel.HandleFuncSync("TextInput.setCaretRect", func(_ interface{}) (interface{}, error) { return nil, nil })
// Ignored: GLFW dosn't support setting the input method of the current cursor location #426
p.channel.HandleFuncSync("TextInput.setEditableSizeAndTransform", func(_ interface{}) (interface{}, error) { return nil, nil })
// Ignored: GLFW dosn't support setting the input method of the current cursor location #426
Expand Down