flutter shell u. emacs
This commit is contained in:
49
Shells/flutter/test/go/cmd/main.go
Normal file
49
Shells/flutter/test/go/cmd/main.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"image"
|
||||
_ "image/png"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/go-flutter-desktop/go-flutter"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// vmArguments may be set by hover at compile-time
|
||||
var vmArguments string
|
||||
|
||||
func main() {
|
||||
// DO NOT EDIT, add options in options.go
|
||||
mainOptions := []flutter.Option{
|
||||
flutter.OptionVMArguments(strings.Split(vmArguments, ";")),
|
||||
flutter.WindowIcon(iconProvider),
|
||||
}
|
||||
err := flutter.Run(append(options, mainOptions...)...)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func iconProvider() ([]image.Image, error) {
|
||||
execPath, err := os.Executable()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to resolve executable path")
|
||||
}
|
||||
execPath, err = filepath.EvalSymlinks(execPath)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to eval symlinks for executable path")
|
||||
}
|
||||
imgFile, err := os.Open(filepath.Join(filepath.Dir(execPath), "assets", "icon.png"))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to open assets/icon.png")
|
||||
}
|
||||
img, _, err := image.Decode(imgFile)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to decode image")
|
||||
}
|
||||
return []image.Image{img}, nil
|
||||
}
|
||||
9
Shells/flutter/test/go/cmd/options.go
Normal file
9
Shells/flutter/test/go/cmd/options.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/go-flutter-desktop/go-flutter"
|
||||
)
|
||||
|
||||
var options = []flutter.Option{
|
||||
flutter.WindowInitialDimensions(800, 1280),
|
||||
}
|
||||
Reference in New Issue
Block a user