Skip to content

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.

Setting the icon

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),