Skip to content

Commit f538461

Browse files
bltavaresPierre Champion | Drakirus
and
Pierre Champion | Drakirus
authored
Implement new method channels to avoid warnings (#669)
* Implement new method channels to avoid warnings Since the upgrade to Flutter 3.0 there were new method channels introduced. This commit implement a couple of them, to reduce the amount of warnings when running the project. Fixes #667 * Update restoration.go Co-authored-by: Pierre Champion | Drakirus <[email protected]>
1 parent 34eaff6 commit f538461

File tree

5 files changed

+42
-0
lines changed

5 files changed

+42
-0
lines changed

application.go

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ func NewApplication(opt ...Option) *Application {
5454
opt = append(opt, AddPlugin(defaultAccessibilityPlugin))
5555
opt = append(opt, AddPlugin(defaultIsolatePlugin))
5656
opt = append(opt, AddPlugin(defaultMousecursorPlugin))
57+
opt = append(opt, AddPlugin(defaultRestorationPlugin))
5758

5859
// apply all configs
5960
for _, o := range opt {

navigation.go

+6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ var defaultNavigationPlugin = &navigationPlugin{}
1717

1818
func (p *navigationPlugin) InitPlugin(messenger plugin.BinaryMessenger) error {
1919
p.channel = plugin.NewMethodChannel(messenger, navigationChannelName, plugin.JSONMethodCodec{})
20+
2021
// Ignored: This information isn't properly formated to set the window.SetTitle
2122
p.channel.HandleFuncSync("routeUpdated", func(_ interface{}) (interface{}, error) { return nil, nil })
23+
24+
// Currently ignored on platforms other than web
25+
p.channel.HandleFuncSync("selectSingleEntryHistory", func(_ interface{}) (interface{}, error) { return nil, nil })
26+
p.channel.HandleFuncSync("routeInformationUpdated", func(_ interface{}) (interface{}, error) { return nil, nil })
27+
2228
return nil
2329
}

platform.go

+14
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ func (p *platformPlugin) InitPlugin(messenger plugin.BinaryMessenger) error {
3838

3939
channel.HandleFuncSync("Clipboard.setData", p.handleClipboardSetData)
4040
channel.HandleFuncSync("Clipboard.getData", p.handleClipboardGetData)
41+
channel.HandleFuncSync("Clipboard.hasStrings", p.handleClipboardHasString)
42+
4143
channel.HandleFuncSync("SystemNavigator.pop", p.handleSystemNavigatorPop)
4244
channel.HandleFunc("SystemChrome.setApplicationSwitcherDescription", p.handleWindowSetTitle)
4345

@@ -89,6 +91,18 @@ func (p *platformPlugin) handleClipboardGetData(arguments interface{}) (reply in
8991
return reply, nil
9092
}
9193

94+
func (p *platformPlugin) handleClipboardHasString(arguments interface{}) (reply interface{}, err error) {
95+
var clipText string
96+
clipText = p.window.GetClipboardString()
97+
98+
reply = struct {
99+
Value bool `json:"value"`
100+
}{
101+
Value: len(clipText) > 0,
102+
}
103+
return reply, nil
104+
}
105+
92106
func (p *platformPlugin) handleWindowSetTitle(arguments interface{}) (reply interface{}, err error) {
93107
// triggers flutter framework initialized callbacks
94108
for _, f := range p.flutterInitialized {

restoration.go

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package flutter
2+
3+
import (
4+
"github.com/go-flutter-desktop/go-flutter/plugin"
5+
)
6+
7+
type restorationPlugin struct{}
8+
9+
// all hardcoded because theres not pluggable renderer system.
10+
var defaultRestorationPlugin = &restorationPlugin{}
11+
12+
var _ Plugin = &restorationPlugin{} // compile-time type check
13+
14+
func (p *restorationPlugin) InitPlugin(messenger plugin.BinaryMessenger) error {
15+
channel := plugin.NewMethodChannel(messenger, "flutter/restoration", plugin.StandardMethodCodec{})
16+
// Ignored: desktop doesn't need application "restoration"
17+
channel.HandleFunc("get", func(_ interface{}) (interface{}, error) { return nil, nil })
18+
return nil
19+
}

text-input.go

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ func (p *textinputPlugin) InitPlugin(messenger plugin.BinaryMessenger) error {
7373
})
7474
// Ignored: This information is used by the flutter Web Engine
7575
p.channel.HandleFuncSync("TextInput.setStyle", func(_ interface{}) (interface{}, error) { return nil, nil })
76+
// Ignored: Used on MacOS to position accent selection menu
77+
p.channel.HandleFuncSync("TextInput.setCaretRect", func(_ interface{}) (interface{}, error) { return nil, nil })
7678
// Ignored: GLFW dosn't support setting the input method of the current cursor location #426
7779
p.channel.HandleFuncSync("TextInput.setEditableSizeAndTransform", func(_ interface{}) (interface{}, error) { return nil, nil })
7880
// Ignored: GLFW dosn't support setting the input method of the current cursor location #426

0 commit comments

Comments
 (0)