-
Notifications
You must be signed in to change notification settings - Fork 282
OptionWindowInitializer deprecated
Geert-Johan Riemer edited this page Mar 5, 2019
·
2 revisions
The window initializer option is deprecated. It is replaced by functions that directly do what you want, so you don't have to work with glfw.
Currently only setting the icon is supported. Are you using the window initializer for a different feature? Please open an issue so we can add support.
Change the setIcon
function, which was calling glfw.SetIcon
to something like this:
func iconProvider() ([]image.Image, error) {
_, currentFilePath, _, _ := runtime.Caller(0)
dir := path.Dir(currentFilePath)
imgFile, err := os.Open(dir + "/assets/icon.png")
if err != nil {
return nil, err
}
img, _, err := image.Decode(imgFile)
if err != nil {
return nil, err
}
return []image.Image{img}, nil
}
Or use your own implementation. Where before it called glfwWindow.SetIcon with a slice of image.Image's, now just return that slice.
Then change the option:
- flutter.OptionWindowInitializer(setIcon),
+ flutter.WindowIcon(iconProvider),