Skip to content

Commit c42c104

Browse files
zephylacPierre Champion
authored and
Pierre Champion
committed
Provide a working set default Option values (#46)
Good Job 💯
1 parent 88749b4 commit c42c104

File tree

3 files changed

+36
-16
lines changed

3 files changed

+36
-16
lines changed

example/simpleDemo/main.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,14 @@ func main() {
2727
_, currentFilePath, _, _ := runtime.Caller(0)
2828
dir := path.Dir(currentFilePath)
2929

30+
initialApplicationHeight := 600
31+
initialApplicationWidth := 800
32+
3033
options := []gutter.Option{
31-
gutter.OptionAssetPath(dir + "/flutter_project/demo/build/flutter_assets"),
32-
/* Depending on your architecture you need to change the enginer
33-
* Mac OS X : flutter/bin/cache/artifacts/engine/darwin-x64/icudtl.dat
34-
* Linux : flutter/bin/cache/artifacts/engine/linux-x64/icudtl.dat
35-
* Windows : flutter/bin/cache/artifacts/engine/windows-x64/icudtl.dat
36-
*/
37-
gutter.OptionICUDataPath(dir + "/icudtl.dat"),
38-
gutter.OptionWindowInitializer(setIcon),
39-
gutter.OptionWindowDimension(800, 600),
34+
gutter.ProjectAssetPath(dir + "/flutter_project/demo/build/flutter_assets"),
35+
/* This path should not be changed. icudtl.dat is handled by engineDownloader.go */
36+
gutter.ApplicationICUDataPath(dir + "/icudtl.dat"),
37+
gutter.ApplicationWindowDimension(initialApplicationWidth, initialApplicationHeight),
4038
gutter.OptionWindowInitializer(setIcon),
4139
gutter.OptionPixelRatio(1.2),
4240
gutter.OptionVMArguments([]string{"--dart-non-checked-mode", "--observatory-port=50300"}),

example/stocks/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func main() {
1717
)
1818

1919
options := []gutter.Option{
20-
gutter.OptionAssetPath("flutter_project/stocks/build/flutter_assets"),
20+
gutter.ProjectAssetPath("flutter_project/stocks/build/flutter_assets"),
2121
gutter.OptionICUDataPath("/opt/flutter/bin/cache/artifacts/engine/linux-x64/icudtl.dat"), // Linux (arch)
2222
// gutter.OptionICUDataPath("./FlutterEmbedder.framework/Resources/icudtl.dat"), // OSX
2323
gutter.OptionWindowDimension(800, 600),

option.go

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,33 @@
11
package gutter
22

33
import (
4+
"log"
5+
"os"
6+
47
"github.com/go-gl/glfw/v3.2/glfw"
58
)
69

710
// Option for gutter
811
type Option func(*config)
912

10-
// OptionAssetPath specify the flutter asset directory.
11-
func OptionAssetPath(p string) Option {
13+
// Check path
14+
func checkPath(p string) {
15+
if _, err := os.Stat(p); os.IsNotExist(err) {
16+
log.Fatal(err)
17+
}
18+
}
19+
20+
// ProjectAssetPath specify the flutter asset directory.
21+
func ProjectAssetPath(p string) Option {
22+
checkPath(p)
1223
return func(c *config) {
1324
c.AssetPath = p
1425
}
1526
}
1627

17-
// OptionICUDataPath specify the path to the ICUData.
18-
func OptionICUDataPath(p string) Option {
28+
// ApplicationICUDataPath specify the path to the ICUData.
29+
func ApplicationICUDataPath(p string) Option {
30+
checkPath(p)
1931
return func(c *config) {
2032
c.ICUDataPath = p
2133
}
@@ -29,8 +41,18 @@ func OptionVMArguments(a []string) Option {
2941
}
3042
}
3143

32-
// OptionWindowDimension specify the startup's dimention of the window.
33-
func OptionWindowDimension(x int, y int) Option {
44+
// ApplicationWindowDimension specify the startup's dimention of the window.
45+
func ApplicationWindowDimension(x int, y int) Option {
46+
// Check for initial application display size
47+
if x < 1 {
48+
log.Fatal("Wrong initial value for width ")
49+
}
50+
51+
// Check for initial application display size
52+
if y < 1 {
53+
log.Fatal("Wrong initial value for height ")
54+
}
55+
3456
return func(c *config) {
3557
c.WindowDimension.x = x
3658
c.WindowDimension.y = y

0 commit comments

Comments
 (0)