Repository: go-flutter-desktop/examples Branch: master Commit: 031d1c2c5e54 Files: 150 Total size: 255.0 KB Directory structure: gitextract_wdz4x0ao/ ├── .github/ │ └── workflows/ │ └── main.yml ├── .gitignore ├── .gitlab-ci.yml ├── README.md ├── draggable_borderless/ │ ├── .gitignore │ ├── .metadata │ ├── README.md │ ├── go/ │ │ ├── .gitignore │ │ ├── cmd/ │ │ │ ├── main.go │ │ │ └── options.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── hover.yaml │ ├── lib/ │ │ └── main_desktop.dart │ └── pubspec.yaml ├── keyboard_event/ │ ├── .gitignore │ ├── README.md │ ├── fonts/ │ │ └── Roboto/ │ │ └── LICENSE.txt │ ├── go/ │ │ ├── .gitignore │ │ ├── cmd/ │ │ │ ├── main.go │ │ │ └── options.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── hover.yaml │ ├── lib/ │ │ ├── app.dart │ │ ├── main.dart │ │ └── main_desktop.dart │ └── pubspec.yaml ├── plugin_tutorial/ │ ├── .gitignore │ ├── README.md │ ├── go/ │ │ ├── .gitignore │ │ ├── cmd/ │ │ │ ├── main.go │ │ │ └── options.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── hover.yaml │ ├── go-plugin-example/ │ │ ├── battery/ │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── main.go │ │ └── complex/ │ │ ├── go.mod │ │ ├── go.sum │ │ └── main.go │ ├── lib/ │ │ └── main_desktop.dart │ └── pubspec.yaml ├── pointer_demo/ │ ├── .gitignore │ ├── README.md │ ├── fonts/ │ │ └── Roboto/ │ │ └── LICENSE.txt │ ├── go/ │ │ ├── .gitignore │ │ ├── cmd/ │ │ │ ├── main.go │ │ │ └── options.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── hover.yaml │ ├── lib/ │ │ ├── app.dart │ │ ├── main.dart │ │ └── main_desktop.dart │ └── pubspec.yaml ├── renovate.json ├── stocks/ │ ├── .gitignore │ ├── README.md │ ├── fonts/ │ │ └── Roboto/ │ │ └── LICENSE.txt │ ├── go/ │ │ ├── .gitignore │ │ ├── cmd/ │ │ │ ├── main.go │ │ │ └── options.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── hover.yaml │ │ └── packaging/ │ │ ├── darwin-bundle/ │ │ │ └── {{.applicationName}} {{.version}}.app/ │ │ │ └── Contents/ │ │ │ └── Info.plist.tmpl │ │ ├── darwin-pkg/ │ │ │ └── flat/ │ │ │ ├── Distribution.tmpl │ │ │ └── base.pkg/ │ │ │ └── PackageInfo.tmpl │ │ ├── linux-appimage/ │ │ │ ├── AppRun.tmpl │ │ │ └── {{.packageName}}.desktop.tmpl │ │ ├── linux-deb/ │ │ │ ├── DEBIAN/ │ │ │ │ └── control.tmpl │ │ │ └── usr/ │ │ │ ├── bin/ │ │ │ │ └── {{.executableName}}.tmpl │ │ │ └── share/ │ │ │ └── applications/ │ │ │ └── {{.executableName}}.desktop.tmpl │ │ ├── linux-pkg/ │ │ │ ├── PKGBUILD.tmpl │ │ │ └── src/ │ │ │ └── usr/ │ │ │ ├── bin/ │ │ │ │ └── {{.executableName}}.tmpl │ │ │ └── share/ │ │ │ └── applications/ │ │ │ └── {{.executableName}}.desktop.tmpl │ │ ├── linux-rpm/ │ │ │ ├── BUILDROOT/ │ │ │ │ └── {{.packageName}}-{{.version}}-{{.release}}.x86_64/ │ │ │ │ └── usr/ │ │ │ │ ├── bin/ │ │ │ │ │ └── {{.executableName}}.tmpl │ │ │ │ └── share/ │ │ │ │ └── applications/ │ │ │ │ └── {{.executableName}}.desktop.tmpl │ │ │ └── SPECS/ │ │ │ └── {{.packageName}}.spec.tmpl │ │ ├── linux-snap/ │ │ │ └── snap/ │ │ │ ├── local/ │ │ │ │ └── {{.executableName}}.desktop.tmpl │ │ │ └── snapcraft.yaml.tmpl │ │ └── windows-msi/ │ │ ├── upgrade-code.txt │ │ └── {{.packageName}}.wxs.tmpl │ ├── lib/ │ │ ├── i18n/ │ │ │ ├── .dartignore │ │ │ ├── regenerate.md │ │ │ ├── stock_messages_all.dart │ │ │ ├── stock_messages_en.dart │ │ │ ├── stock_messages_es.dart │ │ │ ├── stocks_en.arb │ │ │ └── stocks_es.arb │ │ ├── main.dart │ │ ├── main_desktop.dart │ │ ├── stock.dart │ │ ├── stock_arrow.dart │ │ ├── stock_data.dart │ │ ├── stock_home.dart │ │ ├── stock_list.dart │ │ ├── stock_row.dart │ │ ├── stock_settings.dart │ │ ├── stock_strings.dart │ │ ├── stock_symbol_viewer.dart │ │ └── stock_types.dart │ └── pubspec.yaml ├── text_demo/ │ ├── .gitignore │ ├── fonts/ │ │ └── Roboto/ │ │ └── LICENSE.txt │ ├── go/ │ │ ├── .gitignore │ │ ├── cmd/ │ │ │ ├── main.go │ │ │ └── options.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── hover.yaml │ ├── lib/ │ │ ├── app.dart │ │ ├── main.dart │ │ └── main_desktop.dart │ └── pubspec.yaml ├── texture_tutorial/ │ ├── .gitignore │ ├── README.md │ ├── go/ │ │ ├── .gitignore │ │ ├── cmd/ │ │ │ ├── main.go │ │ │ └── options.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── hover.yaml │ ├── go-texture-example/ │ │ ├── gif/ │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── main.go │ │ └── image/ │ │ ├── go.mod │ │ ├── go.sum │ │ └── main.go │ ├── lib/ │ │ └── main_desktop.dart │ └── pubspec.yaml └── xbox_controller/ ├── .gitignore ├── README.md ├── fonts/ │ └── Roboto/ │ └── LICENSE.txt ├── go/ │ ├── .gitignore │ ├── cmd/ │ │ ├── import-path_provider-plugin.go │ │ ├── main.go │ │ └── options.go │ ├── go.mod │ ├── go.sum │ └── hover.yaml ├── go-plugin-example/ │ └── controller/ │ ├── go.mod │ ├── go.sum │ └── main.go ├── lib/ │ ├── game.dart │ ├── main.dart │ └── main_desktop.dart └── pubspec.yaml ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/workflows/main.yml ================================================ name: Github Actions on: schedule: - cron: "0 0 * * 1" push: branches: [master] pull_request: branches: [master] jobs: build: runs-on: ubuntu-latest strategy: fail-fast: false matrix: format: [darwin-dmg, darwin-pkg, darwin, linux-appimage, linux-deb, linux-pkg, linux-rpm, linux-snap, linux, windows-msi, windows] container: image: goflutter/hover:v0.47.2 steps: - name: Update flutter run: | apt-get update apt-get install -y unzip flutter upgrade - uses: actions/checkout@v2 with: fetch-depth: 0 - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - name: Run `hover build ${{ matrix.format }}` run: | cd $GITHUB_WORKSPACE export VERSION_NAME=$(git describe --tags $(git rev-list --tags --max-count=1)) cd stocks && hover build ${{ matrix.format }} --version-number ${VERSION_NAME} --debug ls -lah ./go/build/outputs/${{ matrix.format }}-debug_unopt/* - uses: actions/upload-artifact@v2 with: name: ${{ matrix.format }} path: stocks/go/build/outputs/${{ matrix.format }}-debug_unopt/* ================================================ FILE: .gitignore ================================================ .idea *.iml .flutter-plugins-dependencies ================================================ FILE: .gitlab-ci.yml ================================================ stages: - build # .hoverBuildPackaged is a template job that we re-use for a number of concrete # build jobs. This allows us to have a single job definition that is re-used for # all the separate targets. .hoverBuildPackaged: stage: build image: goflutter/hover:v0.47.2 cache: key: one-key-4-all paths: - /root/.pub-cache - /root/.cache/go-build script: - declare -x VERSION_NAME=$(git describe --tags | sed 's/-//g') - cd stocks && hover build ${PACKAGING_TYPE} --version-number ${VERSION_NAME} artifacts: paths: - stocks/go/build/outputs/${PACKAGING_TYPE} expire_in: 20 weeks ## Build build:darwin-dmg: variables: PACKAGING_TYPE: darwin-dmg extends: .hoverBuildPackaged build:darwin-pkg: variables: PACKAGING_TYPE: darwin-pkg extends: .hoverBuildPackaged build:linux-appimage: variables: PACKAGING_TYPE: linux-appimage extends: .hoverBuildPackaged build:linux-deb: variables: PACKAGING_TYPE: linux-deb extends: .hoverBuildPackaged build:linux-rpm: variables: PACKAGING_TYPE: linux-rpm extends: .hoverBuildPackaged build:linux-pkg: variables: PACKAGING_TYPE: linux-pkg extends: .hoverBuildPackaged build:linux-snap: variables: PACKAGING_TYPE: linux-snap extends: .hoverBuildPackaged build:windows-msi: variables: PACKAGING_TYPE: windows-msi extends: .hoverBuildPackaged ================================================ FILE: README.md ================================================ # go-flutter-desktop/examples This repository contains some example applications that can be built using [go-flutter](https://github.com/go-flutter-desktop/go-flutter). ## Compiled example ![Github Actions](https://github.com/go-flutter-desktop/examples/workflows/Github%20Actions/badge.svg) Pre-compiled examples are available as [Github action](https://github.com/go-flutter-desktop/examples/actions) artifacts. ## Getting started ### Install dependencies You'll need to have the following tools installed on your machine. - [flutter](https://flutter.dev) - [go](https://golang.org) - [hover](https://github.com/go-flutter-desktop/hover) ### Run the example ```bash git clone https://github.com/go-flutter-desktop/examples.git cd examples/[.....] # select an example project hover run ``` ## Issues Please report issues at the [go-flutter issue tracker](https://github.com/go-flutter-desktop/go-flutter/issues/). ================================================ FILE: draggable_borderless/.gitignore ================================================ # Miscellaneous *.class *.log *.pyc *.swp .DS_Store .atom/ .buildlog/ .history .svn/ # IntelliJ related *.iml *.ipr *.iws .idea/ # The .vscode folder contains launch configuration and tasks you configure in # VS Code which you may wish to be included in version control, so this line # is commented out by default. #.vscode/ # Flutter/Dart/Pub related **/doc/api/ .dart_tool/ .flutter-plugins .packages .pub-cache/ .pub/ /build/ # Android related **/android/**/gradle-wrapper.jar **/android/.gradle **/android/captures/ **/android/gradlew **/android/gradlew.bat **/android/local.properties **/android/**/GeneratedPluginRegistrant.java # iOS/XCode related **/ios/**/*.mode1v3 **/ios/**/*.mode2v3 **/ios/**/*.moved-aside **/ios/**/*.pbxuser **/ios/**/*.perspectivev3 **/ios/**/*sync/ **/ios/**/.sconsign.dblite **/ios/**/.tags* **/ios/**/.vagrant/ **/ios/**/DerivedData/ **/ios/**/Icon? **/ios/**/Pods/ **/ios/**/.symlinks/ **/ios/**/profile **/ios/**/xcuserdata **/ios/.generated/ **/ios/Flutter/App.framework **/ios/Flutter/Flutter.framework **/ios/Flutter/Generated.xcconfig **/ios/Flutter/app.flx **/ios/Flutter/app.zip **/ios/Flutter/flutter_assets/ **/ios/ServiceDefinitions.json **/ios/Runner/GeneratedPluginRegistrant.* # Exceptions to above rules. !**/ios/**/default.mode1v3 !**/ios/**/default.mode2v3 !**/ios/**/default.pbxuser !**/ios/**/default.perspectivev3 !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages ================================================ FILE: draggable_borderless/.metadata ================================================ # This file tracks properties of this Flutter project. # Used by Flutter tool to assess capabilities and perform upgrades etc. # # This file should be version controlled and should not be manually edited. version: revision: bc7bc940836f1f834699625426795fd6f07c18ec channel: beta project_type: app ================================================ FILE: draggable_borderless/README.md ================================================ # draggable_borderless A [go-flutter-desktop](https://github.com/go-flutter-desktop/go-flutter/wiki/Plugin-info) GLFW plugin example. In this example we are answering issue [#214](https://github.com/go-flutter-desktop/go-flutter/issues/214): *"how to drag undecorated window".* go-flutter has multiples [option](https://github.com/go-flutter-desktop/go-flutter/wiki/Options), one of them been [`flutter.WindowMode(flutter.WindowModeBorderless)`](https://github.com/go-flutter-desktop/examples/blob/f6eddd4e0051944ab41b0a9e12d8a4a0d0af2fdd/draggable_borderless/desktop/cmd/options.go#L11). This example uses this option, which hide the window decoration (title bar, close/maximize/.. buttons) making the window un-draggable using 'classic' mouse interaction. To solve this limitation a [`GLFW-Plugin`](https://github.com/go-flutter-desktop/go-flutter/wiki/GLFW-Plugin-example) has been written. The GLFW answer comes from https://stackoverflow.com/a/46205940 with a little twist. The window is only draggable from the [Flutter AppBar](https://api.flutter.dev/flutter/material/AppBar-class.html) widget. The source code of the plugin has been placed directly in the [`go/cmd/options.go`](./go/cmd/options.go) file. A custom `AppBar` widget has been created, the source code is available in the [`lib/main_desktop.dart`](./lib/main_desktop.dart) file. ## Demo

Demo of the
  example

================================================ FILE: draggable_borderless/go/.gitignore ================================================ build .last_goflutter_check .last_go-flutter_check ================================================ FILE: draggable_borderless/go/cmd/main.go ================================================ 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 } ================================================ FILE: draggable_borderless/go/cmd/options.go ================================================ package main import ( "github.com/go-flutter-desktop/go-flutter" "github.com/go-flutter-desktop/go-flutter/plugin" "github.com/go-gl/glfw/v3.3/glfw" ) var options = []flutter.Option{ flutter.WindowInitialDimensions(400, 300), flutter.WindowMode(flutter.WindowModeBorderless), flutter.AddPlugin(&AppBarDraggable{}), } // AppBarDraggable is a plugin that makes moving the bordreless window possible type AppBarDraggable struct { window *glfw.Window cursorPosY int cursorPosX int } var _ flutter.Plugin = &AppBarDraggable{} // compile-time type check var _ flutter.PluginGLFW = &AppBarDraggable{} // compile-time type check // AppBarDraggable struct must implement InitPlugin and InitPluginGLFW // InitPlugin creates a MethodChannel for "samples.go-flutter.dev/draggable" func (p *AppBarDraggable) InitPlugin(messenger plugin.BinaryMessenger) error { channel := plugin.NewMethodChannel(messenger, "samples.go-flutter.dev/draggable", plugin.StandardMethodCodec{}) channel.HandleFunc("onPanStart", p.onPanStart) channel.HandleFuncSync("onPanUpdate", p.onPanUpdate) // MUST RUN ON THE MAIN THREAD (use of HandleFuncSync) channel.HandleFunc("onClose", p.onClose) return nil } // InitPluginGLFW is used to gain control over the glfw.Window func (p *AppBarDraggable) InitPluginGLFW(window *glfw.Window) error { p.window = window return nil } // onPanStart/onPanUpdate a golang / flutter implemantation of: // "GLFW how to drag undecorated window without lag" // https://stackoverflow.com/a/46205940 func (p *AppBarDraggable) onPanStart(arguments interface{}) (reply interface{}, err error) { argumentsMap := arguments.(map[interface{}]interface{}) p.cursorPosX = int(argumentsMap["dx"].(float64)) p.cursorPosY = int(argumentsMap["dy"].(float64)) return nil, nil } // onPanUpdate calls GLFW functions that aren't thread safe. // to run function on the main go-flutter thread, use HandleFuncSync instead of HandleFunc! func (p *AppBarDraggable) onPanUpdate(arguments interface{}) (reply interface{}, err error) { xpos, ypos := p.window.GetCursorPos() // This function must only be called from the main thread. deltaX := int(xpos) - p.cursorPosX deltaY := int(ypos) - p.cursorPosY x, y := p.window.GetPos() // This function must only be called from the main thread. p.window.SetPos(x+deltaX, y+deltaY) // This function must only be called from the main thread. return nil, nil } func (p *AppBarDraggable) onClose(arguments interface{}) (reply interface{}, err error) { // This function may be called from any thread. Access is not synchronized. p.window.SetShouldClose(true) return nil, nil } ================================================ FILE: draggable_borderless/go/go.mod ================================================ module draggable_borderless/go go 1.19 require ( github.com/go-flutter-desktop/go-flutter v0.52.2 github.com/go-gl/glfw/v3.3/glfw v0.0.0-20260406072232-3ac4aa2bb164 github.com/pkg/errors v0.9.1 ) require ( github.com/Xuanwo/go-locale v1.1.0 // indirect github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 // indirect golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b // indirect golang.org/x/text v0.3.7 // indirect ) ================================================ FILE: draggable_borderless/go/go.sum ================================================ github.com/Xuanwo/go-locale v1.1.0 h1:51gUxhxl66oXAjI9uPGb2O0qwPECpriKQb2hl35mQkg= github.com/Xuanwo/go-locale v1.1.0/go.mod h1:UKrHoZB3FPIk9wIG2/tVSobnHgNnceGSH3Y8DY5cASs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-flutter-desktop/go-flutter v0.52.2 h1:08LdijXBSiqUcSzofrytBPpItF+zBgJ7s0sDixFhbAU= github.com/go-flutter-desktop/go-flutter v0.52.2/go.mod h1:8lIXoHEAZl01qK7pKwUwf/dzF2mD0JRoaxkGoYu32k8= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 h1:zDw5v7qm4yH7N8C8uWd+8Ii9rROdgWxQuGoJ9WDXxfk= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20260406072232-3ac4aa2bb164 h1:ddtotcEXIT7dFhSeXIWjK8YMFYl5bB2NdYQwgv6Uqjk= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20260406072232-3ac4aa2bb164/go.mod h1:SyRD8YfuKk+ZXlDqYiqe1qMSqjNgtHzBTG810KUagMc= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.7 h1:I6tZjLXD2Q1kjvNbIzB1wvQBsXmKXiVrhpRE8ZjP5jY= github.com/smartystreets/goconvey v1.6.7/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b h1:2n253B2r0pYSmEV+UNCQoPfU/FiaizQEK5Gu4Bq4JE8= golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= ================================================ FILE: draggable_borderless/go/hover.yaml ================================================ #application-name: "draggable_borderless" # Uncomment to modify this value. #executable-name: "draggable_borderless" # Uncomment to modify this value. Only lowercase a-z, numbers, underscores and no spaces #package-name: "draggableborderless" # Uncomment to modify this value. Only lowercase a-z, numbers and no underscores or spaces license: "" # MANDATORY: Fill in your SPDX license name: https://spdx.org/licenses target: lib/main_desktop.dart # opengl: "none" # Uncomment this line if you have trouble with your OpenGL driver (https://github.com/go-flutter-desktop/go-flutter/issues/272) docker: false engine-version: "" # change to a engine version commit ================================================ FILE: draggable_borderless/lib/main_desktop.dart ================================================ import 'package:flutter/foundation.dart' show debugDefaultTargetPlatformOverride; import 'package:flutter/material.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/services.dart'; void main() { debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; runApp(MyApp()); } class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'Flutter Code Sample for widgets.Listener', theme: ThemeData( // If the host is missing some fonts, it can cause the // text to not be rendered or worse the app might crash. fontFamily: 'Roboto', primarySwatch: Colors.blue, ), home: Scaffold( appBar: DraggebleAppBar(title: "Draggable borderless"), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'Select the AppBar to drag the window', style: TextStyle(fontSize: 18), ), ], ), ), ), ); } } class DraggebleAppBar extends StatelessWidget implements PreferredSizeWidget { static const platform_channel_draggable = MethodChannel('samples.go-flutter.dev/draggable'); AppBar appBar; DraggebleAppBar({@required String title}) { this.appBar = AppBar( title: Text(title), actions: [ new IconButton( icon: new Icon(Icons.close), onPressed: () async => await platform_channel_draggable.invokeMethod("onClose"), ), ], leading: new Container(), ); } @override Widget build(BuildContext context) { return GestureDetector( child: appBar, onPanStart: onPanStart, onPanUpdate: onPanUpdate); } @override Size get preferredSize => new Size.fromHeight(kToolbarHeight); void onPanUpdate(DragUpdateDetails details) async { await platform_channel_draggable.invokeMethod('onPanUpdate'); } void onPanStart(DragStartDetails details) async { await platform_channel_draggable.invokeMethod('onPanStart', {"dx": details.globalPosition.dx, "dy": details.globalPosition.dy}); } } ================================================ FILE: draggable_borderless/pubspec.yaml ================================================ name: draggable_borderless description: A new Flutter project. # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 # followed by an optional build number separated by a +. # Both the version and the builder number may be overridden in flutter # build by specifying --build-name and --build-number, respectively. # In Android, build-name is used as versionName while build-number used as versionCode. # Read more about Android versioning at https://developer.android.com/studio/publish/versioning # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html version: 1.0.0+1 environment: sdk: ">=2.2.0 <3.0.0" dependencies: flutter: sdk: flutter # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: dev_dependencies: flutter_test: sdk: flutter # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec # The following section is specific to Flutter. flutter: # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. uses-material-design: true # To add assets to your application, add an assets section, like this: # assets: # - images/a_dot_burr.jpeg # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware. # For details regarding adding assets from package dependencies, see # https://flutter.dev/assets-and-images/#from-packages # To add custom fonts to your application, add a fonts section here, # in this "flutter" section. Each entry in this list should have a # "family" key with the font family name, and a "fonts" key with a # list giving the asset and other descriptors for the font. For # example: # fonts: # - family: Schyler # fonts: # - asset: fonts/Schyler-Regular.ttf # - asset: fonts/Schyler-Italic.ttf # style: italic # - family: Trajan Pro # fonts: # - asset: fonts/TrajanPro.ttf # - asset: fonts/TrajanPro_Bold.ttf # weight: 700 # # For details regarding fonts from package dependencies, # see https://flutter.dev/custom-fonts/#from-packages ================================================ FILE: keyboard_event/.gitignore ================================================ # Miscellaneous *.class *.log *.pyc *.swp .DS_Store .atom/ .buildlog/ .history .svn/ # IntelliJ related *.iml *.ipr *.iws .idea/ # Visual Studio Code related .vscode/ # Flutter/Dart/Pub related **/doc/api/ .dart_tool/ .flutter-plugins .packages .pub-cache/ .pub/ /build/ # Android related **/android/**/gradle-wrapper.jar **/android/.gradle **/android/captures/ **/android/gradlew **/android/gradlew.bat **/android/local.properties **/android/**/GeneratedPluginRegistrant.java # iOS/XCode related **/ios/**/*.mode1v3 **/ios/**/*.mode2v3 **/ios/**/*.moved-aside **/ios/**/*.pbxuser **/ios/**/*.perspectivev3 **/ios/**/*sync/ **/ios/**/.sconsign.dblite **/ios/**/.tags* **/ios/**/.vagrant/ **/ios/**/DerivedData/ **/ios/**/Icon? **/ios/**/Pods/ **/ios/**/.symlinks/ **/ios/**/profile **/ios/**/xcuserdata **/ios/.generated/ **/ios/Flutter/App.framework **/ios/Flutter/Flutter.framework **/ios/Flutter/Generated.xcconfig **/ios/Flutter/app.flx **/ios/Flutter/app.zip **/ios/Flutter/flutter_assets/ **/ios/ServiceDefinitions.json **/ios/Runner/GeneratedPluginRegistrant.* # Exceptions to above rules. !**/ios/**/default.mode1v3 !**/ios/**/default.mode2v3 !**/ios/**/default.pbxuser !**/ios/**/default.perspectivev3 !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages ================================================ FILE: keyboard_event/README.md ================================================ # keyboard_event A [`RawKeyEvent`](https://api.flutter.dev/flutter/services/RawKeyEvent-class.html) go-flutter-desktop example. ## Demo

Demo of the
  example

================================================ FILE: keyboard_event/fonts/Roboto/LICENSE.txt ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: keyboard_event/go/.gitignore ================================================ build .last_goflutter_check .last_go-flutter_check ================================================ FILE: keyboard_event/go/cmd/main.go ================================================ 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 } ================================================ FILE: keyboard_event/go/cmd/options.go ================================================ package main import ( "github.com/go-flutter-desktop/go-flutter" ) var options = []flutter.Option{ flutter.WindowInitialDimensions(800, 1280), } ================================================ FILE: keyboard_event/go/go.mod ================================================ module keyboard_event/go go 1.19 require ( github.com/go-flutter-desktop/go-flutter v0.52.2 github.com/pkg/errors v0.9.1 ) require ( github.com/Xuanwo/go-locale v1.1.0 // indirect github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 // indirect github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f // indirect golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b // indirect golang.org/x/text v0.3.7 // indirect ) ================================================ FILE: keyboard_event/go/go.sum ================================================ github.com/Xuanwo/go-locale v1.1.0 h1:51gUxhxl66oXAjI9uPGb2O0qwPECpriKQb2hl35mQkg= github.com/Xuanwo/go-locale v1.1.0/go.mod h1:UKrHoZB3FPIk9wIG2/tVSobnHgNnceGSH3Y8DY5cASs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-flutter-desktop/go-flutter v0.52.2 h1:08LdijXBSiqUcSzofrytBPpItF+zBgJ7s0sDixFhbAU= github.com/go-flutter-desktop/go-flutter v0.52.2/go.mod h1:8lIXoHEAZl01qK7pKwUwf/dzF2mD0JRoaxkGoYu32k8= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 h1:zDw5v7qm4yH7N8C8uWd+8Ii9rROdgWxQuGoJ9WDXxfk= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f h1:w3h343WgVLKLITcSpwecCDcq0FO8pAv6A/UG86hhFtY= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.7 h1:I6tZjLXD2Q1kjvNbIzB1wvQBsXmKXiVrhpRE8ZjP5jY= github.com/smartystreets/goconvey v1.6.7/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b h1:2n253B2r0pYSmEV+UNCQoPfU/FiaizQEK5Gu4Bq4JE8= golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= ================================================ FILE: keyboard_event/go/hover.yaml ================================================ #application-name: "keyboard_event" # Uncomment to modify this value. #executable-name: "keyboard_event" # Uncomment to modify this value. Only lowercase a-z, numbers, underscores and no spaces #package-name: "keyboardevent" # Uncomment to modify this value. Only lowercase a-z, numbers and no underscores or spaces license: "" # MANDATORY: Fill in your SPDX license name: https://spdx.org/licenses target: lib/main_desktop.dart # opengl: "none" # Uncomment this line if you have trouble with your OpenGL driver (https://github.com/go-flutter-desktop/go-flutter/issues/272) docker: false engine-version: "" # change to a engine version commit ================================================ FILE: keyboard_event/lib/app.dart ================================================ import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter/services.dart'; class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Code Sample for Keyboard event', theme: ThemeData( // If the host is missing some fonts, it can cause the // text to not be rendered or worse the app might crash. fontFamily: 'Roboto', primarySwatch: Colors.blue, ), home: KeyboardTestPage(), ); } } /// Keyboard test page for the example application. class KeyboardTestPage extends StatefulWidget { @override State createState() { return _KeyboardTestPageState(); } } class _KeyboardTestPageState extends State { final List _messages = []; final FocusNode _focusNode = FocusNode(); final ScrollController _scrollController = new ScrollController(); @override void didChangeDependencies() { super.didChangeDependencies(); FocusScope.of(context).requestFocus(_focusNode); } @override Widget build(BuildContext context) { return new Scaffold( appBar: AppBar( title: new Text('Keyboard events test'), ), body: new RawKeyboardListener( focusNode: _focusNode, onKey: onKeyEvent, child: Container( padding: EdgeInsets.symmetric(horizontal: 16.0), child: SingleChildScrollView( controller: _scrollController, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: _messages.map((m) => new Text(m)).toList())), ), ), ); } void onKeyEvent(RawKeyEvent event) { bool isKeyDown; switch (event.runtimeType) { case RawKeyDownEvent: isKeyDown = true; break; case RawKeyUpEvent: isKeyDown = false; break; default: throw new Exception('Unexpected runtimeType of RawKeyEvent'); } _addMessage( '${event.data.runtimeType} - ${isKeyDown ? 'KeyDown' : 'KeyUp'}:\n- Modifiers: ${event.data.modifiersPressed}\n- KeyLabel: ${event.data.keyLabel}\n- physicalKey: ${event.data.physicalKey}\n- logicalkey: ${event.data.logicalKey}\n- character: ${event.character}'); } void _addMessage(String message) { setState(() { _messages.add(message); }); SchedulerBinding.instance.addPostFrameCallback((_) { _scrollController.jumpTo( _scrollController.position.maxScrollExtent, ); }); } } ================================================ FILE: keyboard_event/lib/main.dart ================================================ import 'package:flutter/material.dart'; import 'package:keyboard_event/app.dart'; void main() { runApp(MyApp()); } ================================================ FILE: keyboard_event/lib/main_desktop.dart ================================================ import 'package:flutter/foundation.dart' show debugDefaultTargetPlatformOverride; import 'package:flutter/material.dart'; import 'package:keyboard_event/app.dart'; void main() { debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; runApp(MyApp()); } ================================================ FILE: keyboard_event/pubspec.yaml ================================================ name: keyboard_event description: A new Flutter project. # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 # followed by an optional build number separated by a +. # Both the version and the builder number may be overridden in flutter # build by specifying --build-name and --build-number, respectively. # In Android, build-name is used as versionName while build-number used as versionCode. # Read more about Android versioning at https://developer.android.com/studio/publish/versioning # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html version: 1.0.0+1 environment: sdk: ">=2.1.0 <3.0.0" dependencies: flutter: sdk: flutter # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: dev_dependencies: flutter_test: sdk: flutter # For information on the generic Dart part of this file, see the # following page: https://www.dartlang.org/tools/pub/pubspec # The following section is specific to Flutter. flutter: # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. uses-material-design: true fonts: - family: Roboto fonts: - asset: fonts/Roboto/Roboto-Thin.ttf weight: 100 - asset: fonts/Roboto/Roboto-Light.ttf weight: 300 - asset: fonts/Roboto/Roboto-Regular.ttf weight: 400 - asset: fonts/Roboto/Roboto-Medium.ttf weight: 500 - asset: fonts/Roboto/Roboto-Bold.ttf weight: 700 - asset: fonts/Roboto/Roboto-Black.ttf weight: 900 ================================================ FILE: plugin_tutorial/.gitignore ================================================ # Miscellaneous *.class *.log *.pyc *.swp .DS_Store .atom/ .buildlog/ .history .svn/ # IntelliJ related *.iml *.ipr *.iws .idea/ # Visual Studio Code related .vscode/ # Flutter/Dart/Pub related **/doc/api/ .dart_tool/ .flutter-plugins .packages .pub-cache/ .pub/ /build/ # Android related **/android/**/gradle-wrapper.jar **/android/.gradle **/android/captures/ **/android/gradlew **/android/gradlew.bat **/android/local.properties **/android/**/GeneratedPluginRegistrant.java # iOS/XCode related **/ios/**/*.mode1v3 **/ios/**/*.mode2v3 **/ios/**/*.moved-aside **/ios/**/*.pbxuser **/ios/**/*.perspectivev3 **/ios/**/*sync/ **/ios/**/.sconsign.dblite **/ios/**/.tags* **/ios/**/.vagrant/ **/ios/**/DerivedData/ **/ios/**/Icon? **/ios/**/Pods/ **/ios/**/.symlinks/ **/ios/**/profile **/ios/**/xcuserdata **/ios/.generated/ **/ios/Flutter/App.framework **/ios/Flutter/Flutter.framework **/ios/Flutter/Generated.xcconfig **/ios/Flutter/app.flx **/ios/Flutter/app.zip **/ios/Flutter/flutter_assets/ **/ios/ServiceDefinitions.json **/ios/Runner/GeneratedPluginRegistrant.* # Exceptions to above rules. !**/ios/**/default.mode1v3 !**/ios/**/default.mode2v3 !**/ios/**/default.pbxuser !**/ios/**/default.perspectivev3 !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages ================================================ FILE: plugin_tutorial/README.md ================================================ # plugin_tutorial A detailed tutorial for developing plugins is available at: [go-flutter wiki](https://github.com/go-flutter-desktop/go-flutter/wiki/Implement-a-plugin). The plugins source code is stored in the same example: [./go-plugin-example](./go-plugin-example) ================================================ FILE: plugin_tutorial/go/.gitignore ================================================ build .last_goflutter_check .last_go-flutter_check ================================================ FILE: plugin_tutorial/go/cmd/main.go ================================================ 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 } ================================================ FILE: plugin_tutorial/go/cmd/options.go ================================================ package main import ( "github.com/go-flutter-desktop/go-flutter" "github.com/go-flutter-desktop/plugins/go-plugin-example/battery" "github.com/go-flutter-desktop/plugins/go-plugin-example/complex" ) var options = []flutter.Option{ flutter.WindowInitialDimensions(100, 100), flutter.PopBehavior(flutter.PopBehaviorClose), // on SystemNavigator.pop() closes the app flutter.AddPlugin(&battery.MyBatteryPlugin{}), // our wiki plugin flutter.AddPlugin(&complex.Example{}), // another example } ================================================ FILE: plugin_tutorial/go/go.mod ================================================ module plugin_tutorial/go go 1.19 require ( github.com/go-flutter-desktop/go-flutter v0.52.2 github.com/go-flutter-desktop/plugins/go-plugin-example/battery 01528a4714a5 github.com/go-flutter-desktop/plugins/go-plugin-example/complex 01528a4714a5 github.com/pkg/errors v0.9.1 ) require ( github.com/Xuanwo/go-locale v1.1.0 // indirect github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 // indirect github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f // indirect golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b // indirect golang.org/x/text v0.3.7 // indirect ) replace github.com/go-flutter-desktop/plugins/go-plugin-example/battery => ../go-plugin-example/battery replace github.com/go-flutter-desktop/plugins/go-plugin-example/complex => ../go-plugin-example/complex ================================================ FILE: plugin_tutorial/go/go.sum ================================================ github.com/Xuanwo/go-locale v1.1.0 h1:51gUxhxl66oXAjI9uPGb2O0qwPECpriKQb2hl35mQkg= github.com/Xuanwo/go-locale v1.1.0/go.mod h1:UKrHoZB3FPIk9wIG2/tVSobnHgNnceGSH3Y8DY5cASs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-flutter-desktop/go-flutter v0.52.2 h1:08LdijXBSiqUcSzofrytBPpItF+zBgJ7s0sDixFhbAU= github.com/go-flutter-desktop/go-flutter v0.52.2/go.mod h1:8lIXoHEAZl01qK7pKwUwf/dzF2mD0JRoaxkGoYu32k8= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 h1:zDw5v7qm4yH7N8C8uWd+8Ii9rROdgWxQuGoJ9WDXxfk= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f h1:w3h343WgVLKLITcSpwecCDcq0FO8pAv6A/UG86hhFtY= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.7 h1:I6tZjLXD2Q1kjvNbIzB1wvQBsXmKXiVrhpRE8ZjP5jY= github.com/smartystreets/goconvey v1.6.7/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b h1:2n253B2r0pYSmEV+UNCQoPfU/FiaizQEK5Gu4Bq4JE8= golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= ================================================ FILE: plugin_tutorial/go/hover.yaml ================================================ #application-name: "plugin_tutorial" # Uncomment to modify this value. #executable-name: "plugin_tutorial" # Uncomment to modify this value. Only lowercase a-z, numbers, underscores and no spaces #package-name: "plugintutorial" # Uncomment to modify this value. Only lowercase a-z, numbers and no underscores or spaces license: "" # MANDATORY: Fill in your SPDX license name: https://spdx.org/licenses target: lib/main_desktop.dart # opengl: "none" # Uncomment this line if you have trouble with your OpenGL driver (https://github.com/go-flutter-desktop/go-flutter/issues/272) docker: false engine-version: "" # change to a engine version commit ================================================ FILE: plugin_tutorial/go-plugin-example/battery/go.mod ================================================ module github.com/go-flutter-desktop/plugins/go-plugin-example/battery go 1.19 require github.com/go-flutter-desktop/go-flutter v0.52.2 require ( github.com/Xuanwo/go-locale v1.1.0 // indirect github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 // indirect github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f // indirect github.com/pkg/errors v0.9.1 // indirect golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70 // indirect golang.org/x/text v0.3.7 // indirect ) ================================================ FILE: plugin_tutorial/go-plugin-example/battery/go.sum ================================================ github.com/Xuanwo/go-locale v1.1.0 h1:51gUxhxl66oXAjI9uPGb2O0qwPECpriKQb2hl35mQkg= github.com/Xuanwo/go-locale v1.1.0/go.mod h1:UKrHoZB3FPIk9wIG2/tVSobnHgNnceGSH3Y8DY5cASs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-flutter-desktop/go-flutter v0.52.2 h1:08LdijXBSiqUcSzofrytBPpItF+zBgJ7s0sDixFhbAU= github.com/go-flutter-desktop/go-flutter v0.52.2/go.mod h1:8lIXoHEAZl01qK7pKwUwf/dzF2mD0JRoaxkGoYu32k8= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 h1:zDw5v7qm4yH7N8C8uWd+8Ii9rROdgWxQuGoJ9WDXxfk= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f h1:w3h343WgVLKLITcSpwecCDcq0FO8pAv6A/UG86hhFtY= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.7 h1:I6tZjLXD2Q1kjvNbIzB1wvQBsXmKXiVrhpRE8ZjP5jY= github.com/smartystreets/goconvey v1.6.7/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70 h1:SeSEfdIxyvwGJliREIJhRPPXvW6sDlLT+UQ3B0hD0NA= golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= ================================================ FILE: plugin_tutorial/go-plugin-example/battery/main.go ================================================ package battery import ( flutter "github.com/go-flutter-desktop/go-flutter" "github.com/go-flutter-desktop/go-flutter/plugin" ) // Make sure to use the same channel name as was used on the Flutter client side. const channelName = "samples.flutter.dev/battery" // MyBatteryPlugin demonstrates how to call a platform-specific API to retrieve // the current battery level. // // This example matches the guide example available on: // https://flutter.dev/docs/development/platform-integration/platform-channels type MyBatteryPlugin struct{} var _ flutter.Plugin = &MyBatteryPlugin{} // compile-time type check // InitPlugin creates a MethodChannel and set a HandleFunc to the // shared 'getBatteryLevel' method. // https://godoc.org/github.com/go-flutter-desktop/go-flutter/plugin#MethodChannel // // The plugin is using a MethodChannel through the StandardMethodCodec. // // You can also use the more basic BasicMessageChannel, which supports basic, // asynchronous message passing using a custom message codec. // You can also use the specialized BinaryCodec, StringCodec, and JSONMessageCodec // struct, or create your own codec. // // The JSONMessageCodec was deliberately left out because in Go its better to // decode directly to known structs. func (p *MyBatteryPlugin) InitPlugin(messenger plugin.BinaryMessenger) error { channel := plugin.NewMethodChannel(messenger, channelName, plugin.StandardMethodCodec{}) channel.HandleFunc("getBatteryLevel", handleGetBatteryLevel) return nil // no error } // handleGetBatteryLevel is called when the method getBatteryLevel is invoked by // the dart code. // The function returns a fake battery level, without raising an error. // // Supported return types of StandardMethodCodec codec are described in a table: // https://godoc.org/github.com/go-flutter-desktop/go-flutter/plugin#StandardMessageCodec func handleGetBatteryLevel(arguments interface{}) (reply interface{}, err error) { batteryLevel := int32(55) // Your platform-specific API return batteryLevel, nil } ================================================ FILE: plugin_tutorial/go-plugin-example/complex/go.mod ================================================ module github.com/go-flutter-desktop/plugins/go-plugin-example/complex go 1.19 require github.com/go-flutter-desktop/go-flutter v0.52.2 require ( github.com/Xuanwo/go-locale v1.1.0 // indirect github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 // indirect github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f // indirect github.com/pkg/errors v0.9.1 // indirect golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70 // indirect golang.org/x/text v0.3.7 // indirect ) ================================================ FILE: plugin_tutorial/go-plugin-example/complex/go.sum ================================================ github.com/Xuanwo/go-locale v1.1.0 h1:51gUxhxl66oXAjI9uPGb2O0qwPECpriKQb2hl35mQkg= github.com/Xuanwo/go-locale v1.1.0/go.mod h1:UKrHoZB3FPIk9wIG2/tVSobnHgNnceGSH3Y8DY5cASs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-flutter-desktop/go-flutter v0.52.2 h1:08LdijXBSiqUcSzofrytBPpItF+zBgJ7s0sDixFhbAU= github.com/go-flutter-desktop/go-flutter v0.52.2/go.mod h1:8lIXoHEAZl01qK7pKwUwf/dzF2mD0JRoaxkGoYu32k8= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 h1:zDw5v7qm4yH7N8C8uWd+8Ii9rROdgWxQuGoJ9WDXxfk= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f h1:w3h343WgVLKLITcSpwecCDcq0FO8pAv6A/UG86hhFtY= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.7 h1:I6tZjLXD2Q1kjvNbIzB1wvQBsXmKXiVrhpRE8ZjP5jY= github.com/smartystreets/goconvey v1.6.7/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70 h1:SeSEfdIxyvwGJliREIJhRPPXvW6sDlLT+UQ3B0hD0NA= golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= ================================================ FILE: plugin_tutorial/go-plugin-example/complex/main.go ================================================ package complex import ( "errors" "log" "os" "time" flutter "github.com/go-flutter-desktop/go-flutter" "github.com/go-flutter-desktop/go-flutter/plugin" ) // Example demonstrates how to call a platform-specific API to retrieve // a complex data structure type Example struct { channel *plugin.MethodChannel } var _ flutter.Plugin = &Example{} // InitPlugin creates a MethodChannel and set a HandleFunc to the // shared 'getData' method. func (p *Example) InitPlugin(messenger plugin.BinaryMessenger) error { p.channel = plugin.NewMethodChannel(messenger, "instance.id/go/data", plugin.StandardMethodCodec{}) p.channel.HandleFunc("getData", getRemotesFunc) p.channel.HandleFunc("mutualCall", p.mutualCall) p.channel.HandleFunc("getError", getErrorFunc) p.channel.CatchAllHandleFunc(catchAllTest) return nil } // mutualCall is attached to the plugin struct func (p *Example) mutualCall(arguments interface{}) (reply interface{}, err error) { go func() { time.Sleep(3 * time.Second) if rep, err := p.channel.InvokeMethodWithReply("InvokeMethodWithReply", "text_from_golang"); err != nil { log.Println("InvokeMethod error:", err) } else { if rep.(string) != "text_from_dart" { log.Println("InvokeMethod error: rep.(string) != \"text_from_dart\"") os.Exit(1) } } }() if arguments.(string) != "hello_from_dart" { log.Println("InvokeMethod error: arguments.(string) != \"hello_from_dart\"") os.Exit(1) } return "hello_from_go", nil } func catchAllTest(methodCall interface{}) (reply interface{}, err error) { method := methodCall.(plugin.MethodCall) // return the randomized Method Name return method.Method, nil } func getRemotesFunc(arguments interface{}) (reply interface{}, err error) { dartMsg := arguments.(string) // reading the string argument if dartMsg != "HelloFromDart" { return nil, errors.New("wrong message value, expecting 'HelloFromDart' got '" + dartMsg + "'") } var sectionList = make([]interface{}, 4) sectionList[0] = map[interface{}]interface{}{ "instanceid": int32(1023), "pcbackup": "test", "brbackup": "test2", } sectionList[1] = map[interface{}]interface{}{ "instanceid": int32(1024), "pcbackup": "test", "brbackup": "test2", } sectionList[2] = map[interface{}]interface{}{ "instanceid": int32(1056), "pcbackup": "coucou", "brbackup": "coucou2", } sectionList[3] = map[interface{}]interface{}{ "instanceid": int32(3322), "pcbackup": "finaly", "brbackup": "finaly2", } return sectionList, nil } func getErrorFunc(arguments interface{}) (reply interface{}, err error) { return nil, plugin.NewError("customErrorCode", errors.New("Some error")) } ================================================ FILE: plugin_tutorial/lib/main_desktop.dart ================================================ import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'dart:math'; import 'dart:async' as async; // The client and host sides of a channel are connected through // a channel name passed in the channel constructor. const platform_channel_battery = const MethodChannel('samples.flutter.dev/battery'); void main() async { WidgetsFlutterBinding.ensureInitialized(); // Example from the WIKI // test('Test Battery Plugin result', () async { // Invoke a method on the method channel, specifying the concrete // method to call via the String identifier. final int result = await platform_channel_battery.invokeMethod('getBatteryLevel'); expect(result, 55); final String batteryLevel = ' -- Battery level at $result % .'; print(batteryLevel); }); group('Complex plugin', () { const platform_complex_structure = const MethodChannel('instance.id/go/data'); // A more complicated plugin test('Test StandardMethodCodec array of map', () async { final List result = await platform_complex_structure.invokeMethod('getData', "HelloFromDart"); // passing "HelloFromDart" as an argument expect(result, [ {"instanceid": 1023, "pcbackup": "test", "brbackup": "test2"}, {"instanceid": 1024, "pcbackup": "test", "brbackup": "test2"}, {"instanceid": 1056, "pcbackup": "coucou", "brbackup": "coucou2"}, {"instanceid": 3322, "pcbackup": "finaly", "brbackup": "finaly2"} ]); }); test('Test golang InvokeMethodWithReply', () async { var method; var arguments; async.Completer completer = new async.Completer(); platform_complex_structure.setMethodCallHandler((MethodCall call) async { method = call.method; arguments = call.arguments; completer.complete(); return "text_from_dart"; }); // Triggers the above setMethodCallHandler handler var result = await platform_complex_structure.invokeMethod( 'mutualCall', 'hello_from_dart'); expect(result, "hello_from_go"); await completer.future; expect(method, "InvokeMethodWithReply"); expect(arguments, "text_from_golang"); }); test('Custom errors', () async { var matcher = predicate( (e) => e is PlatformException && e.code == "customErrorCode"); expect( platform_complex_structure.invokeMethod('getError'), throwsA(matcher), ); }); test('Test golang CatchAllHandleFunc', () async { // golang can return the random methodName final String methodName = 'test/' + new Random().nextInt(100000).toString(); final String resultPathPrefix = await platform_complex_structure.invokeMethod(methodName); expect(resultPathPrefix, methodName); }); }); tearDownAll(() async { SystemNavigator.pop(); // close the app }); } ================================================ FILE: plugin_tutorial/pubspec.yaml ================================================ name: plugin_tutorial description: A new Flutter project. # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 # followed by an optional build number separated by a +. # Both the version and the builder number may be overridden in flutter # build by specifying --build-name and --build-number, respectively. # In Android, build-name is used as versionName while build-number used as versionCode. # Read more about Android versioning at https://developer.android.com/studio/publish/versioning # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html version: 1.0.0+1 environment: sdk: ">=2.2.0 <3.0.0" dependencies: flutter: sdk: flutter # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: dev_dependencies: flutter_test: sdk: flutter # For information on the generic Dart part of this file, see the # following page: https://www.dartlang.org/tools/pub/pubspec # The following section is specific to Flutter. flutter: # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. uses-material-design: true ================================================ FILE: pointer_demo/.gitignore ================================================ # Miscellaneous *.class *.log *.pyc *.swp .DS_Store .atom/ .buildlog/ .history .svn/ # IntelliJ related *.iml *.ipr *.iws .idea/ # Visual Studio Code related .vscode/ # Flutter/Dart/Pub related **/doc/api/ .dart_tool/ .flutter-plugins .packages .pub-cache/ .pub/ /build/ # Android related **/android/**/gradle-wrapper.jar **/android/.gradle **/android/captures/ **/android/gradlew **/android/gradlew.bat **/android/local.properties **/android/**/GeneratedPluginRegistrant.java # iOS/XCode related **/ios/**/*.mode1v3 **/ios/**/*.mode2v3 **/ios/**/*.moved-aside **/ios/**/*.pbxuser **/ios/**/*.perspectivev3 **/ios/**/*sync/ **/ios/**/.sconsign.dblite **/ios/**/.tags* **/ios/**/.vagrant/ **/ios/**/DerivedData/ **/ios/**/Icon? **/ios/**/Pods/ **/ios/**/.symlinks/ **/ios/**/profile **/ios/**/xcuserdata **/ios/.generated/ **/ios/Flutter/App.framework **/ios/Flutter/Flutter.framework **/ios/Flutter/Generated.xcconfig **/ios/Flutter/app.flx **/ios/Flutter/app.zip **/ios/Flutter/flutter_assets/ **/ios/ServiceDefinitions.json **/ios/Runner/GeneratedPluginRegistrant.* # Exceptions to above rules. !**/ios/**/default.mode1v3 !**/ios/**/default.mode2v3 !**/ios/**/default.pbxuser !**/ios/**/default.perspectivev3 !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages ================================================ FILE: pointer_demo/README.md ================================================ # pointer_demo A new go-flutter-desktop example. ## Demo

Demo of the
  example

================================================ FILE: pointer_demo/fonts/Roboto/LICENSE.txt ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: pointer_demo/go/.gitignore ================================================ build .last_goflutter_check .last_go-flutter_check ================================================ FILE: pointer_demo/go/cmd/main.go ================================================ 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 } ================================================ FILE: pointer_demo/go/cmd/options.go ================================================ package main import ( "github.com/go-flutter-desktop/go-flutter" ) var options = []flutter.Option{ flutter.WindowInitialDimensions(800, 1280), } ================================================ FILE: pointer_demo/go/go.mod ================================================ module pointer_demo/go go 1.19 require ( github.com/go-flutter-desktop/go-flutter v0.52.2 github.com/pkg/errors v0.9.1 ) require ( github.com/Xuanwo/go-locale v1.1.0 // indirect github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 // indirect github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f // indirect golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b // indirect golang.org/x/text v0.3.7 // indirect ) ================================================ FILE: pointer_demo/go/go.sum ================================================ github.com/Xuanwo/go-locale v1.1.0 h1:51gUxhxl66oXAjI9uPGb2O0qwPECpriKQb2hl35mQkg= github.com/Xuanwo/go-locale v1.1.0/go.mod h1:UKrHoZB3FPIk9wIG2/tVSobnHgNnceGSH3Y8DY5cASs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-flutter-desktop/go-flutter v0.52.2 h1:08LdijXBSiqUcSzofrytBPpItF+zBgJ7s0sDixFhbAU= github.com/go-flutter-desktop/go-flutter v0.52.2/go.mod h1:8lIXoHEAZl01qK7pKwUwf/dzF2mD0JRoaxkGoYu32k8= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 h1:zDw5v7qm4yH7N8C8uWd+8Ii9rROdgWxQuGoJ9WDXxfk= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f h1:w3h343WgVLKLITcSpwecCDcq0FO8pAv6A/UG86hhFtY= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.7 h1:I6tZjLXD2Q1kjvNbIzB1wvQBsXmKXiVrhpRE8ZjP5jY= github.com/smartystreets/goconvey v1.6.7/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b h1:2n253B2r0pYSmEV+UNCQoPfU/FiaizQEK5Gu4Bq4JE8= golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= ================================================ FILE: pointer_demo/go/hover.yaml ================================================ #application-name: "pointer_demo" # Uncomment to modify this value. #executable-name: "pointer_demo" # Uncomment to modify this value. Only lowercase a-z, numbers, underscores and no spaces #package-name: "pointerdemo" # Uncomment to modify this value. Only lowercase a-z, numbers and no underscores or spaces license: "" # MANDATORY: Fill in your SPDX license name: https://spdx.org/licenses target: lib/main_desktop.dart # opengl: "none" # Uncomment this line if you have trouble with your OpenGL driver (https://github.com/go-flutter-desktop/go-flutter/issues/272) docker: false engine-version: "" # change to a engine version commit ================================================ FILE: pointer_demo/lib/app.dart ================================================ // This example makes a [Container] react to being entered by a mouse // pointer, showing a count of the number of entries and exits. import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Code Sample for widgets.Listener', theme: ThemeData( // If the host is missing some fonts, it can cause the // text to not be rendered or worse the app might crash. fontFamily: 'Roboto', primarySwatch: Colors.blue, ), home: MyStatefulWidget(), ); } } class MyStatefulWidget extends StatefulWidget { MyStatefulWidget({Key key}) : super(key: key); @override _MyStatefulWidgetState createState() => _MyStatefulWidgetState(); } class _MyStatefulWidgetState extends State { int _enterCounter = 0; int _exitCounter = 0; double x = 0.0; double y = 0.0; String _mouseStatus = "hovering"; void _incrementCounter(PointerEnterEvent details) { setState(() { _enterCounter++; }); } void _decrementCounter(PointerExitEvent details) { setState(() { _exitCounter++; }); } void _updateLocation(PointerHoverEvent details) { setState(() { x = details.position.dx; y = details.position.dy; _mouseStatus = "hovering, button ${details.buttons.toString()}"; }); } void _updateMove(PointerMoveEvent details) { setState(() { x = details.position.dx; y = details.position.dy; _mouseStatus = "dragging, button ${details.buttons.toString()}"; }); } void _pointerDown(PointerDownEvent details) { setState(() { x = details.position.dx; y = details.position.dy; _mouseStatus = "down, button ${details.buttons.toString()}"; }); } void _pointerUp(PointerUpEvent details) { setState(() { x = details.position.dx; y = details.position.dy; _mouseStatus = "up, button ${details.buttons.toString()}"; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Hover Example'), ), body: Center( child: ConstrainedBox( constraints: BoxConstraints.tight(Size(300.0, 200.0)), child: MouseRegion( onEnter: _incrementCounter, onExit: _decrementCounter, child: Listener( onPointerDown: _pointerDown, onPointerUp: _pointerUp, onPointerMove: _updateMove, onPointerHover: _updateLocation, child: Container( color: Colors.lightBlueAccent, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text('You have pointed at this box this many times:'), Text( '$_enterCounter Entries\n$_exitCounter Exits', ), Text( 'The cursor is here: (${x.toStringAsFixed(2)}, ${y.toStringAsFixed(2)})', ), Divider(), Text( 'The mouse is ${_mouseStatus}', ), ], ), ), ), ), ), ), ); } } ================================================ FILE: pointer_demo/lib/main.dart ================================================ import 'package:flutter/material.dart'; import 'package:pointer_demo/app.dart'; void main() { runApp(MyApp()); } ================================================ FILE: pointer_demo/lib/main_desktop.dart ================================================ import 'package:flutter/foundation.dart' show debugDefaultTargetPlatformOverride; import 'package:flutter/material.dart'; import 'package:pointer_demo/app.dart'; void main() { debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; runApp(MyApp()); } ================================================ FILE: pointer_demo/pubspec.yaml ================================================ name: pointer_demo description: A new Flutter project. # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 # followed by an optional build number separated by a +. # Both the version and the builder number may be overridden in flutter # build by specifying --build-name and --build-number, respectively. # In Android, build-name is used as versionName while build-number used as versionCode. # Read more about Android versioning at https://developer.android.com/studio/publish/versioning # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html version: 1.0.0+1 environment: sdk: ">=2.1.0 <3.0.0" dependencies: flutter: sdk: flutter # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: dev_dependencies: flutter_test: sdk: flutter # For information on the generic Dart part of this file, see the # following page: https://www.dartlang.org/tools/pub/pubspec # The following section is specific to Flutter. flutter: # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. uses-material-design: true fonts: - family: Roboto fonts: - asset: fonts/Roboto/Roboto-Thin.ttf weight: 100 - asset: fonts/Roboto/Roboto-Light.ttf weight: 300 - asset: fonts/Roboto/Roboto-Regular.ttf weight: 400 - asset: fonts/Roboto/Roboto-Medium.ttf weight: 500 - asset: fonts/Roboto/Roboto-Bold.ttf weight: 700 - asset: fonts/Roboto/Roboto-Black.ttf weight: 900 ================================================ FILE: renovate.json ================================================ { "extends": ["config:base"], "automerge": true, "major": { "automerge": false }, "gomodTidy": true, "requiredStatusChecks": null, "postUpdateOptions": [ "gomodTidy" ], "ignoreDeps": [ "golang.org/x/crypto", "golang.org/x/net", "golang.org/x/sys", "intl" ], "ignorePaths": [ "*/android/**" ] } ================================================ FILE: stocks/.gitignore ================================================ .DS_Store .dart_tool/ .packages .pub/ build/ ================================================ FILE: stocks/README.md ================================================ # Stocks [Example from the flutter repo](https://github.com/flutter/flutter/tree/master/examples/stocks) Demo app for the material design widgets and other features provided by Flutter. # Difference The only edit made was to change the font to Roboto. _If the host is missing some fonts, it can cause the text to not be rendered or worse the app might crash_ ```diff diff --git a/examples/stocks/lib/main.dart b/examples/stocks/lib/main.dart index d415902d7..eba3362d9 100644 --- a/examples/stocks/lib/main.dart +++ b/examples/stocks/lib/main.dart @@ -71,12 +71,14 @@ class StocksAppState extends State { case StockMode.optimistic: return new ThemeData( brightness: Brightness.light, - primarySwatch: Colors.purple + primarySwatch: Colors.purple, + fontFamily: 'Roboto' ); case StockMode.pessimistic: return new ThemeData( brightness: Brightness.dark, - accentColor: Colors.redAccent + accentColor: Colors.redAccent, + fontFamily: 'Roboto' ); } assert(_configuration.stockMode != null); diff --git a/examples/stocks/pubspec.yaml b/examples/stocks/pubspec.yaml index 162a7914e..6dba3fbca 100644 --- a/examples/stocks/pubspec.yaml +++ b/examples/stocks/pubspec.yaml @@ -74,4 +74,18 @@ dev_dependencies: flutter: uses-material-design: true -# PUBSPEC CHECKSUM: cf1e + fonts: + - family: Roboto + fonts: + - asset: fonts/Roboto/Roboto-Thin.ttf + weight: 100 + - asset: fonts/Roboto/Roboto-Light.ttf + weight: 300 + - asset: fonts/Roboto/Roboto-Regular.ttf + weight: 400 + - asset: fonts/Roboto/Roboto-Medium.ttf + weight: 500 + - asset: fonts/Roboto/Roboto-Bold.ttf + weight: 700 + - asset: fonts/Roboto/Roboto-Black.ttf + weight: 900 ``` ================================================ FILE: stocks/fonts/Roboto/LICENSE.txt ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: stocks/go/.gitignore ================================================ build .last_goflutter_check .last_go-flutter_check ================================================ FILE: stocks/go/cmd/main.go ================================================ 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 } ================================================ FILE: stocks/go/cmd/options.go ================================================ package main import ( "github.com/go-flutter-desktop/go-flutter" ) var options = []flutter.Option{ flutter.WindowInitialDimensions(800, 1280), } ================================================ FILE: stocks/go/go.mod ================================================ module stocks/go go 1.19 require ( github.com/go-flutter-desktop/go-flutter v0.52.2 github.com/pkg/errors v0.9.1 ) require ( github.com/Xuanwo/go-locale v1.1.0 // indirect github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 // indirect github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f // indirect golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b // indirect golang.org/x/text v0.3.7 // indirect ) ================================================ FILE: stocks/go/go.sum ================================================ github.com/Xuanwo/go-locale v1.1.0 h1:51gUxhxl66oXAjI9uPGb2O0qwPECpriKQb2hl35mQkg= github.com/Xuanwo/go-locale v1.1.0/go.mod h1:UKrHoZB3FPIk9wIG2/tVSobnHgNnceGSH3Y8DY5cASs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-flutter-desktop/go-flutter v0.52.2 h1:08LdijXBSiqUcSzofrytBPpItF+zBgJ7s0sDixFhbAU= github.com/go-flutter-desktop/go-flutter v0.52.2/go.mod h1:8lIXoHEAZl01qK7pKwUwf/dzF2mD0JRoaxkGoYu32k8= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 h1:zDw5v7qm4yH7N8C8uWd+8Ii9rROdgWxQuGoJ9WDXxfk= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f h1:w3h343WgVLKLITcSpwecCDcq0FO8pAv6A/UG86hhFtY= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.7 h1:I6tZjLXD2Q1kjvNbIzB1wvQBsXmKXiVrhpRE8ZjP5jY= github.com/smartystreets/goconvey v1.6.7/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b h1:2n253B2r0pYSmEV+UNCQoPfU/FiaizQEK5Gu4Bq4JE8= golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= ================================================ FILE: stocks/go/hover.yaml ================================================ #application-name: "stocks" # Uncomment to modify this value. #executable-name: "stocks" # Uncomment to modify this value. Only lowercase a-z, numbers, underscores and no spaces #package-name: "stocks" # Uncomment to modify this value. Only lowercase a-z, numbers and no underscores or spaces license: "" # MANDATORY: Fill in your SPDX license name: https://spdx.org/licenses target: lib/main_desktop.dart # opengl: "none" # Uncomment this line if you have trouble with your OpenGL driver (https://github.com/go-flutter-desktop/go-flutter/issues/272) docker: false engine-version: "" # change to a engine version commit ================================================ FILE: stocks/go/packaging/darwin-bundle/{{.applicationName}} {{.version}}.app/Contents/Info.plist.tmpl ================================================ CFBundleDevelopmentRegion English CFBundleExecutable {{.executableName}} CFBundleGetInfoString {{.description}} CFBundleIconFile icon.icns NSHighResolutionCapable CFBundleIdentifier {{.organizationName}}.{{.packageName}} CFBundleInfoDictionaryVersion 6.0 CFBundleLongVersionString {{.version}} CFBundleName {{.applicationName}} CFBundlePackageType APPL CFBundleShortVersionString {{.version}} CFBundleSignature {{.organizationName}}.{{.packageName}} CFBundleVersion {{.version}} CSResourcesFileMapped NSHumanReadableCopyright NSPrincipalClass NSApplication ================================================ FILE: stocks/go/packaging/darwin-pkg/flat/Distribution.tmpl ================================================ {{.applicationName}} #base.pkg ================================================ FILE: stocks/go/packaging/darwin-pkg/flat/base.pkg/PackageInfo.tmpl ================================================ ================================================ FILE: stocks/go/packaging/linux-appimage/AppRun.tmpl ================================================ #!/bin/sh cd "$(dirname "$0")" exec ./build/{{.executableName}} ================================================ FILE: stocks/go/packaging/linux-appimage/{{.packageName}}.desktop.tmpl ================================================ [Desktop Entry] Version=1.0 Type=Application Terminal=false Categories= Comment={{.description}} Name={{.applicationName}} Icon={{.iconPath}} Exec={{.executablePath}} ================================================ FILE: stocks/go/packaging/linux-deb/DEBIAN/control.tmpl ================================================ Package: {{.packageName}} Architecture: amd64 Maintainer: @{{.author}} Priority: optional Version: {{.version}} Description: {{.description}} ================================================ FILE: stocks/go/packaging/linux-deb/usr/bin/{{.executableName}}.tmpl ================================================ #!/bin/sh /usr/lib/{{.packageName}}/{{.executableName}} ================================================ FILE: stocks/go/packaging/linux-deb/usr/share/applications/{{.executableName}}.desktop.tmpl ================================================ [Desktop Entry] Version=1.0 Type=Application Terminal=false Categories= Comment={{.description}} Name={{.applicationName}} Icon={{.iconPath}} Exec={{.executablePath}} ================================================ FILE: stocks/go/packaging/linux-pkg/PKGBUILD.tmpl ================================================ pkgname={{.packageName}} pkgver={{.version}} pkgrel={{.release}} pkgdesc="{{.description}}" arch=("x86_64") license=('{{.license}}') package() { mkdir -p $pkgdir/ cp * $pkgdir/ -r } ================================================ FILE: stocks/go/packaging/linux-pkg/src/usr/bin/{{.executableName}}.tmpl ================================================ #!/bin/sh /usr/lib/{{.packageName}}/{{.executableName}} ================================================ FILE: stocks/go/packaging/linux-pkg/src/usr/share/applications/{{.executableName}}.desktop.tmpl ================================================ [Desktop Entry] Version=1.0 Type=Application Terminal=false Categories= Comment={{.description}} Name={{.applicationName}} Icon={{.iconPath}} Exec={{.executablePath}} ================================================ FILE: stocks/go/packaging/linux-rpm/BUILDROOT/{{.packageName}}-{{.version}}-{{.release}}.x86_64/usr/bin/{{.executableName}}.tmpl ================================================ #!/bin/sh /usr/lib/{{.packageName}}/{{.executableName}} ================================================ FILE: stocks/go/packaging/linux-rpm/BUILDROOT/{{.packageName}}-{{.version}}-{{.release}}.x86_64/usr/share/applications/{{.executableName}}.desktop.tmpl ================================================ [Desktop Entry] Version=1.0 Type=Application Terminal=false Categories= Comment={{.description}} Name={{.applicationName}} Icon={{.iconPath}} Exec={{.executablePath}} ================================================ FILE: stocks/go/packaging/linux-rpm/SPECS/{{.packageName}}.spec.tmpl ================================================ Name: {{.packageName}} Version: {{.version}} Release: {{.release}} Summary: {{.description}} License: {{.license}} %description {{.description}} %install mkdir -p $RPM_BUILD_ROOT%{_bindir} mkdir -p $RPM_BUILD_ROOT/usr/lib/{{.packageName}} mkdir -p $RPM_BUILD_ROOT%{_datadir}/applications cp -R $RPM_BUILD_DIR/{{.packageName}}-{{.version}}-{{.release}}.x86_64/* $RPM_BUILD_ROOT chmod 0755 $RPM_BUILD_ROOT%{_bindir}/{{.executableName}} chmod 0755 $RPM_BUILD_ROOT%{_datadir}/applications/{{.executableName}}.desktop %files %{_bindir}/{{.executableName}} /usr/lib/{{.packageName}}/ %{_datadir}/applications/{{.executableName}}.desktop ================================================ FILE: stocks/go/packaging/linux-snap/snap/local/{{.executableName}}.desktop.tmpl ================================================ [Desktop Entry] Version=1.0 Type=Application Terminal=false Categories= Comment={{.description}} Name={{.applicationName}} Icon={{.iconPath}} Exec={{.executablePath}} ================================================ FILE: stocks/go/packaging/linux-snap/snap/snapcraft.yaml.tmpl ================================================ name: {{.packageName}} base: core18 version: '{{.version}}' summary: {{.description}} description: | {{.description}} confinement: devmode grade: devel apps: {{.packageName}}: command: {{.executableName}} desktop: local/{{.executableName}}.desktop parts: desktop: plugin: dump source: snap assets: plugin: dump source: build/assets app: plugin: dump source: build stage-packages: - libx11-6 - libxrandr2 - libxcursor1 - libxinerama1 ================================================ FILE: stocks/go/packaging/windows-msi/upgrade-code.txt ================================================ dd8de1ec-bfb9-4bd9-a59a-59e092dae8cb # This GUID is your upgrade code and ensures that you can properly update your app. # Don't change it. ================================================ FILE: stocks/go/packaging/windows-msi/{{.packageName}}.wxs.tmpl ================================================ ================================================ FILE: stocks/lib/i18n/.dartignore ================================================ ================================================ FILE: stocks/lib/i18n/regenerate.md ================================================ ## Regenerating the i18n files The files in this directory are based on ../lib/stock_strings.dart which defines all of the localizable strings used by the stocks app. The stocks app uses the [Dart `intl` package](https://github.com/dart-lang/intl). Rebuilding everything requires two steps. With the `examples/stocks` as the current directory, generate `intl_messages.arb` from `lib/stock_strings.dart`: ``` flutter pub pub run intl_translation:extract_to_arb --output-dir=lib/i18n lib/stock_strings.dart ``` The `intl_messages.arb` file is a JSON format map with one entry for each `Intl.message()` function defined in `stock_strings.dart`. This file was used to create the English and Spanish localizations, `stocks_en.arb` and `stocks_es.arb`. The `intl_messages.arb` wasn't checked into the repository, since it only serves as a template for the other `.arb` files. With the `examples/stocks` as the current directory, generate a `stock_messages_.dart` for each `stocks_.arb` file and `stock_messages_all.dart`, which imports all of the messages files: ``` flutter pub pub run intl_translation:generate_from_arb --output-dir=lib/i18n \ --generated-file-prefix=stock_ --no-use-deferred-loading lib/*.dart lib/i18n/stocks_*.arb ``` The `StockStrings` class uses the generated `initializeMessages()` function (`stock_messages_all.dart`) to load the localized messages and `Intl.message()` to look them up. ================================================ FILE: stocks/lib/i18n/stock_messages_all.dart ================================================ // DO NOT EDIT. This is code generated via package:intl/generate_localized.dart // This is a library that looks up messages for specific locales by // delegating to the appropriate library. import 'dart:async'; import 'package:intl/intl.dart'; import 'package:intl/message_lookup_by_library.dart'; // ignore: implementation_imports import 'package:intl/src/intl_helpers.dart'; import 'stock_messages_en.dart' as messages_en; import 'stock_messages_es.dart' as messages_es; typedef Future LibraryLoader(); Map _deferredLibraries = { 'en': () => new Future.value(null), 'es': () => new Future.value(null), }; MessageLookupByLibrary _findExact(localeName) { switch (localeName) { case 'en': return messages_en.messages; case 'es': return messages_es.messages; default: return null; } } /// User programs should call this before using [localeName] for messages. Future initializeMessages(String localeName) async { var availableLocale = Intl.verifiedLocale( localeName, (locale) => _deferredLibraries[locale] != null, onFailure: (_) => null); if (availableLocale == null) { return new Future.value(false); } var lib = _deferredLibraries[availableLocale]; await (lib == null ? new Future.value(false) : lib()); initializeInternalMessageLookup(() => new CompositeMessageLookup()); messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor); return new Future.value(true); } bool _messagesExistFor(String locale) { try { return _findExact(locale) != null; } catch (e) { return false; } } MessageLookupByLibrary _findGeneratedMessagesFor(locale) { var actualLocale = Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null); if (actualLocale == null) return null; return _findExact(actualLocale); } ================================================ FILE: stocks/lib/i18n/stock_messages_en.dart ================================================ // DO NOT EDIT. This is code generated via package:intl/generate_localized.dart // This is a library that provides messages for a en locale. All the // messages from the main program should be duplicated here with the same // function name. import 'package:intl/intl.dart'; import 'package:intl/message_lookup_by_library.dart'; final messages = new MessageLookup(); // ignore: unused_element final _keepAnalysisHappy = Intl.defaultLocale; // ignore: non_constant_identifier_names typedef MessageIfAbsent(String message_str, List args); class MessageLookup extends MessageLookupByLibrary { get localeName => 'en'; final messages = _notInlinedMessages(_notInlinedMessages); static _notInlinedMessages(_) => { "market" : MessageLookupByLibrary.simpleMessage("MARKET"), "portfolio" : MessageLookupByLibrary.simpleMessage("PORTFOLIO"), "title" : MessageLookupByLibrary.simpleMessage("Stocks") }; } ================================================ FILE: stocks/lib/i18n/stock_messages_es.dart ================================================ // DO NOT EDIT. This is code generated via package:intl/generate_localized.dart // This is a library that provides messages for a es locale. All the // messages from the main program should be duplicated here with the same // function name. import 'package:intl/intl.dart'; import 'package:intl/message_lookup_by_library.dart'; final messages = new MessageLookup(); // ignore: unused_element final _keepAnalysisHappy = Intl.defaultLocale; // ignore: non_constant_identifier_names typedef MessageIfAbsent(String message_str, List args); class MessageLookup extends MessageLookupByLibrary { get localeName => 'es'; final messages = _notInlinedMessages(_notInlinedMessages); static _notInlinedMessages(_) => { "market" : MessageLookupByLibrary.simpleMessage("MERCADO"), "portfolio" : MessageLookupByLibrary.simpleMessage("CARTERA"), "title" : MessageLookupByLibrary.simpleMessage("Acciones") }; } ================================================ FILE: stocks/lib/i18n/stocks_en.arb ================================================ { "title": "Stocks", "@title": { "description": "Title for the Stocks application", "type": "text", "placeholders": {} }, "market": "MARKET", "@market": { "description": "Label for the Market tab", "type": "text", "placeholders": {} }, "portfolio": "PORTFOLIO", "@portfolio": { "description": "Label for the Portfolio tab", "type": "text", "placeholders": {} } } ================================================ FILE: stocks/lib/i18n/stocks_es.arb ================================================ { "title": "Acciones", "@title": { "description": "Title for the Stocks application", "type": "text", "placeholders": {} }, "market": "MERCADO", "@market": { "description": "Label for the Market tab", "type": "text", "placeholders": {} }, "portfolio": "CARTERA", "@portfolio": { "description": "Label for the Portfolio tab", "type": "text", "placeholders": {} } } ================================================ FILE: stocks/lib/main.dart ================================================ import 'package:flutter/widgets.dart'; import 'package:stocks/stock.dart'; void main() { runApp(new StocksApp()); } ================================================ FILE: stocks/lib/main_desktop.dart ================================================ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:stocks/stock.dart'; void main() { debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; runApp(new StocksApp()); } ================================================ FILE: stocks/lib/stock.dart ================================================ // Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. library stocks; import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart' show debugPaintSizeEnabled, debugPaintBaselinesEnabled, debugPaintLayerBordersEnabled, debugPaintPointersEnabled, debugRepaintRainbowEnabled; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter/foundation.dart' show debugDefaultTargetPlatformOverride; import 'stock_data.dart'; import 'stock_home.dart'; import 'stock_settings.dart'; import 'stock_strings.dart'; import 'stock_symbol_viewer.dart'; import 'stock_types.dart'; class _StocksLocalizationsDelegate extends LocalizationsDelegate { @override Future load(Locale locale) => StockStrings.load(locale); @override bool isSupported(Locale locale) => locale.languageCode == 'es' || locale.languageCode == 'en'; @override bool shouldReload(_StocksLocalizationsDelegate old) => false; } class StocksApp extends StatefulWidget { @override StocksAppState createState() => new StocksAppState(); } class StocksAppState extends State { StockData stocks; StockConfiguration _configuration = new StockConfiguration( stockMode: StockMode.optimistic, backupMode: BackupMode.enabled, debugShowGrid: false, debugShowSizes: false, debugShowBaselines: false, debugShowLayers: false, debugShowPointers: false, debugShowRainbow: false, showPerformanceOverlay: false, showSemanticsDebugger: false); @override void initState() { super.initState(); stocks = new StockData(); } void configurationUpdater(StockConfiguration value) { setState(() { _configuration = value; }); } ThemeData get theme { switch (_configuration.stockMode) { case StockMode.optimistic: return new ThemeData(brightness: Brightness.light, primarySwatch: Colors.purple, fontFamily: 'Roboto'); case StockMode.pessimistic: return new ThemeData(brightness: Brightness.dark, accentColor: Colors.redAccent, fontFamily: 'Roboto'); } assert(_configuration.stockMode != null); return null; } Route _getRoute(RouteSettings settings) { // Routes, by convention, are split on slashes, like filesystem paths. final List path = settings.name.split('/'); // We only support paths that start with a slash, so bail if // the first component is not empty: if (path[0] != '') return null; // If the path is "/stock:..." then show a stock page for the // specified stock symbol. if (path[1].startsWith('stock:')) { // We don't yet support subpages of a stock, so bail if there's // any more path components. if (path.length != 2) return null; // Extract the symbol part of "stock:..." and return a route // for that symbol. final String symbol = path[1].substring(6); return new MaterialPageRoute( settings: settings, builder: (BuildContext context) => new StockSymbolPage(symbol: symbol, stocks: stocks), ); } // The other paths we support are in the routes table. return null; } @override Widget build(BuildContext context) { assert(() { debugPaintSizeEnabled = _configuration.debugShowSizes; debugPaintBaselinesEnabled = _configuration.debugShowBaselines; debugPaintLayerBordersEnabled = _configuration.debugShowLayers; debugPaintPointersEnabled = _configuration.debugShowPointers; debugRepaintRainbowEnabled = _configuration.debugShowRainbow; return true; }()); return new MaterialApp( title: 'Stocks', theme: theme, localizationsDelegates: >[ new _StocksLocalizationsDelegate(), GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, ], supportedLocales: const [ const Locale('en', 'US'), const Locale('es', 'ES'), ], debugShowMaterialGrid: _configuration.debugShowGrid, showPerformanceOverlay: _configuration.showPerformanceOverlay, showSemanticsDebugger: _configuration.showSemanticsDebugger, routes: { '/': (BuildContext context) => new StockHome(stocks, _configuration, configurationUpdater), '/settings': (BuildContext context) => new StockSettings(_configuration, configurationUpdater) }, onGenerateRoute: _getRoute, ); } } ================================================ FILE: stocks/lib/stock_arrow.dart ================================================ // Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import 'dart:math' as math; import 'package:flutter/material.dart'; class StockArrowPainter extends CustomPainter { StockArrowPainter({ this.color, this.percentChange }); final Color color; final double percentChange; @override void paint(Canvas canvas, Size size) { final Paint paint = new Paint()..color = color; paint.strokeWidth = 1.0; const double padding = 2.0; assert(padding > paint.strokeWidth / 2.0); // make sure the circle remains inside the box final double r = (size.shortestSide - padding) / 2.0; // radius of the circle final double centerX = padding + r; final double centerY = padding + r; // Draw the arrow. const double w = 8.0; double h = 5.0; double arrowY; if (percentChange < 0.0) { h = -h; arrowY = centerX + 1.0; } else { arrowY = centerX - 1.0; } final Path path = new Path(); path.moveTo(centerX, arrowY - h); // top of the arrow path.lineTo(centerX + w, arrowY + h); path.lineTo(centerX - w, arrowY + h); path.close(); paint.style = PaintingStyle.fill; canvas.drawPath(path, paint); // Draw a circle that circumscribes the arrow. paint.style = PaintingStyle.stroke; canvas.drawCircle(new Offset(centerX, centerY), r, paint); } @override bool shouldRepaint(StockArrowPainter oldDelegate) { return oldDelegate.color != color || oldDelegate.percentChange != percentChange; } } class StockArrow extends StatelessWidget { const StockArrow({ Key key, this.percentChange }) : super(key: key); final double percentChange; int _colorIndexForPercentChange(double percentChange) { const double maxPercent = 10.0; final double normalizedPercentChange = math.min(percentChange.abs(), maxPercent) / maxPercent; return 100 + (normalizedPercentChange * 8.0).floor() * 100; } Color _colorForPercentChange(double percentChange) { if (percentChange > 0) return Colors.green[_colorIndexForPercentChange(percentChange)]; return Colors.red[_colorIndexForPercentChange(percentChange)]; } @override Widget build(BuildContext context) { return new Container( width: 40.0, height: 40.0, margin: const EdgeInsets.symmetric(horizontal: 5.0), child: new CustomPaint( painter: new StockArrowPainter( // TODO(jackson): This should change colors with the theme color: _colorForPercentChange(percentChange), percentChange: percentChange ) ) ); } } ================================================ FILE: stocks/lib/stock_data.dart ================================================ // Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Snapshot from http://www.nasdaq.com/screening/company-list.aspx // Fetched 2/23/2014. // "Symbol","Name","LastSale","MarketCap","IPOyear","Sector","industry","Summary Quote", // Data in stock_data.json import 'dart:convert'; import 'dart:math' as math; import 'package:flutter/foundation.dart'; import 'package:http/http.dart' as http; final math.Random _rng = new math.Random(); class Stock { String symbol; String name; double lastSale; String marketCap; double percentChange; Stock(this.symbol, this.name, this.lastSale, this.marketCap, this.percentChange); Stock.fromFields(List fields) { // FIXME: This class should only have static data, not lastSale, etc. // "Symbol","Name","LastSale","MarketCap","IPOyear","Sector","industry","Summary Quote", lastSale = 0.0; try { lastSale = double.parse(fields[2]); } catch (_) {} symbol = fields[0]; name = fields[1]; marketCap = fields[4]; percentChange = (_rng.nextDouble() * 20) - 10; } } class StockData extends ChangeNotifier { StockData() { if (actuallyFetchData) { _httpClient = new http.Client(); _fetchNextChunk(); } } final List _symbols = []; final Map _stocks = {}; Iterable get allSymbols => _symbols; Stock operator [](String symbol) => _stocks[symbol]; bool get loading => _httpClient != null; void add(List data) { for (List fields in data) { final Stock stock = new Stock.fromFields(fields.cast()); _symbols.add(stock.symbol); _stocks[stock.symbol] = stock; } _symbols.sort(); notifyListeners(); } static const int _chunkCount = 30; int _nextChunk = 0; String _urlToFetch(int chunk) { return 'https://domokit.github.io/examples/stocks/data/stock_data_$chunk.json'; } http.Client _httpClient; static bool actuallyFetchData = true; void _fetchNextChunk() { _httpClient.get(_urlToFetch(_nextChunk++)).then((http.Response response) { final String json = response.body; if (json == null) { debugPrint('Failed to load stock data chunk ${_nextChunk - 1}'); _end(); return; } const JsonDecoder decoder = const JsonDecoder(); add(decoder.convert(json)); if (_nextChunk < _chunkCount) { _fetchNextChunk(); } else { _end(); } }); } void _end() { _httpClient?.close(); _httpClient = null; } } ================================================ FILE: stocks/lib/stock_home.dart ================================================ // Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart' show debugDumpRenderTree, debugDumpLayerTree, debugDumpSemanticsTree, DebugSemanticsDumpOrder; import 'package:flutter/scheduler.dart' show timeDilation; import 'stock_data.dart'; import 'stock_list.dart'; import 'stock_strings.dart'; import 'stock_symbol_viewer.dart'; import 'stock_types.dart'; typedef void ModeUpdater(StockMode mode); enum _StockMenuItem { autorefresh, refresh, speedUp, speedDown } enum StockHomeTab { market, portfolio } class _NotImplementedDialog extends StatelessWidget { @override Widget build(BuildContext context) { return new AlertDialog( title: const Text('Not Implemented'), content: const Text('This feature has not yet been implemented.'), actions: [ new FlatButton( onPressed: debugDumpApp, child: new Row( children: [ const Icon( Icons.dvr, size: 18.0, ), new Container( width: 8.0, ), const Text('DUMP APP TO CONSOLE'), ], ), ), new FlatButton( onPressed: () { Navigator.pop(context, false); }, child: const Text('OH WELL'), ), ], ); } } class StockHome extends StatefulWidget { const StockHome(this.stocks, this.configuration, this.updater); final StockData stocks; final StockConfiguration configuration; final ValueChanged updater; @override StockHomeState createState() => new StockHomeState(); } class StockHomeState extends State { final GlobalKey _scaffoldKey = new GlobalKey(); final TextEditingController _searchQuery = new TextEditingController(); bool _isSearching = false; bool _autorefresh = false; void _handleSearchBegin() { ModalRoute.of(context).addLocalHistoryEntry(new LocalHistoryEntry( onRemove: () { setState(() { _isSearching = false; _searchQuery.clear(); }); }, )); setState(() { _isSearching = true; }); } void _handleStockModeChange(StockMode value) { if (widget.updater != null) widget.updater(widget.configuration.copyWith(stockMode: value)); } void _handleStockMenu(BuildContext context, _StockMenuItem value) { switch (value) { case _StockMenuItem.autorefresh: setState(() { _autorefresh = !_autorefresh; }); break; case _StockMenuItem.refresh: showDialog( context: context, builder: (BuildContext context) => new _NotImplementedDialog(), ); break; case _StockMenuItem.speedUp: timeDilation /= 5.0; break; case _StockMenuItem.speedDown: timeDilation *= 5.0; break; } } Widget _buildDrawer(BuildContext context) { return new Drawer( child: new ListView( children: [ const DrawerHeader(child: const Center(child: const Text('Stocks'))), const ListTile( leading: const Icon(Icons.assessment), title: const Text('Stock List'), selected: true, ), const ListTile( leading: const Icon(Icons.account_balance), title: const Text('Account Balance'), enabled: false, ), new ListTile( leading: const Icon(Icons.dvr), title: const Text('Dump App to Console'), onTap: () { try { debugDumpApp(); debugDumpRenderTree(); debugDumpLayerTree(); debugDumpSemanticsTree(DebugSemanticsDumpOrder.traversalOrder); } catch (e, stack) { debugPrint('Exception while dumping app:\n$e\n$stack'); } }, ), const Divider(), new ListTile( leading: const Icon(Icons.thumb_up), title: const Text('Optimistic'), trailing: new Radio( value: StockMode.optimistic, groupValue: widget.configuration.stockMode, onChanged: _handleStockModeChange, ), onTap: () { _handleStockModeChange(StockMode.optimistic); }, ), new ListTile( leading: const Icon(Icons.thumb_down), title: const Text('Pessimistic'), trailing: new Radio( value: StockMode.pessimistic, groupValue: widget.configuration.stockMode, onChanged: _handleStockModeChange, ), onTap: () { _handleStockModeChange(StockMode.pessimistic); }, ), const Divider(), new ListTile( leading: const Icon(Icons.settings), title: const Text('Settings'), onTap: _handleShowSettings, ), new ListTile( leading: const Icon(Icons.help), title: const Text('About'), onTap: _handleShowAbout, ), ], ), ); } void _handleShowSettings() { Navigator.popAndPushNamed(context, '/settings'); } void _handleShowAbout() { showAboutDialog(context: context); } Widget buildAppBar() { return new AppBar( elevation: 0.0, title: new Text(StockStrings.of(context).title()), actions: [ new IconButton( icon: const Icon(Icons.search), onPressed: _handleSearchBegin, tooltip: 'Search', ), new PopupMenuButton<_StockMenuItem>( onSelected: (_StockMenuItem value) { _handleStockMenu(context, value); }, itemBuilder: (BuildContext context) => >[ new CheckedPopupMenuItem<_StockMenuItem>( value: _StockMenuItem.autorefresh, checked: _autorefresh, child: const Text('Autorefresh'), ), const PopupMenuItem<_StockMenuItem>( value: _StockMenuItem.refresh, child: const Text('Refresh'), ), const PopupMenuItem<_StockMenuItem>( value: _StockMenuItem.speedUp, child: const Text('Increase animation speed'), ), const PopupMenuItem<_StockMenuItem>( value: _StockMenuItem.speedDown, child: const Text('Decrease animation speed'), ), ], ), ], bottom: new TabBar( tabs: [ new Tab(text: StockStrings.of(context).market()), new Tab(text: StockStrings.of(context).portfolio()), ], ), ); } static Iterable _getStockList(StockData stocks, Iterable symbols) { return symbols.map((String symbol) => stocks[symbol]) .where((Stock stock) => stock != null); } Iterable _filterBySearchQuery(Iterable stocks) { if (_searchQuery.text.isEmpty) return stocks; final RegExp regexp = new RegExp(_searchQuery.text, caseSensitive: false); return stocks.where((Stock stock) => stock.symbol.contains(regexp)); } void _buyStock(Stock stock) { setState(() { stock.percentChange = 100.0 * (1.0 / stock.lastSale); stock.lastSale += 1.0; }); _scaffoldKey.currentState.showSnackBar(new SnackBar( content: new Text('Purchased ${stock.symbol} for ${stock.lastSale}'), action: new SnackBarAction( label: 'BUY MORE', onPressed: () { _buyStock(stock); }, ), )); } Widget _buildStockList(BuildContext context, Iterable stocks, StockHomeTab tab) { return new StockList( stocks: stocks.toList(), onAction: _buyStock, onOpen: (Stock stock) { Navigator.pushNamed(context, '/stock:${stock.symbol}'); }, onShow: (Stock stock) { _scaffoldKey.currentState.showBottomSheet((BuildContext context) => new StockSymbolBottomSheet(stock: stock)); }, ); } Widget _buildStockTab(BuildContext context, StockHomeTab tab, List stockSymbols) { return new AnimatedBuilder( key: new ValueKey(tab), animation: new Listenable.merge([_searchQuery, widget.stocks]), builder: (BuildContext context, Widget child) { return _buildStockList(context, _filterBySearchQuery(_getStockList(widget.stocks, stockSymbols)).toList(), tab); }, ); } static const List portfolioSymbols = const ['AAPL','FIZZ', 'FIVE', 'FLAT', 'ZINC', 'ZNGA']; Widget buildSearchBar() { return new AppBar( leading: new BackButton( color: Theme.of(context).accentColor, ), title: new TextField( controller: _searchQuery, autofocus: true, decoration: const InputDecoration( hintText: 'Search stocks', ), ), backgroundColor: Theme.of(context).canvasColor, ); } void _handleCreateCompany() { showModalBottomSheet( context: context, builder: (BuildContext context) => new _CreateCompanySheet(), ); } Widget buildFloatingActionButton() { return new FloatingActionButton( tooltip: 'Create company', child: const Icon(Icons.add), backgroundColor: Theme.of(context).accentColor, onPressed: _handleCreateCompany, ); } @override Widget build(BuildContext context) { return new DefaultTabController( length: 2, child: new Scaffold( key: _scaffoldKey, appBar: _isSearching ? buildSearchBar() : buildAppBar(), floatingActionButton: buildFloatingActionButton(), drawer: _buildDrawer(context), body: new TabBarView( children: [ _buildStockTab(context, StockHomeTab.market, widget.stocks.allSymbols), _buildStockTab(context, StockHomeTab.portfolio, portfolioSymbols), ], ), ), ); } } class _CreateCompanySheet extends StatelessWidget { @override Widget build(BuildContext context) { return new Column( children: const [ const TextField( autofocus: true, decoration: const InputDecoration( hintText: 'Company Name', ), ), const Text('(This demo is not yet complete.)'), // For example, we could add a button that actually updates the list // and then contacts the server, etc. ], ); } } ================================================ FILE: stocks/lib/stock_list.dart ================================================ // Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import 'package:flutter/material.dart'; import 'stock_data.dart'; import 'stock_row.dart'; class StockList extends StatelessWidget { const StockList({ Key key, this.stocks, this.onOpen, this.onShow, this.onAction }) : super(key: key); final List stocks; final StockRowActionCallback onOpen; final StockRowActionCallback onShow; final StockRowActionCallback onAction; @override Widget build(BuildContext context) { return new ListView.builder( key: const ValueKey('stock-list'), itemExtent: StockRow.kHeight, itemCount: stocks.length, itemBuilder: (BuildContext context, int index) { return new StockRow( stock: stocks[index], onPressed: onOpen, onDoubleTap: onShow, onLongPressed: onAction ); }, ); } } ================================================ FILE: stocks/lib/stock_row.dart ================================================ // Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import 'package:flutter/material.dart'; import 'stock_arrow.dart'; import 'stock_data.dart'; typedef void StockRowActionCallback(Stock stock); class StockRow extends StatelessWidget { StockRow({ this.stock, this.onPressed, this.onDoubleTap, this.onLongPressed }) : super(key: new ObjectKey(stock)); final Stock stock; final StockRowActionCallback onPressed; final StockRowActionCallback onDoubleTap; final StockRowActionCallback onLongPressed; static const double kHeight = 79.0; GestureTapCallback _getHandler(StockRowActionCallback callback) { return callback == null ? null : () => callback(stock); } @override Widget build(BuildContext context) { final String lastSale = '\$${stock.lastSale.toStringAsFixed(2)}'; String changeInPrice = '${stock.percentChange.toStringAsFixed(2)}%'; if (stock.percentChange > 0) changeInPrice = '+' + changeInPrice; return new InkWell( onTap: _getHandler(onPressed), onDoubleTap: _getHandler(onDoubleTap), onLongPress: _getHandler(onLongPressed), child: new Container( padding: const EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 20.0), decoration: new BoxDecoration( border: new Border( bottom: new BorderSide(color: Theme.of(context).dividerColor) ) ), child: new Row( children: [ new Container( margin: const EdgeInsets.only(right: 5.0), child: new Hero( tag: stock, child: new StockArrow(percentChange: stock.percentChange) ) ), new Expanded( child: new Row( children: [ new Expanded( flex: 2, child: new Text( stock.symbol ) ), new Expanded( child: new Text( lastSale, textAlign: TextAlign.right ) ), new Expanded( child: new Text( changeInPrice, textAlign: TextAlign.right ) ), ], crossAxisAlignment: CrossAxisAlignment.baseline, textBaseline: DefaultTextStyle.of(context).style.textBaseline ) ), ] ) ) ); } } ================================================ FILE: stocks/lib/stock_settings.dart ================================================ // Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import 'package:flutter/material.dart'; import 'stock_types.dart'; class StockSettings extends StatefulWidget { const StockSettings(this.configuration, this.updater); final StockConfiguration configuration; final ValueChanged updater; @override StockSettingsState createState() => new StockSettingsState(); } class StockSettingsState extends State { void _handleOptimismChanged(bool value) { value ??= false; sendUpdates(widget.configuration.copyWith(stockMode: value ? StockMode.optimistic : StockMode.pessimistic)); } void _handleBackupChanged(bool value) { sendUpdates(widget.configuration.copyWith(backupMode: value ? BackupMode.enabled : BackupMode.disabled)); } void _handleShowGridChanged(bool value) { sendUpdates(widget.configuration.copyWith(debugShowGrid: value)); } void _handleShowSizesChanged(bool value) { sendUpdates(widget.configuration.copyWith(debugShowSizes: value)); } void _handleShowBaselinesChanged(bool value) { sendUpdates(widget.configuration.copyWith(debugShowBaselines: value)); } void _handleShowLayersChanged(bool value) { sendUpdates(widget.configuration.copyWith(debugShowLayers: value)); } void _handleShowPointersChanged(bool value) { sendUpdates(widget.configuration.copyWith(debugShowPointers: value)); } void _handleShowRainbowChanged(bool value) { sendUpdates(widget.configuration.copyWith(debugShowRainbow: value)); } void _handleShowPerformanceOverlayChanged(bool value) { sendUpdates(widget.configuration.copyWith(showPerformanceOverlay: value)); } void _handleShowSemanticsDebuggerChanged(bool value) { sendUpdates(widget.configuration.copyWith(showSemanticsDebugger: value)); } void _confirmOptimismChange() { switch (widget.configuration.stockMode) { case StockMode.optimistic: _handleOptimismChanged(false); break; case StockMode.pessimistic: showDialog( context: context, builder: (BuildContext context) { return new AlertDialog( title: const Text('Change mode?'), content: const Text('Optimistic mode means everything is awesome. Are you sure you can handle that?'), actions: [ new FlatButton( child: const Text('NO THANKS'), onPressed: () { Navigator.pop(context, false); } ), new FlatButton( child: const Text('AGREE'), onPressed: () { Navigator.pop(context, true); } ), ], ); }, ).then(_handleOptimismChanged); break; } } void sendUpdates(StockConfiguration value) { if (widget.updater != null) widget.updater(value); } Widget buildAppBar(BuildContext context) { return new AppBar( title: const Text('Settings') ); } Widget buildSettingsPane(BuildContext context) { final List rows = [ new ListTile( leading: const Icon(Icons.thumb_up), title: const Text('Everything is awesome'), onTap: _confirmOptimismChange, trailing: new Checkbox( value: widget.configuration.stockMode == StockMode.optimistic, onChanged: (bool value) => _confirmOptimismChange(), ), ), new ListTile( leading: const Icon(Icons.backup), title: const Text('Back up stock list to the cloud'), onTap: () { _handleBackupChanged(!(widget.configuration.backupMode == BackupMode.enabled)); }, trailing: new Switch( value: widget.configuration.backupMode == BackupMode.enabled, onChanged: _handleBackupChanged, ), ), new ListTile( leading: const Icon(Icons.picture_in_picture), title: const Text('Show rendering performance overlay'), onTap: () { _handleShowPerformanceOverlayChanged(!widget.configuration.showPerformanceOverlay); }, trailing: new Switch( value: widget.configuration.showPerformanceOverlay, onChanged: _handleShowPerformanceOverlayChanged, ), ), new ListTile( leading: const Icon(Icons.accessibility), title: const Text('Show semantics overlay'), onTap: () { _handleShowSemanticsDebuggerChanged(!widget.configuration.showSemanticsDebugger); }, trailing: new Switch( value: widget.configuration.showSemanticsDebugger, onChanged: _handleShowSemanticsDebuggerChanged, ), ), ]; assert(() { // material grid and size construction lines are only available in checked mode rows.addAll([ new ListTile( leading: const Icon(Icons.border_clear), title: const Text('Show material grid (for debugging)'), onTap: () { _handleShowGridChanged(!widget.configuration.debugShowGrid); }, trailing: new Switch( value: widget.configuration.debugShowGrid, onChanged: _handleShowGridChanged, ), ), new ListTile( leading: const Icon(Icons.border_all), title: const Text('Show construction lines (for debugging)'), onTap: () { _handleShowSizesChanged(!widget.configuration.debugShowSizes); }, trailing: new Switch( value: widget.configuration.debugShowSizes, onChanged: _handleShowSizesChanged, ), ), new ListTile( leading: const Icon(Icons.format_color_text), title: const Text('Show baselines (for debugging)'), onTap: () { _handleShowBaselinesChanged(!widget.configuration.debugShowBaselines); }, trailing: new Switch( value: widget.configuration.debugShowBaselines, onChanged: _handleShowBaselinesChanged, ), ), new ListTile( leading: const Icon(Icons.filter_none), title: const Text('Show layer boundaries (for debugging)'), onTap: () { _handleShowLayersChanged(!widget.configuration.debugShowLayers); }, trailing: new Switch( value: widget.configuration.debugShowLayers, onChanged: _handleShowLayersChanged, ), ), new ListTile( leading: const Icon(Icons.mouse), title: const Text('Show pointer hit-testing (for debugging)'), onTap: () { _handleShowPointersChanged(!widget.configuration.debugShowPointers); }, trailing: new Switch( value: widget.configuration.debugShowPointers, onChanged: _handleShowPointersChanged, ), ), new ListTile( leading: const Icon(Icons.gradient), title: const Text('Show repaint rainbow (for debugging)'), onTap: () { _handleShowRainbowChanged(!widget.configuration.debugShowRainbow); }, trailing: new Switch( value: widget.configuration.debugShowRainbow, onChanged: _handleShowRainbowChanged, ), ), ]); return true; }()); return new ListView( padding: const EdgeInsets.symmetric(vertical: 20.0), children: rows, ); } @override Widget build(BuildContext context) { return new Scaffold( appBar: buildAppBar(context), body: buildSettingsPane(context) ); } } ================================================ FILE: stocks/lib/stock_strings.dart ================================================ // Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import 'dart:async'; import 'package:intl/intl.dart'; import 'package:flutter/widgets.dart'; import 'i18n/stock_messages_all.dart'; // Information about how this file relates to i18n/stock_messages_all.dart and how the i18n files // were generated can be found in i18n/regenerate.md. class StockStrings { StockStrings(Locale locale) : _localeName = locale.toString(); final String _localeName; static Future load(Locale locale) { return initializeMessages(locale.toString()) .then((Object _) { return new StockStrings(locale); }); } static StockStrings of(BuildContext context) { return Localizations.of(context, StockStrings); } String title() { return Intl.message( '', name: 'title', desc: 'Title for the Stocks application', locale: _localeName, ); } String market() => Intl.message( 'MARKET', name: 'market', desc: 'Label for the Market tab', locale: _localeName, ); String portfolio() => Intl.message( 'PORTFOLIO', name: 'portfolio', desc: 'Label for the Portfolio tab', locale: _localeName, ); } ================================================ FILE: stocks/lib/stock_symbol_viewer.dart ================================================ // Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import 'package:flutter/material.dart'; import 'stock_arrow.dart'; import 'stock_data.dart'; class _StockSymbolView extends StatelessWidget { const _StockSymbolView({ this.stock, this.arrow }); final Stock stock; final Widget arrow; @override Widget build(BuildContext context) { assert(stock != null); final String lastSale = '\$${stock.lastSale.toStringAsFixed(2)}'; String changeInPrice = '${stock.percentChange.toStringAsFixed(2)}%'; if (stock.percentChange > 0) changeInPrice = '+' + changeInPrice; return new Container( padding: const EdgeInsets.all(20.0), child: new Column( children: [ new Row( children: [ new Text( '${stock.symbol}', ), arrow, ], mainAxisAlignment: MainAxisAlignment.spaceBetween ), new Text('Last Sale'), new Text('$lastSale ($changeInPrice)'), new Container( height: 8.0 ), new Text('Market Cap'), new Text('${stock.marketCap}'), new Container( height: 8.0 ), new RichText( text: new TextSpan( style: DefaultTextStyle.of(context).style.merge(const TextStyle(fontSize: 8.0)), text: 'Prices may be delayed by ', children: const [ const TextSpan(text: 'several', style: const TextStyle(fontStyle: FontStyle.italic)), const TextSpan(text: ' years.'), ] ) ), ], mainAxisSize: MainAxisSize.min ) ); } } class StockSymbolPage extends StatelessWidget { const StockSymbolPage({ this.symbol, this.stocks }); final String symbol; final StockData stocks; @override Widget build(BuildContext context) { return new AnimatedBuilder( animation: stocks, builder: (BuildContext context, Widget child) { final Stock stock = stocks[symbol]; return new Scaffold( appBar: new AppBar( title: new Text(stock?.name ?? symbol) ), body: new SingleChildScrollView( child: new Container( margin: const EdgeInsets.all(20.0), child: new Card( child: new AnimatedCrossFade( duration: const Duration(milliseconds: 300), firstChild: const Padding( padding: const EdgeInsets.all(20.0), child: const Center(child: const CircularProgressIndicator()), ), secondChild: stock != null ? new _StockSymbolView( stock: stock, arrow: new Hero( tag: stock, child: new StockArrow(percentChange: stock.percentChange), ), ) : new Padding( padding: const EdgeInsets.all(20.0), child: new Center(child: new Text('$symbol not found')), ), crossFadeState: stock == null && stocks.loading ? CrossFadeState.showFirst : CrossFadeState.showSecond, ), ) ) ) ); }, ); } } class StockSymbolBottomSheet extends StatelessWidget { const StockSymbolBottomSheet({ this.stock }); final Stock stock; @override Widget build(BuildContext context) { return new Container( padding: const EdgeInsets.all(10.0), decoration: const BoxDecoration( border: const Border(top: const BorderSide(color: Colors.black26)) ), child: new _StockSymbolView( stock: stock, arrow: new StockArrow(percentChange: stock.percentChange) ) ); } } ================================================ FILE: stocks/lib/stock_types.dart ================================================ // Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import 'package:flutter/foundation.dart'; enum StockMode { optimistic, pessimistic } enum BackupMode { enabled, disabled } class StockConfiguration { StockConfiguration({ @required this.stockMode, @required this.backupMode, @required this.debugShowGrid, @required this.debugShowSizes, @required this.debugShowBaselines, @required this.debugShowLayers, @required this.debugShowPointers, @required this.debugShowRainbow, @required this.showPerformanceOverlay, @required this.showSemanticsDebugger }) : assert(stockMode != null), assert(backupMode != null), assert(debugShowGrid != null), assert(debugShowSizes != null), assert(debugShowBaselines != null), assert(debugShowLayers != null), assert(debugShowPointers != null), assert(debugShowRainbow != null), assert(showPerformanceOverlay != null), assert(showSemanticsDebugger != null); final StockMode stockMode; final BackupMode backupMode; final bool debugShowGrid; final bool debugShowSizes; final bool debugShowBaselines; final bool debugShowLayers; final bool debugShowPointers; final bool debugShowRainbow; final bool showPerformanceOverlay; final bool showSemanticsDebugger; StockConfiguration copyWith({ StockMode stockMode, BackupMode backupMode, bool debugShowGrid, bool debugShowSizes, bool debugShowBaselines, bool debugShowLayers, bool debugShowPointers, bool debugShowRainbow, bool showPerformanceOverlay, bool showSemanticsDebugger }) { return new StockConfiguration( stockMode: stockMode ?? this.stockMode, backupMode: backupMode ?? this.backupMode, debugShowGrid: debugShowGrid ?? this.debugShowGrid, debugShowSizes: debugShowSizes ?? this.debugShowSizes, debugShowBaselines: debugShowBaselines ?? this.debugShowBaselines, debugShowLayers: debugShowLayers ?? this.debugShowLayers, debugShowPointers: debugShowPointers ?? this.debugShowPointers, debugShowRainbow: debugShowRainbow ?? this.debugShowRainbow, showPerformanceOverlay: showPerformanceOverlay ?? this.showPerformanceOverlay, showSemanticsDebugger: showSemanticsDebugger ?? this.showSemanticsDebugger ); } } ================================================ FILE: stocks/pubspec.yaml ================================================ name: stocks description: A simple stocks application environment: # The pub client defaults to an <2.0.0 sdk constraint which we need to explicitly overwrite. sdk: ">=2.0.0-dev.68.0 <3.0.0" dependencies: flutter: sdk: flutter flutter_localizations: sdk: flutter intl: http: flutter: uses-material-design: true fonts: - family: Roboto fonts: - asset: fonts/Roboto/Roboto-Thin.ttf weight: 100 - asset: fonts/Roboto/Roboto-Light.ttf weight: 300 - asset: fonts/Roboto/Roboto-Regular.ttf weight: 400 - asset: fonts/Roboto/Roboto-Medium.ttf weight: 500 - asset: fonts/Roboto/Roboto-Bold.ttf weight: 700 - asset: fonts/Roboto/Roboto-Black.ttf weight: 900 ================================================ FILE: text_demo/.gitignore ================================================ # Miscellaneous *.class *.log *.pyc *.swp .DS_Store .atom/ .buildlog/ .history .svn/ # IntelliJ related *.iml *.ipr *.iws .idea/ # Visual Studio Code related .vscode/ # Flutter/Dart/Pub related **/doc/api/ .dart_tool/ .flutter-plugins .packages .pub-cache/ .pub/ /build/ # Android related **/android/**/gradle-wrapper.jar **/android/.gradle **/android/captures/ **/android/gradlew **/android/gradlew.bat **/android/local.properties **/android/**/GeneratedPluginRegistrant.java # iOS/XCode related **/ios/**/*.mode1v3 **/ios/**/*.mode2v3 **/ios/**/*.moved-aside **/ios/**/*.pbxuser **/ios/**/*.perspectivev3 **/ios/**/*sync/ **/ios/**/.sconsign.dblite **/ios/**/.tags* **/ios/**/.vagrant/ **/ios/**/DerivedData/ **/ios/**/Icon? **/ios/**/Pods/ **/ios/**/.symlinks/ **/ios/**/profile **/ios/**/xcuserdata **/ios/.generated/ **/ios/Flutter/App.framework **/ios/Flutter/Flutter.framework **/ios/Flutter/Generated.xcconfig **/ios/Flutter/app.flx **/ios/Flutter/app.zip **/ios/Flutter/flutter_assets/ **/ios/ServiceDefinitions.json **/ios/Runner/GeneratedPluginRegistrant.* # Exceptions to above rules. !**/ios/**/default.mode1v3 !**/ios/**/default.mode2v3 !**/ios/**/default.pbxuser !**/ios/**/default.perspectivev3 !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages ================================================ FILE: text_demo/fonts/Roboto/LICENSE.txt ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: text_demo/go/.gitignore ================================================ build .last_goflutter_check .last_go-flutter_check ================================================ FILE: text_demo/go/cmd/main.go ================================================ 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 } ================================================ FILE: text_demo/go/cmd/options.go ================================================ package main import ( "github.com/go-flutter-desktop/go-flutter" ) var options = []flutter.Option{ flutter.WindowInitialDimensions(800, 1280), } ================================================ FILE: text_demo/go/go.mod ================================================ module text_demo/go go 1.19 require ( github.com/go-flutter-desktop/go-flutter v0.52.2 github.com/pkg/errors v0.9.1 ) require ( github.com/Xuanwo/go-locale v1.1.0 // indirect github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 // indirect github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f // indirect golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b // indirect golang.org/x/text v0.3.7 // indirect ) // replace github.com/go-flutter-desktop/go-flutter => /home/drakirus/lab/flutter/go-flutter ================================================ FILE: text_demo/go/go.sum ================================================ github.com/Xuanwo/go-locale v1.1.0 h1:51gUxhxl66oXAjI9uPGb2O0qwPECpriKQb2hl35mQkg= github.com/Xuanwo/go-locale v1.1.0/go.mod h1:UKrHoZB3FPIk9wIG2/tVSobnHgNnceGSH3Y8DY5cASs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-flutter-desktop/go-flutter v0.52.2 h1:08LdijXBSiqUcSzofrytBPpItF+zBgJ7s0sDixFhbAU= github.com/go-flutter-desktop/go-flutter v0.52.2/go.mod h1:8lIXoHEAZl01qK7pKwUwf/dzF2mD0JRoaxkGoYu32k8= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 h1:zDw5v7qm4yH7N8C8uWd+8Ii9rROdgWxQuGoJ9WDXxfk= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f h1:w3h343WgVLKLITcSpwecCDcq0FO8pAv6A/UG86hhFtY= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.7 h1:I6tZjLXD2Q1kjvNbIzB1wvQBsXmKXiVrhpRE8ZjP5jY= github.com/smartystreets/goconvey v1.6.7/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b h1:2n253B2r0pYSmEV+UNCQoPfU/FiaizQEK5Gu4Bq4JE8= golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= ================================================ FILE: text_demo/go/hover.yaml ================================================ #application-name: "text_demo" # Uncomment to modify this value. #executable-name: "text_demo" # Uncomment to modify this value. Only lowercase a-z, numbers, underscores and no spaces #package-name: "textdemo" # Uncomment to modify this value. Only lowercase a-z, numbers and no underscores or spaces license: "" # MANDATORY: Fill in your SPDX license name: https://spdx.org/licenses target: lib/main_desktop.dart # opengl: "none" # Uncomment this line if you have trouble with your OpenGL driver (https://github.com/go-flutter-desktop/go-flutter/issues/272) docker: false engine-version: "" # change to a engine version commit ================================================ FILE: text_demo/lib/app.dart ================================================ // This example demos the TextField/SelectableText widget and keyboard // integration with the go-flutter text backend import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Code Sample for testing text input', theme: ThemeData( // If the host is missing some fonts, it can cause the // text to not be rendered or worse the app might crash. fontFamily: 'Roboto', primarySwatch: Colors.blue, ), home: MyStatefulWidget(), ); } } class MyStatefulWidget extends StatefulWidget { MyStatefulWidget({Key key}) : super(key: key); @override _MyStatefulWidgetState createState() => _MyStatefulWidgetState(); } class _MyStatefulWidgetState extends State { FocusNode myFocus = FocusNode(); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Hover Example'), ), body: Container( child: Column( children: [ Padding( padding: EdgeInsets.all(16.0), child: SelectableText.rich( // this text can be copied with "Ctrl-C" TextSpan( text: 'Hello', // default text style children: [ TextSpan( text: ' beautiful world', style: TextStyle(fontWeight: FontWeight.bold)), TextSpan( text: ' (should be copyable)', style: TextStyle( fontStyle: FontStyle.italic, fontSize: 10)), ], ), ), ), Padding( padding: new EdgeInsets.all(8.0), child: new Column(children: [ TextField( obscureText: false, decoration: InputDecoration( border: OutlineInputBorder(), labelText: 'TextField', ), onSubmitted: (value) { print("TextField 1:" + value); }, onEditingComplete: () => FocusScope.of(context).requestFocus(myFocus), ), TextField( decoration: InputDecoration(hintText: 'Multiline TextField'), maxLines: 4, focusNode: myFocus, onSubmitted: (value) { setState(() { print("TextField 2:" + value); }); }, ), ]), ), ], ), ), ); } } ================================================ FILE: text_demo/lib/main.dart ================================================ import 'package:flutter/material.dart'; import 'package:text_demo/app.dart'; void main() { runApp(MyApp()); } ================================================ FILE: text_demo/lib/main_desktop.dart ================================================ import 'package:flutter/foundation.dart' show debugDefaultTargetPlatformOverride; import 'package:flutter/material.dart'; import 'package:text_demo/app.dart'; void main() { debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; runApp(MyApp()); } ================================================ FILE: text_demo/pubspec.yaml ================================================ name: text_demo description: A new Flutter project. # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 # followed by an optional build number separated by a +. # Both the version and the builder number may be overridden in flutter # build by specifying --build-name and --build-number, respectively. # In Android, build-name is used as versionName while build-number used as versionCode. # Read more about Android versioning at https://developer.android.com/studio/publish/versioning # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html version: 1.0.0+1 environment: sdk: ">=2.1.0 <3.0.0" dependencies: flutter: sdk: flutter # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: dev_dependencies: flutter_test: sdk: flutter # For information on the generic Dart part of this file, see the # following page: https://www.dartlang.org/tools/pub/pubspec # The following section is specific to Flutter. flutter: # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. uses-material-design: true fonts: - family: Roboto fonts: - asset: fonts/Roboto/Roboto-Thin.ttf weight: 100 - asset: fonts/Roboto/Roboto-Light.ttf weight: 300 - asset: fonts/Roboto/Roboto-Regular.ttf weight: 400 - asset: fonts/Roboto/Roboto-Medium.ttf weight: 500 - asset: fonts/Roboto/Roboto-Bold.ttf weight: 700 - asset: fonts/Roboto/Roboto-Black.ttf weight: 900 ================================================ FILE: texture_tutorial/.gitignore ================================================ # Miscellaneous *.class *.log *.pyc *.swp .DS_Store .atom/ .buildlog/ .history .svn/ # IntelliJ related *.iml *.ipr *.iws .idea/ # Visual Studio Code related .vscode/ # Flutter/Dart/Pub related **/doc/api/ .dart_tool/ .flutter-plugins .packages .pub-cache/ .pub/ /build/ # Android related **/android/**/gradle-wrapper.jar **/android/.gradle **/android/captures/ **/android/gradlew **/android/gradlew.bat **/android/local.properties **/android/**/GeneratedPluginRegistrant.java # iOS/XCode related **/ios/**/*.mode1v3 **/ios/**/*.mode2v3 **/ios/**/*.moved-aside **/ios/**/*.pbxuser **/ios/**/*.perspectivev3 **/ios/**/*sync/ **/ios/**/.sconsign.dblite **/ios/**/.tags* **/ios/**/.vagrant/ **/ios/**/DerivedData/ **/ios/**/Icon? **/ios/**/Pods/ **/ios/**/.symlinks/ **/ios/**/profile **/ios/**/xcuserdata **/ios/.generated/ **/ios/Flutter/App.framework **/ios/Flutter/Flutter.framework **/ios/Flutter/Generated.xcconfig **/ios/Flutter/app.flx **/ios/Flutter/app.zip **/ios/Flutter/flutter_assets/ **/ios/ServiceDefinitions.json **/ios/Runner/GeneratedPluginRegistrant.* # Exceptions to above rules. !**/ios/**/default.mode1v3 !**/ios/**/default.mode2v3 !**/ios/**/default.pbxuser !**/ios/**/default.perspectivev3 !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages ================================================ FILE: texture_tutorial/README.md ================================================ # texture_tutorial The plugins source code is stored in the same example: [./go-texture-example](./go-texture-example). Multiples path are hard coded, run the app in the root of the flutter project! (`hover run`) ## Demo

Demo of the
  example

If you get errors with this example, please report an issue! ================================================ FILE: texture_tutorial/go/.gitignore ================================================ build .last_goflutter_check .last_go-flutter_check ================================================ FILE: texture_tutorial/go/cmd/main.go ================================================ 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 } ================================================ FILE: texture_tutorial/go/cmd/options.go ================================================ package main import ( "github.com/go-flutter-desktop/go-flutter" "github.com/go-flutter-desktop/plugins/go-texture-example/example_gif" "github.com/go-flutter-desktop/plugins/go-texture-example/example_image" ) var options = []flutter.Option{ flutter.WindowInitialDimensions(1260, 580), flutter.AddPlugin(&example_image.ImagePlugin{}), flutter.AddPlugin(&example_gif.GifPlugin{}), } ================================================ FILE: texture_tutorial/go/go.mod ================================================ module texture_tutorial/go go 1.19 require ( github.com/go-flutter-desktop/go-flutter v0.52.2 github.com/go-flutter-desktop/plugins/go-texture-example/example_gif 01528a4714a5 github.com/go-flutter-desktop/plugins/go-texture-example/example_image 01528a4714a5 github.com/pkg/errors v0.9.1 ) require ( github.com/Xuanwo/go-locale v1.1.0 // indirect github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 // indirect github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f // indirect golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b // indirect golang.org/x/text v0.3.7 // indirect ) replace github.com/go-flutter-desktop/plugins/go-texture-example/example_image => ../go-texture-example/image replace github.com/go-flutter-desktop/plugins/go-texture-example/example_gif => ../go-texture-example/gif ================================================ FILE: texture_tutorial/go/go.sum ================================================ github.com/Xuanwo/go-locale v1.1.0 h1:51gUxhxl66oXAjI9uPGb2O0qwPECpriKQb2hl35mQkg= github.com/Xuanwo/go-locale v1.1.0/go.mod h1:UKrHoZB3FPIk9wIG2/tVSobnHgNnceGSH3Y8DY5cASs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-flutter-desktop/go-flutter v0.52.2 h1:08LdijXBSiqUcSzofrytBPpItF+zBgJ7s0sDixFhbAU= github.com/go-flutter-desktop/go-flutter v0.52.2/go.mod h1:8lIXoHEAZl01qK7pKwUwf/dzF2mD0JRoaxkGoYu32k8= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 h1:zDw5v7qm4yH7N8C8uWd+8Ii9rROdgWxQuGoJ9WDXxfk= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f h1:w3h343WgVLKLITcSpwecCDcq0FO8pAv6A/UG86hhFtY= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.7 h1:I6tZjLXD2Q1kjvNbIzB1wvQBsXmKXiVrhpRE8ZjP5jY= github.com/smartystreets/goconvey v1.6.7/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b h1:2n253B2r0pYSmEV+UNCQoPfU/FiaizQEK5Gu4Bq4JE8= golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= ================================================ FILE: texture_tutorial/go/hover.yaml ================================================ #application-name: "texture_tutorial" # Uncomment to modify this value. #executable-name: "texture_tutorial" # Uncomment to modify this value. Only lowercase a-z, numbers, underscores and no spaces #package-name: "texturetutorial" # Uncomment to modify this value. Only lowercase a-z, numbers and no underscores or spaces license: "" # MANDATORY: Fill in your SPDX license name: https://spdx.org/licenses target: lib/main_desktop.dart # opengl: "none" # Uncomment this line if you have trouble with your OpenGL driver (https://github.com/go-flutter-desktop/go-flutter/issues/272) docker: false engine-version: "" # change to a engine version commit ================================================ FILE: texture_tutorial/go-texture-example/gif/go.mod ================================================ module github.com/go-flutter-desktop/plugins/go-texture-example/example_gif go 1.19 require github.com/go-flutter-desktop/go-flutter v0.52.2 require ( github.com/Xuanwo/go-locale v1.1.0 // indirect github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 // indirect github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f // indirect github.com/pkg/errors v0.9.1 // indirect golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70 // indirect golang.org/x/text v0.3.7 // indirect ) ================================================ FILE: texture_tutorial/go-texture-example/gif/go.sum ================================================ github.com/Xuanwo/go-locale v1.1.0 h1:51gUxhxl66oXAjI9uPGb2O0qwPECpriKQb2hl35mQkg= github.com/Xuanwo/go-locale v1.1.0/go.mod h1:UKrHoZB3FPIk9wIG2/tVSobnHgNnceGSH3Y8DY5cASs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-flutter-desktop/go-flutter v0.52.2 h1:08LdijXBSiqUcSzofrytBPpItF+zBgJ7s0sDixFhbAU= github.com/go-flutter-desktop/go-flutter v0.52.2/go.mod h1:8lIXoHEAZl01qK7pKwUwf/dzF2mD0JRoaxkGoYu32k8= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 h1:zDw5v7qm4yH7N8C8uWd+8Ii9rROdgWxQuGoJ9WDXxfk= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f h1:w3h343WgVLKLITcSpwecCDcq0FO8pAv6A/UG86hhFtY= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.7 h1:I6tZjLXD2Q1kjvNbIzB1wvQBsXmKXiVrhpRE8ZjP5jY= github.com/smartystreets/goconvey v1.6.7/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70 h1:SeSEfdIxyvwGJliREIJhRPPXvW6sDlLT+UQ3B0hD0NA= golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= ================================================ FILE: texture_tutorial/go-texture-example/gif/main.go ================================================ package example_gif import ( "errors" "fmt" "image" "image/draw" "image/gif" "os" "time" flutter "github.com/go-flutter-desktop/go-flutter" "github.com/go-flutter-desktop/go-flutter/plugin" ) // GifPlugin is a texture plugin example type GifPlugin struct { gif *gif.GIF rgba *image.RGBA // in-memory buffer for the next image to be displayed } var _ flutter.PluginTexture = &GifPlugin{} // compile-time type check // InitPlugin is used because PluginTexture must implement flutter.Plugin. // InitPlugin delays the first frame, it's better to have images decoded // on demand in a HandleFunc (non-bloking). func (p *GifPlugin) InitPlugin(messenger plugin.BinaryMessenger) error { // hard-coded path, run the app with `hover run` in the project root file := "./SampleVideo.gif" gifFile, err := os.Open(file) if err != nil { fmt.Printf("gif %q not found on disk: %v\n", file, err) return err } p.gif, err = gif.DecodeAll(gifFile) if err != nil { fmt.Printf("error decoding file %s:%v\n", file, err) return err } gifWidth, gifHeight := getGifDimensions(p.gif) p.rgba = image.NewRGBA(image.Rect(0, 0, gifWidth, gifHeight)) if p.rgba.Stride != p.rgba.Rect.Size().X*4 { return errors.New("unsupported stride\n") } draw.Draw(p.rgba, p.rgba.Bounds(), p.gif.Image[0], image.ZP, draw.Over) return nil } // InitPluginTexture is used to create and manage backend textures func (p *GifPlugin) InitPluginTexture(registry *flutter.TextureRegistry) error { texture := registry.NewTexture() // for this exmaple I have hard-coded a `textureId: 2` in the flutter // Texture widget. texture.ID = 2 // You should never change this ID, `registry.NewTexture()` will keep track // of the textureId counter for you. // You should send the texture.ID number to dart using some sort of platform // channel, and use the go generated textureId in flutter. go func() { for { // looping gif for i, srcImg := range p.gif.Image { time.Sleep(time.Millisecond * 10 * time.Duration(p.gif.Delay[i])) draw.Draw(p.rgba, p.rgba.Bounds(), srcImg, image.ZP, draw.Over) // get the frame's pixels texture.FrameAvailable() // redraw (calls textureHanler, and retrive the pixel) } } // In this fairly simple example no golang mutex/channel were used to sync draw.Draw and textureHanler. }() return texture.Register(p.textureHanler) } // textureHanler is executed on the main thread, try to make this handle as // light as possible. // In this case the handler is only sending the pixel buffer drawn in a // goroutine. func (p *GifPlugin) textureHanler(width, height int) (bool, *flutter.PixelBuffer) { return true, &flutter.PixelBuffer{ Pix: p.rgba.Pix, Width: p.rgba.Bounds().Size().X, Height: p.rgba.Bounds().Size().Y, } } func getGifDimensions(gif *gif.GIF) (x, y int) { var lowestX int var lowestY int var highestX int var highestY int for _, gif := range gif.Image { if gif.Rect.Min.X < lowestX { lowestX = gif.Rect.Min.X } if gif.Rect.Min.Y < lowestY { lowestY = gif.Rect.Min.Y } if gif.Rect.Max.X > highestX { highestX = gif.Rect.Max.X } if gif.Rect.Max.Y > highestY { highestY = gif.Rect.Max.Y } } return highestX - lowestX, highestY - lowestY } ================================================ FILE: texture_tutorial/go-texture-example/image/go.mod ================================================ module github.com/go-flutter-desktop/plugins/go-texture-example/example_image go 1.19 require github.com/go-flutter-desktop/go-flutter v0.52.2 require ( github.com/Xuanwo/go-locale v1.1.0 // indirect github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 // indirect github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f // indirect github.com/pkg/errors v0.9.1 // indirect golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70 // indirect golang.org/x/text v0.3.7 // indirect ) ================================================ FILE: texture_tutorial/go-texture-example/image/go.sum ================================================ github.com/Xuanwo/go-locale v1.1.0 h1:51gUxhxl66oXAjI9uPGb2O0qwPECpriKQb2hl35mQkg= github.com/Xuanwo/go-locale v1.1.0/go.mod h1:UKrHoZB3FPIk9wIG2/tVSobnHgNnceGSH3Y8DY5cASs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-flutter-desktop/go-flutter v0.52.2 h1:08LdijXBSiqUcSzofrytBPpItF+zBgJ7s0sDixFhbAU= github.com/go-flutter-desktop/go-flutter v0.52.2/go.mod h1:8lIXoHEAZl01qK7pKwUwf/dzF2mD0JRoaxkGoYu32k8= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 h1:zDw5v7qm4yH7N8C8uWd+8Ii9rROdgWxQuGoJ9WDXxfk= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f h1:w3h343WgVLKLITcSpwecCDcq0FO8pAv6A/UG86hhFtY= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.7 h1:I6tZjLXD2Q1kjvNbIzB1wvQBsXmKXiVrhpRE8ZjP5jY= github.com/smartystreets/goconvey v1.6.7/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70 h1:SeSEfdIxyvwGJliREIJhRPPXvW6sDlLT+UQ3B0hD0NA= golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= ================================================ FILE: texture_tutorial/go-texture-example/image/main.go ================================================ package example_image import ( "fmt" "image" "image/draw" "os" "time" flutter "github.com/go-flutter-desktop/go-flutter" "github.com/go-flutter-desktop/go-flutter/plugin" ) // ImagePlugin is a texture plugin example type ImagePlugin struct{} var _ flutter.PluginTexture = &ImagePlugin{} // compile-time type check // InitPlugin is used because PluginTexture must implement flutter.Plugin func (p *ImagePlugin) InitPlugin(messenger plugin.BinaryMessenger) error { return nil } // InitPluginTexture is used to create and manage backend textures func (p *ImagePlugin) InitPluginTexture(registry *flutter.TextureRegistry) error { texture := registry.NewTexture() // for this exmaple I have hard-coded a `textureId: 1` in the flutter // Texture widget. texture.ID = 1 // You should never change this ID, `registry.NewTexture()` will keep track // of the textureId counter for you. // You should send the texture.ID number to dart using some sort of platform // channel, and use the go generated textureId in flutter. // after 5 seconds, remove the texture from the scene. go func() { time.Sleep(5 * time.Second) fmt.Printf("texture_tutorial: UnRegistering texture %v after 5 seconds\n", texture.ID) err := texture.UnRegister() if err != nil { fmt.Printf("texture_tutorial: %v\n", err) } texture.FrameAvailable() // redraw }() return texture.Register(p.textureHanler) } func (p *ImagePlugin) textureHanler(width, height int) (bool, *flutter.PixelBuffer) { // hard-coded path, run the app with `hover run` in the project root file := "./test.png" imgFile, err := os.Open(file) if err != nil { fmt.Printf("image %q not found on disk: %v\n", file, err) return false, nil } img, _, err := image.Decode(imgFile) if err != nil { fmt.Printf("error decoding file %s:%v\n", file, err) return false, nil } rgba := image.NewRGBA(img.Bounds()) if rgba.Stride != rgba.Rect.Size().X*4 { fmt.Printf("unsupported stride\n") return false, nil } draw.Draw(rgba, rgba.Bounds(), img, image.Point{0, 0}, draw.Src) return true, &flutter.PixelBuffer{ Pix: rgba.Pix, Width: rgba.Bounds().Size().X, Height: rgba.Bounds().Size().Y, } } ================================================ FILE: texture_tutorial/lib/main_desktop.dart ================================================ import 'package:flutter/foundation.dart' show debugDefaultTargetPlatformOverride; import 'package:flutter/material.dart'; void main() { debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; runApp(MyApp()); } class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'go-flutter Texture API', theme: ThemeData( // If the host is missing some fonts, it can cause the // text to not be rendered or worse the app might crash. fontFamily: 'Roboto', primarySwatch: Colors.blue, ), home: Scaffold( appBar: AppBar( title: Text('Texture Examples'), ), body: Center( child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Column( children: [ Spacer(flex: 2), Text('Gif Player (2sec gif)'), Spacer(flex: 2), ConstrainedBox( constraints: BoxConstraints.tight(Size(640, 360)), // hard-coded to 2, gif. // (Not the best practise, let go-flutter generate this ID // and send it back to the dart code using platform // messages) child: Texture(textureId: 2), ), Spacer(flex: 3), ], ), Column( children: [ Spacer(flex: 2), Text('Image Texture (Cleared after 5s)'), Spacer(flex: 2), ConstrainedBox( constraints: BoxConstraints.tight(Size(330, 319)), child: Texture(textureId: 1), // hard-coded to 1, image ), Spacer(flex: 3), ], ), ], ), ), ), ); } } ================================================ FILE: texture_tutorial/pubspec.yaml ================================================ name: texture_tutorial description: A new Flutter project. # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 # followed by an optional build number separated by a +. # Both the version and the builder number may be overridden in flutter # build by specifying --build-name and --build-number, respectively. # In Android, build-name is used as versionName while build-number used as versionCode. # Read more about Android versioning at https://developer.android.com/studio/publish/versioning # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html version: 1.0.0+1 environment: sdk: ">=2.1.0 <3.0.0" dependencies: flutter: sdk: flutter # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: dev_dependencies: flutter_test: sdk: flutter # For information on the generic Dart part of this file, see the # following page: https://www.dartlang.org/tools/pub/pubspec # The following section is specific to Flutter. flutter: # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. uses-material-design: true ================================================ FILE: xbox_controller/.gitignore ================================================ # Miscellaneous *.class *.log *.pyc *.swp .DS_Store .atom/ .buildlog/ .history .svn/ # IntelliJ related *.iml *.ipr *.iws .idea/ # Visual Studio Code related .vscode/ # Flutter/Dart/Pub related **/doc/api/ .dart_tool/ .flutter-plugins .packages .pub-cache/ .pub/ /build/ # Android related **/android/**/gradle-wrapper.jar **/android/.gradle **/android/captures/ **/android/gradlew **/android/gradlew.bat **/android/local.properties **/android/**/GeneratedPluginRegistrant.java # iOS/XCode related **/ios/**/*.mode1v3 **/ios/**/*.mode2v3 **/ios/**/*.moved-aside **/ios/**/*.pbxuser **/ios/**/*.perspectivev3 **/ios/**/*sync/ **/ios/**/.sconsign.dblite **/ios/**/.tags* **/ios/**/.vagrant/ **/ios/**/DerivedData/ **/ios/**/Icon? **/ios/**/Pods/ **/ios/**/.symlinks/ **/ios/**/profile **/ios/**/xcuserdata **/ios/.generated/ **/ios/Flutter/App.framework **/ios/Flutter/Flutter.framework **/ios/Flutter/Generated.xcconfig **/ios/Flutter/app.flx **/ios/Flutter/app.zip **/ios/Flutter/flutter_assets/ **/ios/ServiceDefinitions.json **/ios/Runner/GeneratedPluginRegistrant.* # Exceptions to above rules. !**/ios/**/default.mode1v3 !**/ios/**/default.mode2v3 !**/ios/**/default.pbxuser !**/ios/**/default.perspectivev3 !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages ================================================ FILE: xbox_controller/README.md ================================================ # xbox_controller A project demonstrating: - The [EventChannel](https://godoc.org/github.com/go-flutter-desktop/go-flutter/plugin#EventChannel) specialized platform channel. The demo uses the game engine [flame](https://github.com/flame-engine/flame). ## Demo

Demo of the
  example

================================================ FILE: xbox_controller/fonts/Roboto/LICENSE.txt ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: xbox_controller/go/.gitignore ================================================ build .last_goflutter_check .last_go-flutter_check ================================================ FILE: xbox_controller/go/cmd/import-path_provider-plugin.go ================================================ package main // DO NOT EDIT, this file is generated by hover at compile-time for the path_provider plugin. import ( flutter "github.com/go-flutter-desktop/go-flutter" path_provider "github.com/go-flutter-desktop/plugins/path_provider" ) func init() { // Only the init function can be tweaked by plugin maker. options = append(options, flutter.AddPlugin(&path_provider.PathProviderPlugin{ VendorName: flutter.ProjectOrganizationName, ApplicationName: flutter.ProjectName, })) } ================================================ FILE: xbox_controller/go/cmd/main.go ================================================ 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 } ================================================ FILE: xbox_controller/go/cmd/options.go ================================================ package main import ( "github.com/go-flutter-desktop/go-flutter" controller "github.com/go-flutter-desktop/plugins/xbox" ) var options = []flutter.Option{ flutter.WindowInitialDimensions(1600, 1100), flutter.WindowDimensionLimits(1600, 1100, 1600, 1100), flutter.AddPlugin(&controller.XBOXStream{}), } ================================================ FILE: xbox_controller/go/go.mod ================================================ module xbox_controller/go go 1.19 require ( github.com/go-flutter-desktop/go-flutter v0.52.2 github.com/go-flutter-desktop/plugins/path_provider v0.5.0 github.com/go-flutter-desktop/plugins/xbox 01528a4714a5 github.com/pkg/errors v0.9.1 ) require ( github.com/Xuanwo/go-locale v1.1.0 // indirect github.com/adrg/xdg v0.4.0 // indirect github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 // indirect github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f // indirect golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b // indirect golang.org/x/text v0.3.7 // indirect ) replace github.com/go-flutter-desktop/plugins/xbox => ../go-plugin-example/controller ================================================ FILE: xbox_controller/go/go.sum ================================================ github.com/Xuanwo/go-locale v1.1.0 h1:51gUxhxl66oXAjI9uPGb2O0qwPECpriKQb2hl35mQkg= github.com/Xuanwo/go-locale v1.1.0/go.mod h1:UKrHoZB3FPIk9wIG2/tVSobnHgNnceGSH3Y8DY5cASs= github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls= github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-flutter-desktop/go-flutter v0.52.1/go.mod h1:8lIXoHEAZl01qK7pKwUwf/dzF2mD0JRoaxkGoYu32k8= github.com/go-flutter-desktop/go-flutter v0.52.2 h1:08LdijXBSiqUcSzofrytBPpItF+zBgJ7s0sDixFhbAU= github.com/go-flutter-desktop/go-flutter v0.52.2/go.mod h1:8lIXoHEAZl01qK7pKwUwf/dzF2mD0JRoaxkGoYu32k8= github.com/go-flutter-desktop/plugins/path_provider v0.5.0 h1:5Rcq05GUsi8HssKQ6S7wPzLzRg455UymCPRMve0uz7s= github.com/go-flutter-desktop/plugins/path_provider v0.5.0/go.mod h1:x1kDFgkxLKR0Xp51zJPX3G8+B0y87EBaZB3/WzKIilo= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 h1:zDw5v7qm4yH7N8C8uWd+8Ii9rROdgWxQuGoJ9WDXxfk= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f h1:w3h343WgVLKLITcSpwecCDcq0FO8pAv6A/UG86hhFtY= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.7 h1:I6tZjLXD2Q1kjvNbIzB1wvQBsXmKXiVrhpRE8ZjP5jY= github.com/smartystreets/goconvey v1.6.7/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b h1:2n253B2r0pYSmEV+UNCQoPfU/FiaizQEK5Gu4Bq4JE8= golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= ================================================ FILE: xbox_controller/go/hover.yaml ================================================ #application-name: "xbox_controller" # Uncomment to modify this value. #executable-name: "xbox_controller" # Uncomment to modify this value. Only lowercase a-z, numbers, underscores and no spaces #package-name: "xboxcontroller" # Uncomment to modify this value. Only lowercase a-z, numbers and no underscores or spaces license: "" # MANDATORY: Fill in your SPDX license name: https://spdx.org/licenses target: lib/main_desktop.dart # opengl: "none" # Uncomment this line if you have trouble with your OpenGL driver (https://github.com/go-flutter-desktop/go-flutter/issues/272) docker: false engine-version: "" # change to a engine version commit ================================================ FILE: xbox_controller/go-plugin-example/controller/go.mod ================================================ module github.com/go-flutter-desktop/plugins/xbox go 1.19 require ( github.com/go-flutter-desktop/go-flutter v0.52.2 github.com/go-gl/glfw/v3.3/glfw v0.0.0-20260406072232-3ac4aa2bb164 ) require ( github.com/Xuanwo/go-locale v1.1.0 // indirect github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 // indirect github.com/pkg/errors v0.9.1 // indirect golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70 // indirect golang.org/x/text v0.3.7 // indirect ) ================================================ FILE: xbox_controller/go-plugin-example/controller/go.sum ================================================ github.com/Xuanwo/go-locale v1.1.0 h1:51gUxhxl66oXAjI9uPGb2O0qwPECpriKQb2hl35mQkg= github.com/Xuanwo/go-locale v1.1.0/go.mod h1:UKrHoZB3FPIk9wIG2/tVSobnHgNnceGSH3Y8DY5cASs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-flutter-desktop/go-flutter v0.52.2 h1:08LdijXBSiqUcSzofrytBPpItF+zBgJ7s0sDixFhbAU= github.com/go-flutter-desktop/go-flutter v0.52.2/go.mod h1:8lIXoHEAZl01qK7pKwUwf/dzF2mD0JRoaxkGoYu32k8= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 h1:zDw5v7qm4yH7N8C8uWd+8Ii9rROdgWxQuGoJ9WDXxfk= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220712193148-63cf1f4ef61f/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20260406072232-3ac4aa2bb164 h1:ddtotcEXIT7dFhSeXIWjK8YMFYl5bB2NdYQwgv6Uqjk= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20260406072232-3ac4aa2bb164/go.mod h1:SyRD8YfuKk+ZXlDqYiqe1qMSqjNgtHzBTG810KUagMc= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.7 h1:I6tZjLXD2Q1kjvNbIzB1wvQBsXmKXiVrhpRE8ZjP5jY= github.com/smartystreets/goconvey v1.6.7/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70 h1:SeSEfdIxyvwGJliREIJhRPPXvW6sDlLT+UQ3B0hD0NA= golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= ================================================ FILE: xbox_controller/go-plugin-example/controller/main.go ================================================ package controller import ( "reflect" "time" flutter "github.com/go-flutter-desktop/go-flutter" "github.com/go-flutter-desktop/go-flutter/plugin" "github.com/go-gl/glfw/v3.3/glfw" ) // XBOXStream demonstrates how to use the EventChannel. type XBOXStream struct { stop chan bool } var _ flutter.Plugin = &XBOXStream{} // compile-time type check func (p *XBOXStream) InitPlugin(messenger plugin.BinaryMessenger) error { p.stop = make(chan bool) channel := plugin.NewEventChannel(messenger, "go-flutter-sample/xbox_controller", plugin.StandardMethodCodec{}) channel.Handle(p) return nil } func (p *XBOXStream) OnListen(arguments interface{}, sink *plugin.EventSink) { joy := glfw.Joystick1 var lastJoystickInfo map[interface{}]interface{} for { select { case <-p.stop: return default: var present bool if joy.Present() { present = true glfwButtons := joy.GetButtons() buttons := make([]interface{}, len(glfwButtons)) for i, v := range glfwButtons { buttons[i] = v == 1 } glfwAxes := joy.GetAxes() axes := make([]interface{}, len(glfwAxes)) for i, v := range glfwAxes { axes[i] = float64(v) } joystickInfo := map[interface{}]interface{}{ "name": joy.GetName(), "buttons": buttons, "axes": axes, } // don't send duplicated succeding message, (reduces serialisation). if !reflect.DeepEqual(lastJoystickInfo, joystickInfo) { sink.Success(joystickInfo) lastJoystickInfo = joystickInfo } } if !present { // no joysticks present // EndOfStream will call OnCancel, which will send true in the channel // p.stop, which will stop the OnListen goroutine. sink.EndOfStream() } time.Sleep(5 * time.Millisecond) // Constantly polling joysticks event // no wait for joysticks events available } } } func (p *XBOXStream) OnCancel(arguments interface{}) { // I choose to use channels to Cancel events. // Mutex can also work. // I found that channels are bit more reliable than Mutex during hot restart. p.stop <- true } ================================================ FILE: xbox_controller/lib/game.dart ================================================ import 'package:flame/game.dart'; import 'package:flame_svg/flame_svg.dart'; import 'package:flame/position.dart'; import 'package:flame/text_config.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'dart:async'; const XBOXEventStream = const EventChannel('go-flutter-sample/xbox_controller'); class MyGame extends BaseGame { Svg svgInstance; TextConfig config = TextConfig( fontSize: 20.0, fontFamily: 'Roboto', color: Colors.pinkAccent); Controller controller = Controller.messageAsName( "No game controller connected (Click to connect)"); StreamSubscription _xboxInputSubs; Size screenSize; MyGame(this.screenSize) { _start(); searchController(); } void searchController() { if (_xboxInputSubs != null) { return; } this.controller = Controller.messageAsName("Searching controller..."); _xboxInputSubs = XBOXEventStream.receiveBroadcastStream().listen(_updateGameController); _xboxInputSubs.onDone(() async { await Future.delayed(Duration(seconds: 1)); this.controller = Controller.messageAsName( "No game controller connected (Click to connect)"); _xboxInputSubs = null; }); } void _updateGameController(ctrl) { // print(ctrl); this.controller = Controller( name: ctrl["name"], stickAxes: ctrl["axes"].cast(), buttons: ctrl["buttons"].cast()); } void _start() { svgInstance = Svg('xbox-controller.svg'); } @override void render(Canvas canvas) { super.render(canvas); final Rect rect = Rect.fromLTWH(0, 0, screenSize.width, screenSize.height); canvas.drawRect(rect, Paint()..color = Colors.white); canvas.drawRect(rect, Paint()..color = Colors.black12); config.render(canvas, this.controller.name, Position(10, 10)); svgInstance.renderPosition(canvas, Position(100, 0), 600, 500); canvas.drawCircle( Offset(269 + this.controller.offsetRightStick().x, 174 + this.controller.offsetRightStick().y), 7, Paint()..color = Colors.white70); canvas.drawCircle( Offset(466 + this.controller.offsetLeftStick().x, 260 + this.controller.offsetLeftStick().y), 7, Paint()..color = Colors.white70); canvas.drawRect(Rect.fromLTWH(259, 91, 19, this.controller.lt() * 10), Paint()..color = Colors.black54); canvas.drawRect(Rect.fromLTWH(523, 91, 19, this.controller.rt() * 10), Paint()..color = Colors.black54); for (var btn in this.controller.pressedButtons()) { canvas.drawCircle(Offset(btn.coordinates.x, btn.coordinates.y), 18, Paint()..color = btn.color); } } } class Coordinates { double x, y; Coordinates({this.x, this.y}); } class Button { String name; Coordinates coordinates; Color color; Button(this.name, this.coordinates, this.color); } class Controller { String name; List stickAxes = [0, 0, 0, 0, 0, 0, 0, 0]; List buttons = [ false, false, false, false, false, false, false, false, false, false ]; Controller({this.name, this.stickAxes, this.buttons}); // Named constructor Controller.messageAsName(this.name); Coordinates offsetRightStick() { return Coordinates(x: (this.stickAxes[0] * 27), y: (stickAxes[1] * 27)); } Coordinates offsetLeftStick() { return Coordinates(x: (this.stickAxes[3] * 27), y: (stickAxes[4] * 27)); } double rt() { return (this.stickAxes[5] + 1) * -2; } double lt() { return (this.stickAxes[2] + 1) * -2; } List