├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.yaml
│ └── config.yml
├── PULL_REQUEST_TEMPLATE.md
└── workflows
│ ├── .cspell
│ ├── companies.txt
│ ├── cryptocurrencies.txt
│ ├── cryptography.txt
│ ├── en_US.txt
│ ├── flutter_dart.txt
│ ├── forbidden.txt
│ ├── hyph_en_US.txt
│ ├── networking_terms.txt
│ ├── project.txt
│ └── software_terms.txt
│ ├── cspell.json
│ ├── on_pull_request.yml
│ ├── spell_checker.yml
│ ├── stale-branches.yml
│ └── title_validation.yml
├── .gitignore
├── .metadata
├── .vscode
└── launch.json
├── CHANGELOG.md
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── SECURITY.md
├── analysis_options.yaml
├── assets
└── popover.pxd
│ ├── QuickLook
│ ├── Icon.tiff
│ └── Thumbnail.tiff
│ ├── data
│ ├── 5BC896EC-BCEF-43D1-9861-ACA4C0F5BBE9
│ ├── 5EB1D7DE-C477-4BD5-AADF-38260B1F132A
│ ├── 8F00D828-9D5B-4252-A7EC-9EEA5B24E1B6
│ ├── A3688D72-C0E0-4D6B-A9E7-B99A42546338
│ └── CD0ED540-5ECB-4CFB-9B86-237858F87D33
│ └── metadata.info
├── example
├── .gitignore
├── .metadata
├── .vscode
│ └── launch.json
├── README.md
├── android
│ ├── .gitignore
│ ├── app
│ │ ├── build.gradle
│ │ └── src
│ │ │ ├── debug
│ │ │ └── AndroidManifest.xml
│ │ │ ├── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── kotlin
│ │ │ │ └── me
│ │ │ │ │ └── minikin
│ │ │ │ │ └── example
│ │ │ │ │ └── MainActivity.kt
│ │ │ └── res
│ │ │ │ ├── drawable-v21
│ │ │ │ └── launch_background.xml
│ │ │ │ ├── drawable
│ │ │ │ └── launch_background.xml
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── values-night
│ │ │ │ └── styles.xml
│ │ │ │ └── values
│ │ │ │ └── styles.xml
│ │ │ └── profile
│ │ │ └── AndroidManifest.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ └── gradle-wrapper.properties
│ └── settings.gradle
├── ios
│ ├── .gitignore
│ ├── Flutter
│ │ ├── AppFrameworkInfo.plist
│ │ ├── Debug.xcconfig
│ │ └── Release.xcconfig
│ ├── Runner.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcshareddata
│ │ │ │ ├── IDEWorkspaceChecks.plist
│ │ │ │ └── WorkspaceSettings.xcsettings
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── Runner.xcscheme
│ ├── Runner.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ ├── IDEWorkspaceChecks.plist
│ │ │ └── WorkspaceSettings.xcsettings
│ └── Runner
│ │ ├── AppDelegate.swift
│ │ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ ├── Contents.json
│ │ │ ├── Icon-App-1024x1024@1x.png
│ │ │ ├── Icon-App-20x20@1x.png
│ │ │ ├── Icon-App-20x20@2x.png
│ │ │ ├── Icon-App-20x20@3x.png
│ │ │ ├── Icon-App-29x29@1x.png
│ │ │ ├── Icon-App-29x29@2x.png
│ │ │ ├── Icon-App-29x29@3x.png
│ │ │ ├── Icon-App-40x40@1x.png
│ │ │ ├── Icon-App-40x40@2x.png
│ │ │ ├── Icon-App-40x40@3x.png
│ │ │ ├── Icon-App-60x60@2x.png
│ │ │ ├── Icon-App-60x60@3x.png
│ │ │ ├── Icon-App-76x76@1x.png
│ │ │ ├── Icon-App-76x76@2x.png
│ │ │ └── Icon-App-83.5x83.5@2x.png
│ │ └── LaunchImage.imageset
│ │ │ ├── Contents.json
│ │ │ ├── LaunchImage.png
│ │ │ ├── LaunchImage@2x.png
│ │ │ ├── LaunchImage@3x.png
│ │ │ └── README.md
│ │ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ │ ├── Info.plist
│ │ └── Runner-Bridging-Header.h
├── lib
│ └── main.dart
├── linux
│ ├── .gitignore
│ ├── CMakeLists.txt
│ ├── flutter
│ │ ├── CMakeLists.txt
│ │ ├── generated_plugin_registrant.cc
│ │ ├── generated_plugin_registrant.h
│ │ └── generated_plugins.cmake
│ ├── main.cc
│ ├── my_application.cc
│ └── my_application.h
├── macos
│ ├── .gitignore
│ ├── Flutter
│ │ ├── Flutter-Debug.xcconfig
│ │ ├── Flutter-Release.xcconfig
│ │ └── GeneratedPluginRegistrant.swift
│ ├── Runner.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ └── xcshareddata
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── Runner.xcscheme
│ ├── Runner.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ ├── Runner
│ │ ├── AppDelegate.swift
│ │ ├── Assets.xcassets
│ │ │ └── AppIcon.appiconset
│ │ │ │ ├── Contents.json
│ │ │ │ ├── app_icon_1024.png
│ │ │ │ ├── app_icon_128.png
│ │ │ │ ├── app_icon_16.png
│ │ │ │ ├── app_icon_256.png
│ │ │ │ ├── app_icon_32.png
│ │ │ │ ├── app_icon_512.png
│ │ │ │ └── app_icon_64.png
│ │ ├── Base.lproj
│ │ │ └── MainMenu.xib
│ │ ├── Configs
│ │ │ ├── AppInfo.xcconfig
│ │ │ ├── Debug.xcconfig
│ │ │ ├── Release.xcconfig
│ │ │ └── Warnings.xcconfig
│ │ ├── DebugProfile.entitlements
│ │ ├── Info.plist
│ │ ├── MainFlutterWindow.swift
│ │ └── Release.entitlements
│ └── RunnerTests
│ │ └── RunnerTests.swift
├── pubspec.lock
├── pubspec.yaml
├── test
│ └── widget_test.dart
├── web
│ ├── favicon.png
│ ├── icons
│ │ ├── Icon-192.png
│ │ ├── Icon-512.png
│ │ ├── Icon-maskable-192.png
│ │ └── Icon-maskable-512.png
│ ├── index.html
│ └── manifest.json
└── windows
│ ├── .gitignore
│ ├── CMakeLists.txt
│ ├── flutter
│ ├── CMakeLists.txt
│ ├── generated_plugin_registrant.cc
│ ├── generated_plugin_registrant.h
│ └── generated_plugins.cmake
│ └── runner
│ ├── CMakeLists.txt
│ ├── Runner.rc
│ ├── flutter_window.cpp
│ ├── flutter_window.h
│ ├── main.cpp
│ ├── resource.h
│ ├── resources
│ └── app_icon.ico
│ ├── run_loop.cpp
│ ├── run_loop.h
│ ├── runner.exe.manifest
│ ├── utils.cpp
│ ├── utils.h
│ ├── win32_window.cpp
│ └── win32_window.h
├── lib
├── popover.dart
└── src
│ ├── popover.dart
│ ├── popover_context.dart
│ ├── popover_direction.dart
│ ├── popover_item.dart
│ ├── popover_path.dart
│ ├── popover_position_render_object.dart
│ ├── popover_position_widget.dart
│ ├── popover_render_shifted_box.dart
│ ├── popover_route.dart
│ ├── popover_transition.dart
│ └── utils
│ ├── build_context_extension.dart
│ └── popover_utils.dart
├── pubspec.lock
├── pubspec.yaml
└── test
└── popover_test.dart
/.github/ISSUE_TEMPLATE/bug_report.yaml:
--------------------------------------------------------------------------------
1 | name: Bug Report
2 | description: File a bug report
3 | title: "[Bug]: "
4 | labels: ["bug"]
5 | body:
6 | - type: markdown
7 | attributes:
8 | value: |
9 | Thanks for taking the time to fill out this bug report!
10 |
11 | - type: checkboxes
12 | attributes:
13 | label: Is there an existing issue for this?
14 | description: Please search to see if an issue already exists for the bug you encountered.
15 | options:
16 | - label: I have searched the existing issues
17 | required: true
18 |
19 | - type: textarea
20 | attributes:
21 | label: Current Behavior
22 | description: A concise description of what you're experiencing.
23 | validations:
24 | required: false
25 | - type: textarea
26 | attributes:
27 | label: Expected Behavior
28 | description: A concise description of what you expected to happen.
29 | validations:
30 | required: false
31 |
32 | - type: dropdown
33 | id: OS
34 | attributes:
35 | label: What operating system are you seeing the problem on?
36 | multiple: true
37 | options:
38 | - macOS
39 | - Linux
40 | - iOS
41 | - Android
42 | - Windows
43 | - Web
44 | validations:
45 | required: true
46 |
47 | - type: textarea
48 | id: logs
49 | attributes:
50 | label: Relevant log output
51 | description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
52 | render: sh
53 |
54 | - type: textarea
55 | attributes:
56 | label: Anything else?
57 | description: |
58 | Links? References? Anything that will give us more context about the issue you are encountering!
59 |
60 | Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
61 | validations:
62 | required: false
63 |
64 | - type: checkboxes
65 | id: terms
66 | attributes:
67 | label: Code of Conduct
68 | description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/minikin/popover/blob/main/CODE_OF_CONDUCT.md)
69 | options:
70 | - label: I agree to follow this project's Code of Conduct
71 | required: true
72 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | blank_issues_enabled: false
2 | contact_links:
3 | - name: Popover Discussions
4 | url: https://www.linkedin.com/in/minikin
5 | about: Please ask and answer questions here.
6 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | *Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.*
2 |
3 | *List which issues are fixed by this PR. You must list at least one issue.*
4 |
5 | ## Pre-launch Checklist
6 |
7 | - [ ] I read and followed the [Effective Dart](https://dart.dev/guides/language/effective-dart/style).
8 | - [ ] I listed at least one issue or feature that this PR fixes or adds in the description above.
9 | - [ ] I updated/added relevant documentation (doc comments with `///`).
10 | - [ ] I updated/added relevant documentation to README.md.
11 | - [ ] I updated/added relevant code samples to [example](https://github.com/minikin/popover/blob/main/example/lib/main.dart).
12 | - [ ] I added new tests to check the change I am making or feature I am adding, or Minikin said the PR is test-exempt.
13 | - [ ] All existing and new tests are passing.
14 |
15 | If you need help, consider asking for advice on [Twitter](https://twitter.com/minikin).
16 |
17 | Thank you for your contribution 🚀!
18 |
--------------------------------------------------------------------------------
/.github/workflows/.cspell/cryptocurrencies.txt:
--------------------------------------------------------------------------------
1 | 137
2 | CBOR
3 | abi
4 | abis
5 | amberdata
6 | bancor
7 | binance
8 | bittrex
9 | blocknative
10 | blocknumber
11 | busd
12 | calldata
13 | cardano
14 | coinbase
15 | coingecko
16 | coinmarketcap
17 | connext
18 | contenthash
19 | cryptocurrencies
20 | cryptokitties
21 | cryptokitty
22 | da
23 | dai
24 | dao
25 | dapp
26 | dapps
27 | decentraland
28 | ecrecover
29 | endblock
30 | eoa
31 | eoas
32 | erasurebay
33 | ethereum
34 | ethereumjs
35 | etherscan
36 | ethersjs
37 | ethplorer
38 | ethutil
39 | extcodesize
40 | finney
41 | fortmatic
42 | frontrun
43 | frontrunner
44 | frontrunning
45 | ganache
46 | gaslimit
47 | gasprice
48 | geth
49 | gether
50 | gitcoin
51 | goerli
52 | griefing
53 | gwei
54 | holo
55 | huobi
56 | iearn
57 | infura
58 | js
59 | keth
60 | kether
61 | keystore
62 | keystores
63 | keythereum
64 | kovan
65 | kwei
66 | kyber
67 | loopring
68 | mainnet
69 | makerdao
70 | matic
71 | mempool
72 | metamask
73 | mether
74 | moonpay
75 | multisig
76 | mwei
77 | namehash
78 | nexo
79 | nft
80 | nfts
81 | nonpayable
82 | numeraire
83 | onchain
84 | onramp
85 | opensea
86 | openzeppelin
87 | orderbook
88 | ostack
89 | panvala
90 | portis
91 | privatekey
92 | quantstamp
93 | relayer
94 | relayers
95 | reth
96 | rhoc
97 | rinkeby
98 | rinketh
99 | ropsten
100 | sai
101 | samczsun
102 | samczsun's
103 | sendwyre
104 | shapeshift
105 | sigutil
106 | slugify
107 | solc
108 | squarelink
109 | stablecoin
110 | startblock
111 | storj
112 | susd
113 | szabo
114 | taud
115 | tcad
116 | testnet
117 | testnets
118 | testwyre
119 | tgbp
120 | thkd
121 | threebox
122 | tkn
123 | trezor
124 | tusd
125 | txhash
126 | txlist
127 | uint
128 | unilogin
129 | uniswap
130 | upgradeability
131 | usdc
132 | usdt
133 | veri
134 | wbtc
135 | web
136 | wei
137 | weth
138 | wyre
139 | xchf
140 |
--------------------------------------------------------------------------------
/.github/workflows/.cspell/cryptography.txt:
--------------------------------------------------------------------------------
1 | 2
2 | ED25519
3 | blake2b
--------------------------------------------------------------------------------
/.github/workflows/.cspell/flutter_dart.txt:
--------------------------------------------------------------------------------
1 | Intelli
2 | Boostrapping
3 | dartdoc
4 | goldens
5 | xcworkspace
6 | xcassets
--------------------------------------------------------------------------------
/.github/workflows/.cspell/forbidden.txt:
--------------------------------------------------------------------------------
1 | hte
2 | teh
3 |
--------------------------------------------------------------------------------
/.github/workflows/.cspell/networking_terms.txt:
--------------------------------------------------------------------------------
1 | 36
2 | arubaos
3 | asaos
4 | bgp
5 | dns
6 | demux
7 | ebgp
8 | eigrp
9 | eos
10 | evpn
11 | ftp
12 | ibgp
13 | imap
14 | ios
15 | iosxr
16 | ipp
17 | ise
18 | isis
19 | isoxe
20 | junoos
21 | junos
22 | ldap
23 | lldp
24 | mux
25 | ntp
26 | nxos
27 | openswitch
28 | ospf
29 | pop3
30 | rip
31 | routeros
32 | snmp
33 | sros
34 | ssh
35 | tmos
36 | vxlan
37 | vyos
38 |
--------------------------------------------------------------------------------
/.github/workflows/.cspell/project.txt:
--------------------------------------------------------------------------------
1 | djminikin
2 | LTWH
3 | nonmodal
--------------------------------------------------------------------------------
/.github/workflows/cspell.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2",
3 | "language": "en",
4 | "flagWords": ["teh", "hte"],
5 | "ignorePaths": [
6 | "**/assets/**",
7 | "**/test/**",
8 | "**/CHANGELOG.md"
9 | ],
10 | "ignoreRegExpList": [
11 | "@[\\w\\-]+",
12 | "\\$\\w+",
13 | "\\{\\w+",
14 | "\\`\\w+",
15 | "\\:\\w+",
16 | "\\/\\w+",
17 | "\\#[\\w\\-]+"
18 | ],
19 | "dictionaries": [
20 | "companies",
21 | "cryptocurrencies",
22 | "cryptography",
23 | "en_US",
24 | "flutterDart",
25 | "forbidden",
26 | "hyph_en_US",
27 | "networkingTerms",
28 | "project",
29 | "rust",
30 | "softwareTerms"
31 | ],
32 | "languageSettings": [{
33 | "languageId": "markdown",
34 | "ignoreRegExpList": [
35 | "/^\\s*```[\\s\\S]*?^\\s*```/gm"
36 | ]
37 | }],
38 | "dictionaryDefinitions": [{
39 | "name": "companies",
40 | "path": "./.cspell/companies.txt",
41 | "addWords": true
42 | },
43 | {
44 | "name": "cryptocurrencies",
45 | "path": "./.cspell/cryptocurrencies.txt",
46 | "addWords": true
47 | },
48 | {
49 | "name": "cryptography",
50 | "path": "./.cspell/cryptography.txt",
51 | "addWords": true
52 | },
53 | {
54 | "name": "en_US",
55 | "path": "./.cspell/en_US.txt",
56 | "addWords": true
57 | },
58 | {
59 | "name": "flutterDart",
60 | "path": "./.cspell/flutter_dart.txt",
61 | "addWords": true
62 | },
63 | {
64 | "name": "forbidden",
65 | "path": "./.cspell/forbidden.txt",
66 | "addWords": true
67 | },
68 | {
69 | "name": "hyph_en_US",
70 | "path": "./.cspell/hyph_en_US.txt",
71 | "addWords": true
72 | },
73 | {
74 | "name": "networkingTerms",
75 | "path": "./.cspell/networking_terms.txt",
76 | "addWords": true
77 | },
78 | {
79 | "name": "project",
80 | "path": "./.cspell/project.txt",
81 | "addWords": true
82 | },
83 | {
84 | "name": "softwareTerms",
85 | "path": "./.cspell/software_terms.txt",
86 | "addWords": true
87 | }
88 | ]
89 | }
--------------------------------------------------------------------------------
/.github/workflows/on_pull_request.yml:
--------------------------------------------------------------------------------
1 | name: On Pull Request
2 |
3 | on:
4 | push:
5 | branches: [main]
6 | pull_request:
7 | branches:
8 | - "*"
9 |
10 | jobs:
11 | build:
12 | runs-on: ubuntu-latest
13 |
14 | steps:
15 | - uses: actions/checkout@v3
16 |
17 | - uses: subosito/flutter-action@v2
18 | with:
19 | channel: "stable"
20 |
21 | - name: Install dependencies
22 | run: flutter pub get
23 |
24 | - name: Format
25 | run: dart format --set-exit-if-changed lib test example
26 |
27 | - name: Analyzing project
28 | run: flutter analyze
29 |
30 | - name: Run tests
31 | run: flutter test --no-pub --coverage --test-randomize-ordering-seed random
32 |
33 | - name: Check Code Coverage
34 | uses: VeryGoodOpenSource/very_good_coverage@v1.1.1
35 | with:
36 | path: coverage/lcov.info
37 | min_coverage: 90
38 |
39 | - name: Upload coverage to Codecov
40 | uses: codecov/codecov-action@v1
41 | with:
42 | token: ${{ secrets.CODECOV_TOKEN }}
43 |
--------------------------------------------------------------------------------
/.github/workflows/spell_checker.yml:
--------------------------------------------------------------------------------
1 | name: Spell Checker
2 |
3 | concurrency:
4 | group: ${{ github.workflow }}-${{ github.ref }}
5 | cancel-in-progress: true
6 |
7 | on:
8 | push:
9 | branches:
10 | - main
11 | pull_request:
12 | types:
13 | - opened
14 | - edited
15 | - synchronize
16 |
17 | permissions:
18 | contents: read
19 |
20 | jobs:
21 | test:
22 | name: 'Check spelling'
23 | runs-on: ubuntu-latest
24 | permissions:
25 | contents: read
26 | pull-requests: read
27 | steps:
28 | - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
29 | - uses: streetsidesoftware/cspell-action@48c17f77a224fd11ab3bbb8ef454117ff098eff7 # v2.21.0
30 | with:
31 | files: "**/*.{md,dart}"
32 | incremental_files_only: false
33 | config: ./.github/workflows/cspell.json
--------------------------------------------------------------------------------
/.github/workflows/stale-branches.yml:
--------------------------------------------------------------------------------
1 | name: Stale Branches
2 |
3 | on:
4 | schedule:
5 | - cron: "0 6 * * 1-5"
6 |
7 | permissions:
8 | issues: write
9 | contents: write
10 |
11 | jobs:
12 | stale_branches:
13 | runs-on: ubuntu-latest
14 | steps:
15 | - name: Stale Branches
16 | uses: crs-k/stale-branches@v2.0.1
17 | with:
18 | repo-token: "${{ secrets.GITHUB_TOKEN }}"
19 | days-before-stale: 30
20 | days-before-delete: 45
21 | comment-updates: false
22 | max-issues: 20
23 | tag-committer: false
24 | stale-branch-label: "stale branch 🗑️"
25 | compare-branches: "info"
26 |
--------------------------------------------------------------------------------
/.github/workflows/title_validation.yml:
--------------------------------------------------------------------------------
1 | # See https://github.com/amannn/action-semantic-pull-request
2 | name: 'PR Title is Conventional'
3 |
4 | on:
5 | pull_request_target:
6 | types:
7 | - opened
8 | - edited
9 | - synchronize
10 |
11 | permissions:
12 | contents: read
13 |
14 | jobs:
15 | main:
16 | name: Validate PR title
17 | runs-on: ubuntu-latest
18 | permissions:
19 | pull-requests: read
20 | statuses: write
21 | steps:
22 | - uses: amannn/action-semantic-pull-request@505e44b4f33b4c801f063838b3f053990ee46ea7 # v4.6.0
23 | env:
24 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25 | with:
26 | types: |
27 | build
28 | chore
29 | ci
30 | docs
31 | feat
32 | fix
33 | perf
34 | refactor
35 | revert
36 | style
37 | test
38 | subjectPattern: ^[A-Z].+$
39 | subjectPatternError: |
40 | The subject of the PR must begin with an uppercase letter.
41 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 |
12 | # IntelliJ related
13 | *.iml
14 | *.ipr
15 | *.iws
16 | .idea/
17 |
18 | # The .vscode folder contains launch configuration and tasks you configure in
19 | # VS Code which you may wish to be included in version control, so this line
20 | # is commented out by default.
21 | #.vscode/
22 |
23 | # Flutter/Dart/Pub related
24 | **/doc/api/
25 | .dart_tool/
26 | .flutter-plugins
27 | .flutter-plugins-dependencies
28 | .packages
29 | .pub-cache/
30 | .pub/
31 | build/
32 |
33 | # Android related
34 | **/android/**/gradle-wrapper.jar
35 | **/android/.gradle
36 | **/android/captures/
37 | **/android/gradlew
38 | **/android/gradlew.bat
39 | **/android/local.properties
40 | **/android/**/GeneratedPluginRegistrant.java
41 |
42 | # iOS/XCode related
43 | **/ios/**/*.mode1v3
44 | **/ios/**/*.mode2v3
45 | **/ios/**/*.moved-aside
46 | **/ios/**/*.pbxuser
47 | **/ios/**/*.perspectivev3
48 | **/ios/**/*sync/
49 | **/ios/**/.sconsign.dblite
50 | **/ios/**/.tags*
51 | **/ios/**/.vagrant/
52 | **/ios/**/DerivedData/
53 | **/ios/**/Icon?
54 | **/ios/**/Pods/
55 | **/ios/**/.symlinks/
56 | **/ios/**/profile
57 | **/ios/**/xcuserdata
58 | **/ios/.generated/
59 | **/ios/Flutter/App.framework
60 | **/ios/Flutter/Flutter.framework
61 | **/ios/Flutter/Flutter.podspec
62 | **/ios/Flutter/Generated.xcconfig
63 | **/ios/Flutter/app.flx
64 | **/ios/Flutter/app.zip
65 | **/ios/Flutter/flutter_assets/
66 | **/ios/Flutter/flutter_export_environment.sh
67 | **/ios/ServiceDefinitions.json
68 | **/ios/Runner/GeneratedPluginRegistrant.*
69 |
70 | # Exceptions to above rules.
71 | !**/ios/**/default.mode1v3
72 | !**/ios/**/default.mode2v3
73 | !**/ios/**/default.pbxuser
74 | !**/ios/**/default.perspectivev3
75 |
76 | #
77 | coverage/
78 |
--------------------------------------------------------------------------------
/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: 8f89f6505b941329a864fef1527243a72800bf4d
8 | channel: beta
9 |
10 | project_type: package
11 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Example",
9 | "request": "launch",
10 | "type": "dart",
11 | "flutterMode": "debug",
12 | "program": "example/lib/main.dart",
13 | }
14 | ]
15 | }
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## [0.3.1] - 10.00.2024
2 |
3 | - Update minimum Flutter and Dart versions to 3.24.0+ and 3.5.0+ respectively.
4 |
5 | ## [0.3.0+1] - 19.05.2024
6 |
7 | - Update README.
8 | - Update web example to use flutter.js service worker bootstrapping.
9 |
10 | ## [0.3.0] - 08.02.2024
11 |
12 | - Fixed [Half of the widget is not shown](https://github.com/minikin/popover/issues/83). (thanks [@zwett](https://github.com/zwett)).
13 |
14 | ## [0.2.9] - 08.12.2023
15 |
16 | - Added `contentDxOffset`. (thanks [@kasyanyukd1995](https://github.com/kasyanyukd1995)).
17 |
18 | ## [0.2.8+2] - 01.03.2023
19 |
20 | - Fix [`PopoverItem._configureRect()` throws trying to access unmounted context](https://github.com/minikin/popover/issues/63).(thanks [@moescs](https://github.com/moescs)).
21 |
22 | ## [0.2.8+1] - 05.02.2023
23 |
24 | - Fix [`backgroundColor` only effects arrow](https://github.com/minikin/popover/issues/59).
25 |
26 | ## [0.2.8] - 02.01.2023
27 |
28 | - **BREAKING**: Improve popover rendering. `isParentAlive` parameter was deprecated. (thanks [@VictorOhashi](https://github.com/VictorOhashi)).
29 |
30 | ## [0.2.7] - 23.10.2022
31 |
32 | - Add `popoverTransitionBuilder`. Users can provide custom animation transition now. (thanks [@sanjidbillah](https://github.com/sanjidbillah)).
33 |
34 | ## [0.2.6+3] - 12.10.2021
35 |
36 | - Fixed the bug that appears when the parent widget from which `Popover` was presented has been removed from a widget tree (thanks [@ajaxspace](https://github.com/ajaxspace)).
37 |
38 | ## [0.2.6+2] - 17.06.2021
39 |
40 | - Fixed the bug that appears when you change window size while popover is opened (thanks [@whitebug](https://github.com/whitebug)).
41 |
42 | ## [0.2.6+1] - 21.05.2021
43 |
44 | - Set minimum dart version to 2.12.0.
45 |
46 | ## [0.2.6] - 21.05.2021
47 |
48 | - Fix constraints size for `PopoverDirection.top` & `PopoverDirection.bottom`.
49 |
50 | ## [0.2.5] - 18.05.2021
51 |
52 | - Recalculate popover shape on context changes.
53 |
54 | ## [0.2.4] - 17.05.2021
55 |
56 | - Parameters `arrowDyOffset`, `arrowDxOffset` and `contentDyOffset` now can be apply again.
57 | - Fix [Popover breaks when opened to the right](https://github.com/minikin/popover/issues/17).
58 | - Update example.
59 |
60 | ## [0.2.3] - 03.05.2021.
61 |
62 | - Add `RouteSettings? routeSettings` parameter.
63 |
64 | ## [0.2.2] - 22.04.2021.
65 |
66 | - Rebuild Popover on device orientation changes (thanks [@SanekLic](https://github.com/SanekLic), [@shcherbuk96](https://github.com/shcherbuk96)).
67 |
68 | ## [0.2.1] - 04.04.2021.
69 |
70 | - Lower minimum version requirements for Dart and Flutter to pass pub.dev validation.
71 |
72 | ## [0.2.0] - 04.04.2021.
73 |
74 | - Migrate to NNBD.
75 |
76 | ## [0.1.0] - 09.02.2021.
77 |
78 | - **BREAKING**: Refactor popover implementation to have identical API to included in Flutter modal dialogs e.g. `showCupertinoDialog`
79 | - docs: README updates
80 | - docs: example application updates
81 |
82 | ## [0.0.5] - 08.02.2021.
83 |
84 | - Add `Key key`, `barrierDismissible` and `showPopover`.
85 |
86 | ## [0.0.4] - 27.01.2021.
87 |
88 | - Add `arrowDyOffset`, `arrowDxOffset` and `contentDyOffset` public parameters.
89 |
90 | ## [0.0.3] - 21.01.2021.
91 |
92 | - A `child` widget can be wrapped in `InkWell` or `GestureDetector`.
93 |
94 | ## [0.0.2] - 18.01.2021.
95 |
96 | - Update `PopoverItem`.
97 | - Add `PopoverDirection` to exports.
98 | - Add documentation.
99 |
100 | ## [0.0.1] - 10.01.2021.
101 |
102 | - Initial release.
103 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, sex characteristics, gender identity and expression,
9 | level of experience, education, socio-economic status, nationality, personal
10 | appearance, race, religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at warbles.lieu_04@icloud.com. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
75 | For answers to common questions about this code of conduct, see
76 | https://www.contributor-covenant.org/faq
77 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | When contributing to this repository, please first discuss the change you wish to make via issue,
4 | email, or any other method with the owners of this repository before making a change.
5 |
6 | Please note we have a code of conduct, please follow it in all your interactions with the project.
7 |
8 | ## Pull Request Process
9 |
10 | 1. Ensure any install or build dependencies are removed before the end of the layer when doing a
11 | build.
12 | 2. Update the README.md with details of changes to the interface, this includes new environment
13 | variables, exposed ports, useful file locations and container parameters.
14 | 3. Increase the version numbers in any examples files and the README.md to the new version that this
15 | Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
16 | 4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
17 | do not have permission to do that, you may request the second reviewer to merge it for you.
18 |
19 | ## Code of Conduct
20 |
21 | ### Our Pledge
22 |
23 | In the interest of fostering an open and welcoming environment, we as
24 | contributors and maintainers pledge to making participation in our project and
25 | our community a harassment-free experience for everyone, regardless of age, body
26 | size, disability, ethnicity, gender identity and expression, level of experience,
27 | nationality, personal appearance, race, religion, or sexual identity and
28 | orientation.
29 |
30 | ### Our Standards
31 |
32 | Examples of behavior that contributes to creating a positive environment
33 | include:
34 |
35 | * Using welcoming and inclusive language
36 | * Being respectful of differing viewpoints and experiences
37 | * Gracefully accepting constructive criticism
38 | * Focusing on what is best for the community
39 | * Showing empathy towards other community members
40 |
41 | Examples of unacceptable behavior by participants include:
42 |
43 | * The use of sexualized language or imagery and unwelcome sexual attention or
44 | advances
45 | * Trolling, insulting/derogatory comments, and personal or political attacks
46 | * Public or private harassment
47 | * Publishing others' private information, such as a physical or electronic
48 | address, without explicit permission
49 | * Other conduct which could reasonably be considered inappropriate in a
50 | professional setting
51 |
52 | ### Our Responsibilities
53 |
54 | Project maintainers are responsible for clarifying the standards of acceptable
55 | behavior and are expected to take appropriate and fair corrective action in
56 | response to any instances of unacceptable behavior.
57 |
58 | Project maintainers have the right and responsibility to remove, edit, or
59 | reject comments, commits, code, wiki edits, issues, and other contributions
60 | that are not aligned to this Code of Conduct, or to ban temporarily or
61 | permanently any contributor for other behaviors that they deem inappropriate,
62 | threatening, offensive, or harmful.
63 |
64 | ### Scope
65 |
66 | This Code of Conduct applies both within project spaces and in public spaces
67 | when an individual is representing the project or its community. Examples of
68 | representing a project or community include using an official project e-mail
69 | address, posting via an official social media account, or acting as an appointed
70 | representative at an online or offline event. Representation of a project may be
71 | further defined and clarified by project maintainers.
72 |
73 | ### Enforcement
74 |
75 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
76 | reported by contacting the project team at djminikin at gmail dot com. All
77 | complaints will be reviewed and investigated and will result in a response that
78 | is deemed necessary and appropriate to the circumstances. The project team is
79 | obligated to maintain confidentiality with regard to the reporter of an incident.
80 | Further details of specific enforcement policies may be posted separately.
81 |
82 | Project maintainers who do not follow or enforce the Code of Conduct in good
83 | faith may face temporary or permanent repercussions as determined by other
84 | members of the project's leadership.
85 |
86 | ### Attribution
87 |
88 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
89 | available at [http://contributor-covenant.org/version/1/4][version]
90 |
91 | [homepage]: http://contributor-covenant.org
92 | [version]: http://contributor-covenant.org/version/1/4/
93 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 - 2024 Oleksandr Prokhorenko
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
Popover
2 |
3 |
4 |
5 |
6 |
7 |
Popover for Flutter
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | # Content
41 |
42 | - [Content](#content)
43 | - [Features](#features)
44 | - [Requirements](#requirements)
45 | - [Install](#install)
46 | - [Example](#example)
47 | - [Support](#support)
48 | - [License](#license)
49 |
50 | ## Features
51 |
52 | > A popover is a transient view that appears above other content onscreen when you tap a control or in an area. Typically, a popover includes an arrow pointing to the location from which it emerged. Popovers can be nonmodal or modal. A nonmodal popover is dismissed by tapping another part of the screen or a button on the popover. A modal popover is dismissed by tapping a Cancel or other button on the popover.
53 |
54 | Source: [Human Interface Guidelines.
55 | ](https://developer.apple.com/design/human-interface-guidelines/ios/views/popovers/)
56 |
57 | ## Requirements
58 |
59 | - Dart: 3.5.0+
60 | - Flutter: 3.24.0+
61 |
62 | ## Install
63 |
64 | ```yaml
65 | dependencies:
66 | popover: ^0.3.1
67 | ```
68 |
69 | ## Example
70 |
71 | See `example/lib/main.dart`.
72 |
73 | ```dart
74 | import 'package:flutter/material.dart';
75 | import 'package:popover/popover.dart';
76 |
77 | class PopoverExample extends StatelessWidget {
78 | @override
79 | Widget build(BuildContext context) {
80 | return MaterialApp(
81 | home: Scaffold(
82 | appBar: AppBar(title: const Text('Popover Example')),
83 | body: const SafeArea(
84 | child: Padding(
85 | padding: EdgeInsets.all(16),
86 | child: Button(),
87 | ),
88 | ),
89 | ),
90 | );
91 | }
92 | }
93 |
94 | class Button extends StatelessWidget {
95 | const Button({Key? key}) : super(key: key);
96 |
97 | @override
98 | Widget build(BuildContext context) {
99 | return Container(
100 | width: 80,
101 | height: 40,
102 | decoration: const BoxDecoration(
103 | color: Colors.white,
104 | borderRadius: BorderRadius.all(Radius.circular(5)),
105 | boxShadow: [BoxShadow(color: Colors.black26, blurRadius: 5)],
106 | ),
107 | child: GestureDetector(
108 | child: const Center(child: Text('Click Me')),
109 | onTap: () {
110 | showPopover(
111 | context: context,
112 | bodyBuilder: (context) => const ListItems(),
113 | onPop: () => print('Popover was popped!'),
114 | direction: PopoverDirection.bottom,
115 | width: 200,
116 | height: 400,
117 | arrowHeight: 15,
118 | arrowWidth: 30,
119 | );
120 | },
121 | ),
122 | );
123 | }
124 | }
125 |
126 | class ListItems extends StatelessWidget {
127 | const ListItems({Key? key}) : super(key: key);
128 |
129 | @override
130 | Widget build(BuildContext context) {
131 | return Padding(
132 | padding: const EdgeInsets.symmetric(vertical: 8),
133 | child: ListView(
134 | padding: const EdgeInsets.all(8),
135 | children: [
136 | InkWell(
137 | onTap: () {
138 | Navigator.of(context)
139 | ..pop()
140 | ..push(
141 | MaterialPageRoute(
142 | builder: (context) => SecondRoute(),
143 | ),
144 | );
145 | },
146 | child: Container(
147 | height: 50,
148 | color: Colors.amber[100],
149 | child: const Center(child: Text('Entry A')),
150 | ),
151 | ),
152 | const Divider(),
153 | Container(
154 | height: 50,
155 | color: Colors.amber[200],
156 | child: const Center(child: Text('Entry B')),
157 | ),
158 | const Divider(),
159 | Container(
160 | height: 50,
161 | color: Colors.amber[300],
162 | child: const Center(child: Text('Entry C')),
163 | ),
164 | ],
165 | ),
166 | );
167 | }
168 | }
169 |
170 | class SecondRoute extends StatelessWidget {
171 | @override
172 | Widget build(BuildContext context) {
173 | return Scaffold(
174 | appBar: AppBar(
175 | title: const Text('Second Route'),
176 | automaticallyImplyLeading: false,
177 | ),
178 | body: Center(
179 | child: ElevatedButton(
180 | onPressed: () => Navigator.pop(context),
181 | child: const Text('Go back!'),
182 | ),
183 | ),
184 | );
185 | }
186 | }
187 | ```
188 |
189 | To see examples of the following package on a device or simulator:
190 |
191 | ```sh
192 | cd example && flutter run
193 | ```
194 |
195 | ## Support
196 |
197 | Post issues and feature requests on the GitHub [issue tracker](https://github.com/minikin/popover/issues).
198 |
199 | ## License
200 |
201 | The source code of Popover project is available under the MIT license.
202 | See the [LICENSE](https://github.com/minikin/popover/blob/main/LICENSE) file for more info.
203 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | ## Reporting a Vulnerability
4 |
5 | This project is maintained on a voluntary basis, and there is no formal support or dedicated security team.
6 | However, we still take security vulnerabilities seriously and appreciate your effort in reporting them.
7 |
8 | ### How to Report
9 |
10 | 1. **GitHub Issue:** Create an issue in this repository to report the vulnerability.
11 | 2. **Tagging:** Tag the repository owner or maintainer in the issue to ensure it gets noticed.
12 | 3. **Details to Include:**
13 | - A description of the vulnerability and its potential impact.
14 | - Steps to reproduce the issue.
15 | - Any relevant logs or screenshots.
16 | - Potential solutions or fixes if you have any.
17 |
18 | ### Response Time
19 |
20 | As this project is maintained by volunteers, response times may vary.
21 | We aim to respond to vulnerability reports as soon as possible,
22 | but please understand that there may be delays.
23 |
24 | ## Supported Versions
25 |
26 | Security updates, if any, will be applied to the latest version of the repository.
27 | Older versions may not receive security updates due to limited resources.
28 |
29 | ## Security Measures
30 |
31 | ### Code Review
32 |
33 | - Contributions are reviewed by volunteers before being merged.
34 |
35 | ### Dependency Management
36 |
37 | - Efforts are made to keep dependencies up to date, but this is not guaranteed.
38 |
39 | ### Security Testing
40 |
41 | - Basic security testing is performed, but there may be gaps due to limited resources.
42 |
43 | ## Disclaimer
44 |
45 | This project is provided "as is" without any warranty.
46 | There is no obligation to provide maintenance, support, updates, enhancements, or modifications.
47 |
48 | ## Contact
49 |
50 | If you have any questions or concerns about our security policy, please create an issue in this repository and tag @minikin.
51 |
52 | ---
53 |
54 | By following this security policy, we aim to address security concerns within the limitations of our volunteer-based project.
55 |
--------------------------------------------------------------------------------
/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | analyzer:
2 | language:
3 | strict-casts: true
4 | strict-inference: true
5 | strict-raw-types: true
6 | errors:
7 | always_put_required_named_parameters_first: error
8 | avoid_relative_lib_imports: error
9 | missing_required_param: error
10 | no_duplicate_case_values: error
11 | prefer_const_constructors: error
12 | exclude:
13 | - lib/generated_plugin_registrant.dart
14 | - lib/**.g.dart
15 |
16 | linter:
17 | rules:
18 | - avoid_private_typedef_functions
19 | - avoid_setters_without_getters
20 | - await_only_futures
21 | - camel_case_types
22 | - cancel_subscriptions
23 | - close_sinks
24 | - constant_identifier_names
25 | - control_flow_in_finally
26 | - directives_ordering
27 | - empty_constructor_bodies
28 | - empty_statements
29 | - hash_and_equals
30 | - implementation_imports
31 | - lines_longer_than_80_chars
32 | - non_constant_identifier_names
33 | - one_member_abstracts
34 | - package_names
35 | - package_prefixed_library_names
36 | - prefer_collection_literals
37 | - prefer_const_constructors
38 | - prefer_final_locals
39 | - prefer_function_declarations_over_variables
40 | - prefer_if_elements_to_conditional_expressions
41 | - prefer_interpolation_to_compose_strings
42 | - prefer_null_aware_operators
43 | - prefer_typing_uninitialized_variables
44 | - test_types_in_equals
45 | - type_annotate_public_apis
46 | - unnecessary_await_in_return
47 | - unnecessary_brace_in_string_interps
48 | - unnecessary_const
49 | - unnecessary_getters_setters
50 | - unnecessary_parenthesis
51 | - unnecessary_statements
52 | - use_to_and_as_if_applicable
53 | # Effective Dart Rules
54 | - avoid_catches_without_on_clauses
55 | - avoid_catching_errors
56 | - avoid_equals_and_hash_code_on_mutable_classes
57 | - avoid_function_literals_in_foreach_calls
58 | - avoid_init_to_null
59 | - avoid_null_checks_in_equality_operators
60 | - avoid_positional_boolean_parameters
61 | - avoid_relative_lib_imports
62 | - avoid_return_types_on_setters
63 | - avoid_returning_this
64 | - avoid_types_on_closure_parameters
65 | - camel_case_extensions
66 | - curly_braces_in_flow_control_structures
67 | - file_names
68 | - library_names
69 | - library_prefixes
70 | - omit_local_variable_types
71 | - package_api_docs
72 | - prefer_adjacent_string_concatenation
73 | - prefer_equal_for_default_values
74 | - prefer_final_fields
75 | - prefer_generic_function_type_aliases
76 | - prefer_initializing_formals
77 | - prefer_is_empty
78 | - prefer_is_not_empty
79 | - prefer_iterable_whereType
80 | - prefer_mixin
81 | - prefer_relative_imports
82 | - slash_for_doc_comments
83 | - type_init_formals
84 | - unnecessary_lambdas
85 | - unnecessary_new
86 | - unnecessary_this
87 | - use_setters_to_change_properties
88 |
--------------------------------------------------------------------------------
/assets/popover.pxd/QuickLook/Icon.tiff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/assets/popover.pxd/QuickLook/Icon.tiff
--------------------------------------------------------------------------------
/assets/popover.pxd/QuickLook/Thumbnail.tiff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/assets/popover.pxd/QuickLook/Thumbnail.tiff
--------------------------------------------------------------------------------
/assets/popover.pxd/data/5BC896EC-BCEF-43D1-9861-ACA4C0F5BBE9:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/assets/popover.pxd/data/5BC896EC-BCEF-43D1-9861-ACA4C0F5BBE9
--------------------------------------------------------------------------------
/assets/popover.pxd/data/5EB1D7DE-C477-4BD5-AADF-38260B1F132A:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/assets/popover.pxd/data/5EB1D7DE-C477-4BD5-AADF-38260B1F132A
--------------------------------------------------------------------------------
/assets/popover.pxd/data/8F00D828-9D5B-4252-A7EC-9EEA5B24E1B6:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/assets/popover.pxd/data/8F00D828-9D5B-4252-A7EC-9EEA5B24E1B6
--------------------------------------------------------------------------------
/assets/popover.pxd/data/A3688D72-C0E0-4D6B-A9E7-B99A42546338:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/assets/popover.pxd/data/A3688D72-C0E0-4D6B-A9E7-B99A42546338
--------------------------------------------------------------------------------
/assets/popover.pxd/data/CD0ED540-5ECB-4CFB-9B86-237858F87D33:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/assets/popover.pxd/data/CD0ED540-5ECB-4CFB-9B86-237858F87D33
--------------------------------------------------------------------------------
/assets/popover.pxd/metadata.info:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/assets/popover.pxd/metadata.info
--------------------------------------------------------------------------------
/example/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 |
12 | # IntelliJ related
13 | *.iml
14 | *.ipr
15 | *.iws
16 | .idea/
17 |
18 | # The .vscode folder contains launch configuration and tasks you configure in
19 | # VS Code which you may wish to be included in version control, so this line
20 | # is commented out by default.
21 | #.vscode/
22 |
23 | # Flutter/Dart/Pub related
24 | **/doc/api/
25 | **/ios/Flutter/.last_build_id
26 | .dart_tool/
27 | .flutter-plugins
28 | .flutter-plugins-dependencies
29 | .packages
30 | .pub-cache/
31 | .pub/
32 | /build/
33 |
34 | # Web related
35 |
36 | # Symbolication related
37 | app.*.symbols
38 |
39 | # Obfuscation related
40 | app.*.map.json
41 |
42 | # Android Studio will place build artifacts here
43 | /android/app/debug
44 | /android/app/profile
45 | /android/app/release
46 |
--------------------------------------------------------------------------------
/example/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: "80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819"
8 | channel: "stable"
9 |
10 | project_type: app
11 |
12 | # Tracks metadata for the flutter migrate command
13 | migration:
14 | platforms:
15 | - platform: root
16 | create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
17 | base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
18 | - platform: android
19 | create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
20 | base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
21 |
22 | # User provided section
23 |
24 | # List of Local paths (relative to this file) that should be
25 | # ignored by the migrate tool.
26 | #
27 | # Files that are not part of the templates will be ignored by default.
28 | unmanaged_files:
29 | - 'lib/main.dart'
30 | - 'ios/Runner.xcodeproj/project.pbxproj'
31 |
--------------------------------------------------------------------------------
/example/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "example",
9 | "request": "launch",
10 | "type": "dart"
11 | }
12 | ]
13 | }
--------------------------------------------------------------------------------
/example/README.md:
--------------------------------------------------------------------------------
1 | # example
2 |
3 | A new Flutter project.
4 |
5 | ## Getting Started
6 |
7 | This project is a starting point for a Flutter application.
8 |
9 | A few resources to get you started if this is your first Flutter project:
10 |
11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
13 |
14 | For help getting started with Flutter, view our
15 | [online documentation](https://flutter.dev/docs), which offers tutorials,
16 | samples, guidance on mobile development, and a full API reference.
17 |
--------------------------------------------------------------------------------
/example/android/.gitignore:
--------------------------------------------------------------------------------
1 | gradle-wrapper.jar
2 | /.gradle
3 | /captures/
4 | /gradlew
5 | /gradlew.bat
6 | /local.properties
7 | GeneratedPluginRegistrant.java
8 |
9 | # Remember to never publicly share your keystore.
10 | # See https://flutter.dev/to/reference-keystore
11 | key.properties
12 | **/*.keystore
13 | **/*.jks
14 |
--------------------------------------------------------------------------------
/example/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id "com.android.application"
3 | id "kotlin-android"
4 | // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
5 | id "dev.flutter.flutter-gradle-plugin"
6 | }
7 |
8 | android {
9 | namespace = "me.minikin.example"
10 | compileSdk = flutter.compileSdkVersion
11 | ndkVersion = flutter.ndkVersion
12 |
13 | compileOptions {
14 | sourceCompatibility = JavaVersion.VERSION_1_8
15 | targetCompatibility = JavaVersion.VERSION_1_8
16 | }
17 |
18 | kotlinOptions {
19 | jvmTarget = JavaVersion.VERSION_1_8
20 | }
21 |
22 | defaultConfig {
23 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
24 | applicationId = "me.minikin.example"
25 | // You can update the following values to match your application needs.
26 | // For more information, see: https://flutter.dev/to/review-gradle-config.
27 | minSdk = flutter.minSdkVersion
28 | targetSdk = flutter.targetSdkVersion
29 | versionCode = flutter.versionCode
30 | versionName = flutter.versionName
31 | }
32 |
33 | buildTypes {
34 | release {
35 | // TODO: Add your own signing config for the release build.
36 | // Signing with the debug keys for now, so `flutter run --release` works.
37 | signingConfig = signingConfigs.debug
38 | }
39 | }
40 | }
41 |
42 | flutter {
43 | source = "../.."
44 | }
45 |
--------------------------------------------------------------------------------
/example/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
15 |
19 |
23 |
24 |
25 |
26 |
27 |
28 |
30 |
33 |
34 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/example/android/app/src/main/kotlin/me/minikin/example/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package me.minikin.example
2 |
3 | import io.flutter.embedding.android.FlutterActivity
4 |
5 | class MainActivity: FlutterActivity()
6 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable-v21/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values-night/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/example/android/app/src/profile/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/android/build.gradle:
--------------------------------------------------------------------------------
1 | allprojects {
2 | repositories {
3 | google()
4 | mavenCentral()
5 | }
6 | }
7 |
8 | rootProject.buildDir = "../build"
9 | subprojects {
10 | project.buildDir = "${rootProject.buildDir}/${project.name}"
11 | }
12 | subprojects {
13 | project.evaluationDependsOn(":app")
14 | }
15 |
16 | tasks.register("clean", Delete) {
17 | delete rootProject.buildDir
18 | }
19 |
--------------------------------------------------------------------------------
/example/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError
2 | android.useAndroidX=true
3 | android.enableJetifier=true
4 |
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | zipStoreBase=GRADLE_USER_HOME
4 | zipStorePath=wrapper/dists
5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip
6 |
--------------------------------------------------------------------------------
/example/android/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | def flutterSdkPath = {
3 | def properties = new Properties()
4 | file("local.properties").withInputStream { properties.load(it) }
5 | def flutterSdkPath = properties.getProperty("flutter.sdk")
6 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
7 | return flutterSdkPath
8 | }()
9 |
10 | includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
11 |
12 | repositories {
13 | google()
14 | mavenCentral()
15 | gradlePluginPortal()
16 | }
17 | }
18 |
19 | plugins {
20 | id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21 | id "com.android.application" version "7.3.0" apply false
22 | id "org.jetbrains.kotlin.android" version "1.7.10" apply false
23 | }
24 |
25 | include ":app"
26 |
--------------------------------------------------------------------------------
/example/ios/.gitignore:
--------------------------------------------------------------------------------
1 | *.mode1v3
2 | *.mode2v3
3 | *.moved-aside
4 | *.pbxuser
5 | *.perspectivev3
6 | **/*sync/
7 | .sconsign.dblite
8 | .tags*
9 | **/.vagrant/
10 | **/DerivedData/
11 | Icon?
12 | **/Pods/
13 | **/.symlinks/
14 | profile
15 | xcuserdata
16 | **/.generated/
17 | Flutter/App.framework
18 | Flutter/Flutter.framework
19 | Flutter/Flutter.podspec
20 | Flutter/Generated.xcconfig
21 | Flutter/app.flx
22 | Flutter/app.zip
23 | Flutter/flutter_assets/
24 | Flutter/flutter_export_environment.sh
25 | ServiceDefinitions.json
26 | Runner/GeneratedPluginRegistrant.*
27 |
28 | # Exceptions to above rules.
29 | !default.mode1v3
30 | !default.mode2v3
31 | !default.pbxuser
32 | !default.perspectivev3
33 |
--------------------------------------------------------------------------------
/example/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | App
9 | CFBundleIdentifier
10 | io.flutter.flutter.app
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | App
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | MinimumOSVersion
24 | 12.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/example/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 | import Flutter
3 |
4 | @main
5 | @objc class AppDelegate: FlutterAppDelegate {
6 | override func application(
7 | _ application: UIApplication,
8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
9 | ) -> Bool {
10 | GeneratedPluginRegistrant.register(with: self)
11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "20x20",
5 | "idiom" : "iphone",
6 | "filename" : "Icon-App-20x20@2x.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "size" : "20x20",
11 | "idiom" : "iphone",
12 | "filename" : "Icon-App-20x20@3x.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "Icon-App-29x29@1x.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "29x29",
23 | "idiom" : "iphone",
24 | "filename" : "Icon-App-29x29@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "29x29",
29 | "idiom" : "iphone",
30 | "filename" : "Icon-App-29x29@3x.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "40x40",
35 | "idiom" : "iphone",
36 | "filename" : "Icon-App-40x40@2x.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "40x40",
41 | "idiom" : "iphone",
42 | "filename" : "Icon-App-40x40@3x.png",
43 | "scale" : "3x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "Icon-App-60x60@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "Icon-App-60x60@3x.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "20x20",
59 | "idiom" : "ipad",
60 | "filename" : "Icon-App-20x20@1x.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "20x20",
65 | "idiom" : "ipad",
66 | "filename" : "Icon-App-20x20@2x.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "29x29",
71 | "idiom" : "ipad",
72 | "filename" : "Icon-App-29x29@1x.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "29x29",
77 | "idiom" : "ipad",
78 | "filename" : "Icon-App-29x29@2x.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "40x40",
83 | "idiom" : "ipad",
84 | "filename" : "Icon-App-40x40@1x.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "40x40",
89 | "idiom" : "ipad",
90 | "filename" : "Icon-App-40x40@2x.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "76x76",
95 | "idiom" : "ipad",
96 | "filename" : "Icon-App-76x76@1x.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "76x76",
101 | "idiom" : "ipad",
102 | "filename" : "Icon-App-76x76@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "83.5x83.5",
107 | "idiom" : "ipad",
108 | "filename" : "Icon-App-83.5x83.5@2x.png",
109 | "scale" : "2x"
110 | },
111 | {
112 | "size" : "1024x1024",
113 | "idiom" : "ios-marketing",
114 | "filename" : "Icon-App-1024x1024@1x.png",
115 | "scale" : "1x"
116 | }
117 | ],
118 | "info" : {
119 | "version" : 1,
120 | "author" : "xcode"
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchImage.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchImage@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "LaunchImage@3x.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md:
--------------------------------------------------------------------------------
1 | # Launch Screen Assets
2 |
3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory.
4 |
5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
--------------------------------------------------------------------------------
/example/ios/Runner/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/example/ios/Runner/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | example
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | $(FLUTTER_BUILD_NAME)
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(FLUTTER_BUILD_NUMBER)
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UISupportedInterfaceOrientations
30 |
31 | UIInterfaceOrientationPortrait
32 | UIInterfaceOrientationLandscapeLeft
33 | UIInterfaceOrientationLandscapeRight
34 |
35 | UISupportedInterfaceOrientations~ipad
36 |
37 | UIInterfaceOrientationPortrait
38 | UIInterfaceOrientationPortraitUpsideDown
39 | UIInterfaceOrientationLandscapeLeft
40 | UIInterfaceOrientationLandscapeRight
41 |
42 | UIViewControllerBasedStatusBarAppearance
43 |
44 | CADisableMinimumFrameDurationOnPhone
45 |
46 | UIApplicationSupportsIndirectInputEvents
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/example/ios/Runner/Runner-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | #import "GeneratedPluginRegistrant.h"
2 |
--------------------------------------------------------------------------------
/example/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:popover/popover.dart';
3 |
4 | void main() => runApp(PopoverExample());
5 |
6 | class PopoverExample extends StatelessWidget {
7 | @override
8 | Widget build(BuildContext context) {
9 | return MaterialApp(
10 | home: Scaffold(
11 | appBar: AppBar(title: const Text('Popover Example')),
12 | body: const SafeArea(
13 | child: Padding(
14 | padding: EdgeInsets.all(16),
15 | child: Column(
16 | mainAxisAlignment: MainAxisAlignment.spaceBetween,
17 | mainAxisSize: MainAxisSize.max,
18 | children: [
19 | Row(
20 | mainAxisAlignment: MainAxisAlignment.spaceBetween,
21 | mainAxisSize: MainAxisSize.max,
22 | children: [
23 | Button(),
24 | Button(),
25 | Button(),
26 | ],
27 | ),
28 | Row(
29 | mainAxisAlignment: MainAxisAlignment.spaceBetween,
30 | mainAxisSize: MainAxisSize.max,
31 | children: [
32 | Button(),
33 | Button(),
34 | Button(),
35 | ],
36 | ),
37 | Row(
38 | mainAxisAlignment: MainAxisAlignment.spaceBetween,
39 | mainAxisSize: MainAxisSize.max,
40 | children: [
41 | Button(),
42 | Button(),
43 | Button(),
44 | ],
45 | ),
46 | ],
47 | ),
48 | ),
49 | ),
50 | ),
51 | );
52 | }
53 | }
54 |
55 | class Button extends StatelessWidget {
56 | const Button({Key? key}) : super(key: key);
57 |
58 | @override
59 | Widget build(BuildContext context) {
60 | return Container(
61 | width: 80,
62 | height: 40,
63 | decoration: const BoxDecoration(
64 | color: Colors.white,
65 | borderRadius: BorderRadius.all(Radius.circular(5)),
66 | boxShadow: [BoxShadow(color: Colors.black26, blurRadius: 5)],
67 | ),
68 | child: GestureDetector(
69 | child: const Center(child: Text('Click Me')),
70 | onTap: () {
71 | showPopover(
72 | context: context,
73 | bodyBuilder: (context) => const ListItems(),
74 | onPop: () => print('Popover was popped!'),
75 | direction: PopoverDirection.bottom,
76 | backgroundColor: Colors.white,
77 | width: 200,
78 | height: 400,
79 | arrowHeight: 15,
80 | arrowWidth: 30,
81 | );
82 | },
83 | ),
84 | );
85 | }
86 | }
87 |
88 | class ListItems extends StatelessWidget {
89 | const ListItems({Key? key}) : super(key: key);
90 |
91 | @override
92 | Widget build(BuildContext context) {
93 | return Padding(
94 | padding: const EdgeInsets.symmetric(vertical: 8),
95 | child: ListView(
96 | padding: const EdgeInsets.all(8),
97 | children: [
98 | InkWell(
99 | onTap: () {
100 | Navigator.of(context)
101 | ..pop()
102 | ..push(
103 | MaterialPageRoute(
104 | builder: (context) => SecondRoute(),
105 | ),
106 | );
107 | },
108 | child: Container(
109 | height: 50,
110 | color: Colors.amber[100],
111 | child: const Center(child: Text('Entry A')),
112 | ),
113 | ),
114 | const Divider(),
115 | Container(
116 | height: 50,
117 | color: Colors.amber[200],
118 | child: const Center(child: Text('Entry B')),
119 | ),
120 | const Divider(),
121 | Container(
122 | height: 50,
123 | color: Colors.amber[300],
124 | child: const Center(child: Text('Entry C')),
125 | ),
126 | const Divider(),
127 | Container(
128 | height: 50,
129 | color: Colors.amber[400],
130 | child: const Center(child: Text('Entry D')),
131 | ),
132 | const Divider(),
133 | Container(
134 | height: 50,
135 | color: Colors.amber[500],
136 | child: const Center(child: Text('Entry E')),
137 | ),
138 | const Divider(),
139 | Container(
140 | height: 50,
141 | color: Colors.amber[600],
142 | child: const Center(child: Text('Entry F')),
143 | ),
144 | ],
145 | ),
146 | );
147 | }
148 | }
149 |
150 | class SecondRoute extends StatelessWidget {
151 | @override
152 | Widget build(BuildContext context) {
153 | return Scaffold(
154 | appBar: AppBar(
155 | title: const Text('Second Route'),
156 | automaticallyImplyLeading: false,
157 | ),
158 | body: Center(
159 | child: ElevatedButton(
160 | onPressed: () => Navigator.pop(context),
161 | child: const Text('Back'),
162 | ),
163 | ),
164 | );
165 | }
166 | }
167 |
--------------------------------------------------------------------------------
/example/linux/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/ephemeral
2 |
--------------------------------------------------------------------------------
/example/linux/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 | project(runner LANGUAGES CXX)
3 |
4 | set(BINARY_NAME "example")
5 | set(APPLICATION_ID "com.example.example")
6 |
7 | cmake_policy(SET CMP0063 NEW)
8 |
9 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
10 |
11 | # Configure build options.
12 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
13 | set(CMAKE_BUILD_TYPE "Debug" CACHE
14 | STRING "Flutter build mode" FORCE)
15 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
16 | "Debug" "Profile" "Release")
17 | endif()
18 |
19 | # Compilation settings that should be applied to most targets.
20 | function(APPLY_STANDARD_SETTINGS TARGET)
21 | target_compile_features(${TARGET} PUBLIC cxx_std_14)
22 | target_compile_options(${TARGET} PRIVATE -Wall -Werror)
23 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>")
24 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>")
25 | endfunction()
26 |
27 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
28 |
29 | # Flutter library and tool build rules.
30 | add_subdirectory(${FLUTTER_MANAGED_DIR})
31 |
32 | # System-level dependencies.
33 | find_package(PkgConfig REQUIRED)
34 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
35 |
36 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
37 |
38 | # Application build
39 | add_executable(${BINARY_NAME}
40 | "main.cc"
41 | "my_application.cc"
42 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
43 | )
44 | apply_standard_settings(${BINARY_NAME})
45 | target_link_libraries(${BINARY_NAME} PRIVATE flutter)
46 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
47 | add_dependencies(${BINARY_NAME} flutter_assemble)
48 | # Only the install-generated bundle's copy of the executable will launch
49 | # correctly, since the resources must in the right relative locations. To avoid
50 | # people trying to run the unbundled copy, put it in a subdirectory instead of
51 | # the default top-level location.
52 | set_target_properties(${BINARY_NAME}
53 | PROPERTIES
54 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
55 | )
56 |
57 | # Generated plugin build rules, which manage building the plugins and adding
58 | # them to the application.
59 | include(flutter/generated_plugins.cmake)
60 |
61 |
62 | # === Installation ===
63 | # By default, "installing" just makes a relocatable bundle in the build
64 | # directory.
65 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
66 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
67 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
68 | endif()
69 |
70 | # Start with a clean build bundle directory every time.
71 | install(CODE "
72 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
73 | " COMPONENT Runtime)
74 |
75 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
76 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
77 |
78 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
79 | COMPONENT Runtime)
80 |
81 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
82 | COMPONENT Runtime)
83 |
84 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
85 | COMPONENT Runtime)
86 |
87 | if(PLUGIN_BUNDLED_LIBRARIES)
88 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
89 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
90 | COMPONENT Runtime)
91 | endif()
92 |
93 | # Fully re-copy the assets directory on each build to avoid having stale files
94 | # from a previous install.
95 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
96 | install(CODE "
97 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
98 | " COMPONENT Runtime)
99 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
100 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
101 |
102 | # Install the AOT library on non-Debug builds only.
103 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
104 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
105 | COMPONENT Runtime)
106 | endif()
107 |
--------------------------------------------------------------------------------
/example/linux/flutter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 |
3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
4 |
5 | # Configuration provided via flutter tool.
6 | include(${EPHEMERAL_DIR}/generated_config.cmake)
7 |
8 | # TODO: Move the rest of this into files in ephemeral. See
9 | # https://github.com/flutter/flutter/issues/57146.
10 |
11 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...),
12 | # which isn't available in 3.10.
13 | function(list_prepend LIST_NAME PREFIX)
14 | set(NEW_LIST "")
15 | foreach(element ${${LIST_NAME}})
16 | list(APPEND NEW_LIST "${PREFIX}${element}")
17 | endforeach(element)
18 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
19 | endfunction()
20 |
21 | # === Flutter Library ===
22 | # System-level dependencies.
23 | find_package(PkgConfig REQUIRED)
24 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
25 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
26 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
27 | pkg_check_modules(BLKID REQUIRED IMPORTED_TARGET blkid)
28 | pkg_check_modules(LZMA REQUIRED IMPORTED_TARGET liblzma)
29 |
30 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
31 |
32 | # Published to parent scope for install step.
33 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
34 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
35 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
36 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
37 |
38 | list(APPEND FLUTTER_LIBRARY_HEADERS
39 | "fl_basic_message_channel.h"
40 | "fl_binary_codec.h"
41 | "fl_binary_messenger.h"
42 | "fl_dart_project.h"
43 | "fl_engine.h"
44 | "fl_json_message_codec.h"
45 | "fl_json_method_codec.h"
46 | "fl_message_codec.h"
47 | "fl_method_call.h"
48 | "fl_method_channel.h"
49 | "fl_method_codec.h"
50 | "fl_method_response.h"
51 | "fl_plugin_registrar.h"
52 | "fl_plugin_registry.h"
53 | "fl_standard_message_codec.h"
54 | "fl_standard_method_codec.h"
55 | "fl_string_codec.h"
56 | "fl_value.h"
57 | "fl_view.h"
58 | "flutter_linux.h"
59 | )
60 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
61 | add_library(flutter INTERFACE)
62 | target_include_directories(flutter INTERFACE
63 | "${EPHEMERAL_DIR}"
64 | )
65 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
66 | target_link_libraries(flutter INTERFACE
67 | PkgConfig::GTK
68 | PkgConfig::GLIB
69 | PkgConfig::GIO
70 | PkgConfig::BLKID
71 | PkgConfig::LZMA
72 | )
73 | add_dependencies(flutter flutter_assemble)
74 |
75 | # === Flutter tool backend ===
76 | # _phony_ is a non-existent file to force this command to run every time,
77 | # since currently there's no way to get a full input/output list from the
78 | # flutter tool.
79 | add_custom_command(
80 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
81 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_
82 | COMMAND ${CMAKE_COMMAND} -E env
83 | ${FLUTTER_TOOL_ENVIRONMENT}
84 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
85 | linux-x64 ${CMAKE_BUILD_TYPE}
86 | VERBATIM
87 | )
88 | add_custom_target(flutter_assemble DEPENDS
89 | "${FLUTTER_LIBRARY}"
90 | ${FLUTTER_LIBRARY_HEADERS}
91 | )
92 |
--------------------------------------------------------------------------------
/example/linux/flutter/generated_plugin_registrant.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #include "generated_plugin_registrant.h"
8 |
9 |
10 | void fl_register_plugins(FlPluginRegistry* registry) {
11 | }
12 |
--------------------------------------------------------------------------------
/example/linux/flutter/generated_plugin_registrant.h:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #ifndef GENERATED_PLUGIN_REGISTRANT_
8 | #define GENERATED_PLUGIN_REGISTRANT_
9 |
10 | #include
11 |
12 | // Registers Flutter plugins.
13 | void fl_register_plugins(FlPluginRegistry* registry);
14 |
15 | #endif // GENERATED_PLUGIN_REGISTRANT_
16 |
--------------------------------------------------------------------------------
/example/linux/flutter/generated_plugins.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Generated file, do not edit.
3 | #
4 |
5 | list(APPEND FLUTTER_PLUGIN_LIST
6 | )
7 |
8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST
9 | )
10 |
11 | set(PLUGIN_BUNDLED_LIBRARIES)
12 |
13 | foreach(plugin ${FLUTTER_PLUGIN_LIST})
14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
18 | endforeach(plugin)
19 |
20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
23 | endforeach(ffi_plugin)
24 |
--------------------------------------------------------------------------------
/example/linux/main.cc:
--------------------------------------------------------------------------------
1 | #include "my_application.h"
2 |
3 | int main(int argc, char** argv) {
4 | g_autoptr(MyApplication) app = my_application_new();
5 | return g_application_run(G_APPLICATION(app), argc, argv);
6 | }
7 |
--------------------------------------------------------------------------------
/example/linux/my_application.cc:
--------------------------------------------------------------------------------
1 | #include "my_application.h"
2 |
3 | #include
4 | #ifdef GDK_WINDOWING_X11
5 | #include
6 | #endif
7 |
8 | #include "flutter/generated_plugin_registrant.h"
9 |
10 | struct _MyApplication {
11 | GtkApplication parent_instance;
12 | char** dart_entrypoint_arguments;
13 | };
14 |
15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
16 |
17 | // Implements GApplication::activate.
18 | static void my_application_activate(GApplication* application) {
19 | MyApplication* self = MY_APPLICATION(application);
20 | GtkWindow* window =
21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
22 |
23 | // Use a header bar when running in GNOME as this is the common style used
24 | // by applications and is the setup most users will be using (e.g. Ubuntu
25 | // desktop).
26 | // If running on X and not using GNOME then just use a traditional title bar
27 | // in case the window manager does more exotic layout, e.g. tiling.
28 | // If running on Wayland assume the header bar will work (may need changing
29 | // if future cases occur).
30 | gboolean use_header_bar = TRUE;
31 | #ifdef GDK_WINDOWING_X11
32 | GdkScreen *screen = gtk_window_get_screen(window);
33 | if (GDK_IS_X11_SCREEN(screen)) {
34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
36 | use_header_bar = FALSE;
37 | }
38 | }
39 | #endif
40 | if (use_header_bar) {
41 | GtkHeaderBar *header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
42 | gtk_widget_show(GTK_WIDGET(header_bar));
43 | gtk_header_bar_set_title(header_bar, "example");
44 | gtk_header_bar_set_show_close_button(header_bar, TRUE);
45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
46 | }
47 | else {
48 | gtk_window_set_title(window, "example");
49 | }
50 |
51 | gtk_window_set_default_size(window, 1280, 720);
52 | gtk_widget_show(GTK_WIDGET(window));
53 |
54 | g_autoptr(FlDartProject) project = fl_dart_project_new();
55 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
56 |
57 | FlView* view = fl_view_new(project);
58 | gtk_widget_show(GTK_WIDGET(view));
59 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
60 |
61 | fl_register_plugins(FL_PLUGIN_REGISTRY(view));
62 |
63 | gtk_widget_grab_focus(GTK_WIDGET(view));
64 | }
65 |
66 | // Implements GApplication::local_command_line.
67 | static gboolean my_application_local_command_line(GApplication* application, gchar ***arguments, int *exit_status) {
68 | MyApplication* self = MY_APPLICATION(application);
69 | // Strip out the first argument as it is the binary name.
70 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1);
71 |
72 | g_autoptr(GError) error = nullptr;
73 | if (!g_application_register(application, nullptr, &error)) {
74 | g_warning("Failed to register: %s", error->message);
75 | *exit_status = 1;
76 | return TRUE;
77 | }
78 |
79 | g_application_activate(application);
80 | *exit_status = 0;
81 |
82 | return TRUE;
83 | }
84 |
85 | // Implements GObject::dispose.
86 | static void my_application_dispose(GObject *object) {
87 | MyApplication* self = MY_APPLICATION(object);
88 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev);
89 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object);
90 | }
91 |
92 | static void my_application_class_init(MyApplicationClass* klass) {
93 | G_APPLICATION_CLASS(klass)->activate = my_application_activate;
94 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line;
95 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
96 | }
97 |
98 | static void my_application_init(MyApplication* self) {}
99 |
100 | MyApplication* my_application_new() {
101 | return MY_APPLICATION(g_object_new(my_application_get_type(),
102 | "application-id", APPLICATION_ID,
103 | nullptr));
104 | }
105 |
--------------------------------------------------------------------------------
/example/linux/my_application.h:
--------------------------------------------------------------------------------
1 | #ifndef FLUTTER_MY_APPLICATION_H_
2 | #define FLUTTER_MY_APPLICATION_H_
3 |
4 | #include
5 |
6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION,
7 | GtkApplication)
8 |
9 | /**
10 | * my_application_new:
11 | *
12 | * Creates a new Flutter-based application.
13 | *
14 | * Returns: a new #MyApplication.
15 | */
16 | MyApplication* my_application_new();
17 |
18 | #endif // FLUTTER_MY_APPLICATION_H_
19 |
--------------------------------------------------------------------------------
/example/macos/.gitignore:
--------------------------------------------------------------------------------
1 | # Flutter-related
2 | **/Flutter/ephemeral/
3 | **/Pods/
4 |
5 | # Xcode-related
6 | **/dgph
7 | **/xcuserdata/
8 |
--------------------------------------------------------------------------------
/example/macos/Flutter/Flutter-Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "ephemeral/Flutter-Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/example/macos/Flutter/Flutter-Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "ephemeral/Flutter-Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/example/macos/Flutter/GeneratedPluginRegistrant.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | import FlutterMacOS
6 | import Foundation
7 |
8 |
9 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
10 | }
11 |
--------------------------------------------------------------------------------
/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
37 |
38 |
39 |
40 |
43 |
49 |
50 |
51 |
52 |
53 |
63 |
65 |
71 |
72 |
73 |
74 |
80 |
82 |
88 |
89 |
90 |
91 |
93 |
94 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/example/macos/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/macos/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 |
4 | @main
5 | class AppDelegate: FlutterAppDelegate {
6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
7 | return true
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "16x16",
5 | "idiom" : "mac",
6 | "filename" : "app_icon_16.png",
7 | "scale" : "1x"
8 | },
9 | {
10 | "size" : "16x16",
11 | "idiom" : "mac",
12 | "filename" : "app_icon_32.png",
13 | "scale" : "2x"
14 | },
15 | {
16 | "size" : "32x32",
17 | "idiom" : "mac",
18 | "filename" : "app_icon_32.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "32x32",
23 | "idiom" : "mac",
24 | "filename" : "app_icon_64.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "128x128",
29 | "idiom" : "mac",
30 | "filename" : "app_icon_128.png",
31 | "scale" : "1x"
32 | },
33 | {
34 | "size" : "128x128",
35 | "idiom" : "mac",
36 | "filename" : "app_icon_256.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "256x256",
41 | "idiom" : "mac",
42 | "filename" : "app_icon_256.png",
43 | "scale" : "1x"
44 | },
45 | {
46 | "size" : "256x256",
47 | "idiom" : "mac",
48 | "filename" : "app_icon_512.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "512x512",
53 | "idiom" : "mac",
54 | "filename" : "app_icon_512.png",
55 | "scale" : "1x"
56 | },
57 | {
58 | "size" : "512x512",
59 | "idiom" : "mac",
60 | "filename" : "app_icon_1024.png",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png
--------------------------------------------------------------------------------
/example/macos/Runner/Configs/AppInfo.xcconfig:
--------------------------------------------------------------------------------
1 | // Application-level settings for the Runner target.
2 | //
3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the
4 | // future. If not, the values below would default to using the project name when this becomes a
5 | // 'flutter create' template.
6 |
7 | // The application's name. By default this is also the title of the Flutter window.
8 | PRODUCT_NAME = example
9 |
10 | // The application's bundle identifier
11 | PRODUCT_BUNDLE_IDENTIFIER = me.minikin.example
12 |
13 | // The copyright displayed in application information
14 | PRODUCT_COPYRIGHT = Copyright © 2023 me.minikin. All rights reserved.
15 |
--------------------------------------------------------------------------------
/example/macos/Runner/Configs/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "../../Flutter/Flutter-Debug.xcconfig"
2 | #include "Warnings.xcconfig"
3 |
--------------------------------------------------------------------------------
/example/macos/Runner/Configs/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "../../Flutter/Flutter-Release.xcconfig"
2 | #include "Warnings.xcconfig"
3 |
--------------------------------------------------------------------------------
/example/macos/Runner/Configs/Warnings.xcconfig:
--------------------------------------------------------------------------------
1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings
2 | GCC_WARN_UNDECLARED_SELECTOR = YES
3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES
4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE
5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
6 | CLANG_WARN_PRAGMA_PACK = YES
7 | CLANG_WARN_STRICT_PROTOTYPES = YES
8 | CLANG_WARN_COMMA = YES
9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES
10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
12 | GCC_WARN_SHADOW = YES
13 | CLANG_WARN_UNREACHABLE_CODE = YES
14 |
--------------------------------------------------------------------------------
/example/macos/Runner/DebugProfile.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 | com.apple.security.cs.allow-jit
8 |
9 | com.apple.security.network.server
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/example/macos/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | $(FLUTTER_BUILD_NAME)
21 | CFBundleVersion
22 | $(FLUTTER_BUILD_NUMBER)
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | $(PRODUCT_COPYRIGHT)
27 | NSMainNibFile
28 | MainMenu
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/example/macos/Runner/MainFlutterWindow.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 |
4 | class MainFlutterWindow: NSWindow {
5 | override func awakeFromNib() {
6 | let flutterViewController = FlutterViewController()
7 | let windowFrame = self.frame
8 | self.contentViewController = flutterViewController
9 | self.setFrame(windowFrame, display: true)
10 |
11 | RegisterGeneratedPlugins(registry: flutterViewController)
12 |
13 | super.awakeFromNib()
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/example/macos/Runner/Release.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/macos/RunnerTests/RunnerTests.swift:
--------------------------------------------------------------------------------
1 | import FlutterMacOS
2 | import Cocoa
3 | import XCTest
4 |
5 | class RunnerTests: XCTestCase {
6 |
7 | func testExample() {
8 | // If you add code to the Runner application, consider adding tests here.
9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest.
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/example/pubspec.lock:
--------------------------------------------------------------------------------
1 | # Generated by pub
2 | # See https://dart.dev/tools/pub/glossary#lockfile
3 | packages:
4 | async:
5 | dependency: transitive
6 | description:
7 | name: async
8 | sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
9 | url: "https://pub.dev"
10 | source: hosted
11 | version: "2.11.0"
12 | boolean_selector:
13 | dependency: transitive
14 | description:
15 | name: boolean_selector
16 | sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
17 | url: "https://pub.dev"
18 | source: hosted
19 | version: "2.1.1"
20 | characters:
21 | dependency: transitive
22 | description:
23 | name: characters
24 | sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
25 | url: "https://pub.dev"
26 | source: hosted
27 | version: "1.3.0"
28 | clock:
29 | dependency: transitive
30 | description:
31 | name: clock
32 | sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
33 | url: "https://pub.dev"
34 | source: hosted
35 | version: "1.1.1"
36 | collection:
37 | dependency: transitive
38 | description:
39 | name: collection
40 | sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
41 | url: "https://pub.dev"
42 | source: hosted
43 | version: "1.18.0"
44 | fake_async:
45 | dependency: transitive
46 | description:
47 | name: fake_async
48 | sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
49 | url: "https://pub.dev"
50 | source: hosted
51 | version: "1.3.1"
52 | flutter:
53 | dependency: "direct main"
54 | description: flutter
55 | source: sdk
56 | version: "0.0.0"
57 | flutter_test:
58 | dependency: "direct dev"
59 | description: flutter
60 | source: sdk
61 | version: "0.0.0"
62 | leak_tracker:
63 | dependency: transitive
64 | description:
65 | name: leak_tracker
66 | sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
67 | url: "https://pub.dev"
68 | source: hosted
69 | version: "10.0.5"
70 | leak_tracker_flutter_testing:
71 | dependency: transitive
72 | description:
73 | name: leak_tracker_flutter_testing
74 | sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
75 | url: "https://pub.dev"
76 | source: hosted
77 | version: "3.0.5"
78 | leak_tracker_testing:
79 | dependency: transitive
80 | description:
81 | name: leak_tracker_testing
82 | sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
83 | url: "https://pub.dev"
84 | source: hosted
85 | version: "3.0.1"
86 | matcher:
87 | dependency: transitive
88 | description:
89 | name: matcher
90 | sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
91 | url: "https://pub.dev"
92 | source: hosted
93 | version: "0.12.16+1"
94 | material_color_utilities:
95 | dependency: transitive
96 | description:
97 | name: material_color_utilities
98 | sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
99 | url: "https://pub.dev"
100 | source: hosted
101 | version: "0.11.1"
102 | meta:
103 | dependency: transitive
104 | description:
105 | name: meta
106 | sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
107 | url: "https://pub.dev"
108 | source: hosted
109 | version: "1.15.0"
110 | path:
111 | dependency: transitive
112 | description:
113 | name: path
114 | sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
115 | url: "https://pub.dev"
116 | source: hosted
117 | version: "1.9.0"
118 | popover:
119 | dependency: "direct main"
120 | description:
121 | path: ".."
122 | relative: true
123 | source: path
124 | version: "0.3.1"
125 | sky_engine:
126 | dependency: transitive
127 | description: flutter
128 | source: sdk
129 | version: "0.0.99"
130 | source_span:
131 | dependency: transitive
132 | description:
133 | name: source_span
134 | sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
135 | url: "https://pub.dev"
136 | source: hosted
137 | version: "1.10.0"
138 | stack_trace:
139 | dependency: transitive
140 | description:
141 | name: stack_trace
142 | sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
143 | url: "https://pub.dev"
144 | source: hosted
145 | version: "1.11.1"
146 | stream_channel:
147 | dependency: transitive
148 | description:
149 | name: stream_channel
150 | sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
151 | url: "https://pub.dev"
152 | source: hosted
153 | version: "2.1.2"
154 | string_scanner:
155 | dependency: transitive
156 | description:
157 | name: string_scanner
158 | sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
159 | url: "https://pub.dev"
160 | source: hosted
161 | version: "1.2.0"
162 | term_glyph:
163 | dependency: transitive
164 | description:
165 | name: term_glyph
166 | sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
167 | url: "https://pub.dev"
168 | source: hosted
169 | version: "1.2.1"
170 | test_api:
171 | dependency: transitive
172 | description:
173 | name: test_api
174 | sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
175 | url: "https://pub.dev"
176 | source: hosted
177 | version: "0.7.2"
178 | vector_math:
179 | dependency: transitive
180 | description:
181 | name: vector_math
182 | sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
183 | url: "https://pub.dev"
184 | source: hosted
185 | version: "2.1.4"
186 | vm_service:
187 | dependency: transitive
188 | description:
189 | name: vm_service
190 | sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
191 | url: "https://pub.dev"
192 | source: hosted
193 | version: "14.2.5"
194 | sdks:
195 | dart: ">=3.5.0 <4.0.0"
196 | flutter: ">=3.24.0"
197 |
--------------------------------------------------------------------------------
/example/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: popover_example
2 | description: Popover Example.
3 | version: 0.1.0
4 | publish_to: none
5 |
6 | environment:
7 | sdk: '>=3.5.0 <4.0.0'
8 | flutter: '>=3.24.0'
9 |
10 | dependencies:
11 | flutter:
12 | sdk: flutter
13 |
14 | popover:
15 | path: ../
16 |
17 | dev_dependencies:
18 | flutter_test:
19 | sdk: flutter
20 |
--------------------------------------------------------------------------------
/example/test/widget_test.dart:
--------------------------------------------------------------------------------
1 | void main() {}
2 |
--------------------------------------------------------------------------------
/example/web/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/web/favicon.png
--------------------------------------------------------------------------------
/example/web/icons/Icon-192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/web/icons/Icon-192.png
--------------------------------------------------------------------------------
/example/web/icons/Icon-512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/web/icons/Icon-512.png
--------------------------------------------------------------------------------
/example/web/icons/Icon-maskable-192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/web/icons/Icon-maskable-192.png
--------------------------------------------------------------------------------
/example/web/icons/Icon-maskable-512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/web/icons/Icon-maskable-512.png
--------------------------------------------------------------------------------
/example/web/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | example
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/example/web/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example",
3 | "short_name": "example",
4 | "start_url": ".",
5 | "display": "standalone",
6 | "background_color": "#0175C2",
7 | "theme_color": "#0175C2",
8 | "description": "A new Flutter project.",
9 | "orientation": "portrait-primary",
10 | "prefer_related_applications": false,
11 | "icons": [
12 | {
13 | "src": "icons/Icon-192.png",
14 | "sizes": "192x192",
15 | "type": "image/png"
16 | },
17 | {
18 | "src": "icons/Icon-512.png",
19 | "sizes": "512x512",
20 | "type": "image/png"
21 | },
22 | {
23 | "src": "icons/Icon-maskable-192.png",
24 | "sizes": "192x192",
25 | "type": "image/png",
26 | "purpose": "maskable"
27 | },
28 | {
29 | "src": "icons/Icon-maskable-512.png",
30 | "sizes": "512x512",
31 | "type": "image/png",
32 | "purpose": "maskable"
33 | }
34 | ]
35 | }
36 |
--------------------------------------------------------------------------------
/example/windows/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/ephemeral/
2 |
3 | # Visual Studio user-specific files.
4 | *.suo
5 | *.user
6 | *.userosscache
7 | *.sln.docstates
8 |
9 | # Visual Studio build-related files.
10 | x64/
11 | x86/
12 |
13 | # Visual Studio cache files
14 | # files ending in .cache can be ignored
15 | *.[Cc]ache
16 | # but keep track of directories ending in .cache
17 | !*.[Cc]ache/
18 |
--------------------------------------------------------------------------------
/example/windows/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.15)
2 | project(example LANGUAGES CXX)
3 |
4 | set(BINARY_NAME "example")
5 |
6 | cmake_policy(SET CMP0063 NEW)
7 |
8 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
9 |
10 | # Configure build options.
11 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
12 | if(IS_MULTICONFIG)
13 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
14 | CACHE STRING "" FORCE)
15 | else()
16 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
17 | set(CMAKE_BUILD_TYPE "Debug" CACHE
18 | STRING "Flutter build mode" FORCE)
19 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
20 | "Debug" "Profile" "Release")
21 | endif()
22 | endif()
23 |
24 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
25 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
26 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
27 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")
28 |
29 | # Use Unicode for all projects.
30 | add_definitions(-DUNICODE -D_UNICODE)
31 |
32 | # Compilation settings that should be applied to most targets.
33 | function(APPLY_STANDARD_SETTINGS TARGET)
34 | target_compile_features(${TARGET} PUBLIC cxx_std_17)
35 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
36 | target_compile_options(${TARGET} PRIVATE /EHsc)
37 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
38 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>")
39 | endfunction()
40 |
41 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
42 |
43 | # Flutter library and tool build rules.
44 | add_subdirectory(${FLUTTER_MANAGED_DIR})
45 |
46 | # Application build
47 | add_subdirectory("runner")
48 |
49 | # Generated plugin build rules, which manage building the plugins and adding
50 | # them to the application.
51 | include(flutter/generated_plugins.cmake)
52 |
53 |
54 | # === Installation ===
55 | # Support files are copied into place next to the executable, so that it can
56 | # run in place. This is done instead of making a separate bundle (as on Linux)
57 | # so that building and running from within Visual Studio will work.
58 | set(BUILD_BUNDLE_DIR "$")
59 | # Make the "install" step default, as it's required to run.
60 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
61 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
62 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
63 | endif()
64 |
65 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
66 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")
67 |
68 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
69 | COMPONENT Runtime)
70 |
71 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
72 | COMPONENT Runtime)
73 |
74 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
75 | COMPONENT Runtime)
76 |
77 | if(PLUGIN_BUNDLED_LIBRARIES)
78 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
79 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
80 | COMPONENT Runtime)
81 | endif()
82 |
83 | # Fully re-copy the assets directory on each build to avoid having stale files
84 | # from a previous install.
85 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
86 | install(CODE "
87 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
88 | " COMPONENT Runtime)
89 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
90 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
91 |
92 | # Install the AOT library on non-Debug builds only.
93 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
94 | CONFIGURATIONS Profile;Release
95 | COMPONENT Runtime)
96 |
--------------------------------------------------------------------------------
/example/windows/flutter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.15)
2 |
3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
4 |
5 | # Configuration provided via flutter tool.
6 | include(${EPHEMERAL_DIR}/generated_config.cmake)
7 |
8 | # TODO: Move the rest of this into files in ephemeral. See
9 | # https://github.com/flutter/flutter/issues/57146.
10 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
11 |
12 | # === Flutter Library ===
13 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
14 |
15 | # Published to parent scope for install step.
16 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
17 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
18 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
19 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE)
20 |
21 | list(APPEND FLUTTER_LIBRARY_HEADERS
22 | "flutter_export.h"
23 | "flutter_windows.h"
24 | "flutter_messenger.h"
25 | "flutter_plugin_registrar.h"
26 | "flutter_texture_registrar.h"
27 | )
28 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/")
29 | add_library(flutter INTERFACE)
30 | target_include_directories(flutter INTERFACE
31 | "${EPHEMERAL_DIR}"
32 | )
33 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib")
34 | add_dependencies(flutter flutter_assemble)
35 |
36 | # === Wrapper ===
37 | list(APPEND CPP_WRAPPER_SOURCES_CORE
38 | "core_implementations.cc"
39 | "standard_codec.cc"
40 | )
41 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/")
42 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN
43 | "plugin_registrar.cc"
44 | )
45 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/")
46 | list(APPEND CPP_WRAPPER_SOURCES_APP
47 | "flutter_engine.cc"
48 | "flutter_view_controller.cc"
49 | )
50 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/")
51 |
52 | # Wrapper sources needed for a plugin.
53 | add_library(flutter_wrapper_plugin STATIC
54 | ${CPP_WRAPPER_SOURCES_CORE}
55 | ${CPP_WRAPPER_SOURCES_PLUGIN}
56 | )
57 | apply_standard_settings(flutter_wrapper_plugin)
58 | set_target_properties(flutter_wrapper_plugin PROPERTIES
59 | POSITION_INDEPENDENT_CODE ON)
60 | set_target_properties(flutter_wrapper_plugin PROPERTIES
61 | CXX_VISIBILITY_PRESET hidden)
62 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter)
63 | target_include_directories(flutter_wrapper_plugin PUBLIC
64 | "${WRAPPER_ROOT}/include"
65 | )
66 | add_dependencies(flutter_wrapper_plugin flutter_assemble)
67 |
68 | # Wrapper sources needed for the runner.
69 | add_library(flutter_wrapper_app STATIC
70 | ${CPP_WRAPPER_SOURCES_CORE}
71 | ${CPP_WRAPPER_SOURCES_APP}
72 | )
73 | apply_standard_settings(flutter_wrapper_app)
74 | target_link_libraries(flutter_wrapper_app PUBLIC flutter)
75 | target_include_directories(flutter_wrapper_app PUBLIC
76 | "${WRAPPER_ROOT}/include"
77 | )
78 | add_dependencies(flutter_wrapper_app flutter_assemble)
79 |
80 | # === Flutter tool backend ===
81 | # _phony_ is a non-existent file to force this command to run every time,
82 | # since currently there's no way to get a full input/output list from the
83 | # flutter tool.
84 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_")
85 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE)
86 | add_custom_command(
87 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
88 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN}
89 | ${CPP_WRAPPER_SOURCES_APP}
90 | ${PHONY_OUTPUT}
91 | COMMAND ${CMAKE_COMMAND} -E env
92 | ${FLUTTER_TOOL_ENVIRONMENT}
93 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
94 | windows-x64 $
95 | VERBATIM
96 | )
97 | add_custom_target(flutter_assemble DEPENDS
98 | "${FLUTTER_LIBRARY}"
99 | ${FLUTTER_LIBRARY_HEADERS}
100 | ${CPP_WRAPPER_SOURCES_CORE}
101 | ${CPP_WRAPPER_SOURCES_PLUGIN}
102 | ${CPP_WRAPPER_SOURCES_APP}
103 | )
104 |
--------------------------------------------------------------------------------
/example/windows/flutter/generated_plugin_registrant.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #include "generated_plugin_registrant.h"
8 |
9 |
10 | void RegisterPlugins(flutter::PluginRegistry* registry) {
11 | }
12 |
--------------------------------------------------------------------------------
/example/windows/flutter/generated_plugin_registrant.h:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #ifndef GENERATED_PLUGIN_REGISTRANT_
8 | #define GENERATED_PLUGIN_REGISTRANT_
9 |
10 | #include
11 |
12 | // Registers Flutter plugins.
13 | void RegisterPlugins(flutter::PluginRegistry* registry);
14 |
15 | #endif // GENERATED_PLUGIN_REGISTRANT_
16 |
--------------------------------------------------------------------------------
/example/windows/flutter/generated_plugins.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Generated file, do not edit.
3 | #
4 |
5 | list(APPEND FLUTTER_PLUGIN_LIST
6 | )
7 |
8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST
9 | )
10 |
11 | set(PLUGIN_BUNDLED_LIBRARIES)
12 |
13 | foreach(plugin ${FLUTTER_PLUGIN_LIST})
14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin})
15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
18 | endforeach(plugin)
19 |
20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
23 | endforeach(ffi_plugin)
24 |
--------------------------------------------------------------------------------
/example/windows/runner/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.15)
2 | project(runner LANGUAGES CXX)
3 |
4 | add_executable(${BINARY_NAME} WIN32
5 | "flutter_window.cpp"
6 | "main.cpp"
7 | "run_loop.cpp"
8 | "utils.cpp"
9 | "win32_window.cpp"
10 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
11 | "Runner.rc"
12 | "runner.exe.manifest"
13 | )
14 | apply_standard_settings(${BINARY_NAME})
15 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
16 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
17 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
18 | add_dependencies(${BINARY_NAME} flutter_assemble)
19 |
--------------------------------------------------------------------------------
/example/windows/runner/Runner.rc:
--------------------------------------------------------------------------------
1 | // Microsoft Visual C++ generated resource script.
2 | //
3 | #pragma code_page(65001)
4 | #include "resource.h"
5 |
6 | #define APSTUDIO_READONLY_SYMBOLS
7 | /////////////////////////////////////////////////////////////////////////////
8 | //
9 | // Generated from the TEXTINCLUDE 2 resource.
10 | //
11 | #include "winres.h"
12 |
13 | /////////////////////////////////////////////////////////////////////////////
14 | #undef APSTUDIO_READONLY_SYMBOLS
15 |
16 | /////////////////////////////////////////////////////////////////////////////
17 | // English (United States) resources
18 |
19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
21 |
22 | #ifdef APSTUDIO_INVOKED
23 | /////////////////////////////////////////////////////////////////////////////
24 | //
25 | // TEXTINCLUDE
26 | //
27 |
28 | 1 TEXTINCLUDE
29 | BEGIN
30 | "resource.h\0"
31 | END
32 |
33 | 2 TEXTINCLUDE
34 | BEGIN
35 | "#include ""winres.h""\r\n"
36 | "\0"
37 | END
38 |
39 | 3 TEXTINCLUDE
40 | BEGIN
41 | "\r\n"
42 | "\0"
43 | END
44 |
45 | #endif // APSTUDIO_INVOKED
46 |
47 |
48 | /////////////////////////////////////////////////////////////////////////////
49 | //
50 | // Icon
51 | //
52 |
53 | // Icon with lowest ID value placed first to ensure application icon
54 | // remains consistent on all systems.
55 | IDI_APP_ICON ICON "resources\\app_icon.ico"
56 |
57 |
58 | /////////////////////////////////////////////////////////////////////////////
59 | //
60 | // Version
61 | //
62 |
63 | #ifdef FLUTTER_BUILD_NUMBER
64 | #define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER
65 | #else
66 | #define VERSION_AS_NUMBER 1,0,0
67 | #endif
68 |
69 | #ifdef FLUTTER_BUILD_NAME
70 | #define VERSION_AS_STRING #FLUTTER_BUILD_NAME
71 | #else
72 | #define VERSION_AS_STRING "1.0.0"
73 | #endif
74 |
75 | VS_VERSION_INFO VERSIONINFO
76 | FILEVERSION VERSION_AS_NUMBER
77 | PRODUCTVERSION VERSION_AS_NUMBER
78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
79 | #ifdef _DEBUG
80 | FILEFLAGS VS_FF_DEBUG
81 | #else
82 | FILEFLAGS 0x0L
83 | #endif
84 | FILEOS VOS__WINDOWS32
85 | FILETYPE VFT_APP
86 | FILESUBTYPE 0x0L
87 | BEGIN
88 | BLOCK "StringFileInfo"
89 | BEGIN
90 | BLOCK "040904e4"
91 | BEGIN
92 | VALUE "CompanyName", "com.example" "\0"
93 | VALUE "FileDescription", "A new Flutter project." "\0"
94 | VALUE "FileVersion", VERSION_AS_STRING "\0"
95 | VALUE "InternalName", "example" "\0"
96 | VALUE "LegalCopyright", "Copyright (C) 2021 com.example. All rights reserved." "\0"
97 | VALUE "OriginalFilename", "example.exe" "\0"
98 | VALUE "ProductName", "example" "\0"
99 | VALUE "ProductVersion", VERSION_AS_STRING "\0"
100 | END
101 | END
102 | BLOCK "VarFileInfo"
103 | BEGIN
104 | VALUE "Translation", 0x409, 1252
105 | END
106 | END
107 |
108 | #endif // English (United States) resources
109 | /////////////////////////////////////////////////////////////////////////////
110 |
111 |
112 |
113 | #ifndef APSTUDIO_INVOKED
114 | /////////////////////////////////////////////////////////////////////////////
115 | //
116 | // Generated from the TEXTINCLUDE 3 resource.
117 | //
118 |
119 |
120 | /////////////////////////////////////////////////////////////////////////////
121 | #endif // not APSTUDIO_INVOKED
122 |
--------------------------------------------------------------------------------
/example/windows/runner/flutter_window.cpp:
--------------------------------------------------------------------------------
1 | #include "flutter_window.h"
2 |
3 | #include
4 |
5 | #include "flutter/generated_plugin_registrant.h"
6 |
7 | FlutterWindow::FlutterWindow(RunLoop* run_loop,
8 | const flutter::DartProject& project)
9 | : run_loop_(run_loop), project_(project) {}
10 |
11 | FlutterWindow::~FlutterWindow() {}
12 |
13 | bool FlutterWindow::OnCreate() {
14 | if (!Win32Window::OnCreate()) {
15 | return false;
16 | }
17 |
18 | RECT frame = GetClientArea();
19 |
20 | // The size here must match the window dimensions to avoid unnecessary surface
21 | // creation / destruction in the startup path.
22 | flutter_controller_ = std::make_unique(
23 | frame.right - frame.left, frame.bottom - frame.top, project_);
24 | // Ensure that basic setup of the controller was successful.
25 | if (!flutter_controller_->engine() || !flutter_controller_->view()) {
26 | return false;
27 | }
28 | RegisterPlugins(flutter_controller_->engine());
29 | run_loop_->RegisterFlutterInstance(flutter_controller_->engine());
30 | SetChildContent(flutter_controller_->view()->GetNativeWindow());
31 | return true;
32 | }
33 |
34 | void FlutterWindow::OnDestroy() {
35 | if (flutter_controller_) {
36 | run_loop_->UnregisterFlutterInstance(flutter_controller_->engine());
37 | flutter_controller_ = nullptr;
38 | }
39 |
40 | Win32Window::OnDestroy();
41 | }
42 |
43 | LRESULT
44 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
45 | WPARAM const wparam,
46 | LPARAM const lparam) noexcept {
47 | // Give Flutter, including plugins, an opporutunity to handle window messages.
48 | if (flutter_controller_) {
49 | std::optional result =
50 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam,
51 | lparam);
52 | if (result) {
53 | return *result;
54 | }
55 | }
56 |
57 | switch (message) {
58 | case WM_FONTCHANGE:
59 | flutter_controller_->engine()->ReloadSystemFonts();
60 | break;
61 | }
62 |
63 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam);
64 | }
65 |
--------------------------------------------------------------------------------
/example/windows/runner/flutter_window.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_FLUTTER_WINDOW_H_
2 | #define RUNNER_FLUTTER_WINDOW_H_
3 |
4 | #include
5 | #include
6 |
7 | #include
8 |
9 | #include "run_loop.h"
10 | #include "win32_window.h"
11 |
12 | // A window that does nothing but host a Flutter view.
13 | class FlutterWindow : public Win32Window {
14 | public:
15 | // Creates a new FlutterWindow driven by the |run_loop|, hosting a
16 | // Flutter view running |project|.
17 | explicit FlutterWindow(RunLoop* run_loop,
18 | const flutter::DartProject& project);
19 | virtual ~FlutterWindow();
20 |
21 | protected:
22 | // Win32Window:
23 | bool OnCreate() override;
24 | void OnDestroy() override;
25 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam,
26 | LPARAM const lparam) noexcept override;
27 |
28 | private:
29 | // The run loop driving events for this window.
30 | RunLoop* run_loop_;
31 |
32 | // The project to run.
33 | flutter::DartProject project_;
34 |
35 | // The Flutter instance hosted by this window.
36 | std::unique_ptr flutter_controller_;
37 | };
38 |
39 | #endif // RUNNER_FLUTTER_WINDOW_H_
40 |
--------------------------------------------------------------------------------
/example/windows/runner/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "flutter_window.h"
6 | #include "run_loop.h"
7 | #include "utils.h"
8 |
9 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
10 | _In_ wchar_t *command_line, _In_ int show_command) {
11 | // Attach to console when present (e.g., 'flutter run') or create a
12 | // new console when running with a debugger.
13 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
14 | CreateAndAttachConsole();
15 | }
16 |
17 | // Initialize COM, so that it is available for use in the library and/or
18 | // plugins.
19 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
20 |
21 | RunLoop run_loop;
22 |
23 | flutter::DartProject project(L"data");
24 |
25 | std::vector command_line_arguments =
26 | GetCommandLineArguments();
27 |
28 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
29 |
30 | FlutterWindow window(&run_loop, project);
31 | Win32Window::Point origin(10, 10);
32 | Win32Window::Size size(1280, 720);
33 | if (!window.CreateAndShow(L"example", origin, size)) {
34 | return EXIT_FAILURE;
35 | }
36 | window.SetQuitOnClose(true);
37 |
38 | run_loop.Run();
39 |
40 | ::CoUninitialize();
41 | return EXIT_SUCCESS;
42 | }
43 |
--------------------------------------------------------------------------------
/example/windows/runner/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by Runner.rc
4 | //
5 | #define IDI_APP_ICON 101
6 |
7 | // Next default values for new objects
8 | //
9 | #ifdef APSTUDIO_INVOKED
10 | #ifndef APSTUDIO_READONLY_SYMBOLS
11 | #define _APS_NEXT_RESOURCE_VALUE 102
12 | #define _APS_NEXT_COMMAND_VALUE 40001
13 | #define _APS_NEXT_CONTROL_VALUE 1001
14 | #define _APS_NEXT_SYMED_VALUE 101
15 | #endif
16 | #endif
17 |
--------------------------------------------------------------------------------
/example/windows/runner/resources/app_icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minikin/popover/1283ecd878db562cc6fd00bb88d65349be8bdff1/example/windows/runner/resources/app_icon.ico
--------------------------------------------------------------------------------
/example/windows/runner/run_loop.cpp:
--------------------------------------------------------------------------------
1 | #include "run_loop.h"
2 |
3 | #include
4 |
5 | #include
6 |
7 | RunLoop::RunLoop() {}
8 |
9 | RunLoop::~RunLoop() {}
10 |
11 | void RunLoop::Run() {
12 | bool keep_running = true;
13 | TimePoint next_flutter_event_time = TimePoint::clock::now();
14 | while (keep_running) {
15 | std::chrono::nanoseconds wait_duration =
16 | std::max(std::chrono::nanoseconds(0),
17 | next_flutter_event_time - TimePoint::clock::now());
18 | ::MsgWaitForMultipleObjects(
19 | 0, nullptr, FALSE, static_cast(wait_duration.count() / 1000),
20 | QS_ALLINPUT);
21 | bool processed_events = false;
22 | MSG message;
23 | // All pending Windows messages must be processed; MsgWaitForMultipleObjects
24 | // won't return again for items left in the queue after PeekMessage.
25 | while (::PeekMessage(&message, nullptr, 0, 0, PM_REMOVE)) {
26 | processed_events = true;
27 | if (message.message == WM_QUIT) {
28 | keep_running = false;
29 | break;
30 | }
31 | ::TranslateMessage(&message);
32 | ::DispatchMessage(&message);
33 | // Allow Flutter to process messages each time a Windows message is
34 | // processed, to prevent starvation.
35 | next_flutter_event_time =
36 | std::min(next_flutter_event_time, ProcessFlutterMessages());
37 | }
38 | // If the PeekMessage loop didn't run, process Flutter messages.
39 | if (!processed_events) {
40 | next_flutter_event_time =
41 | std::min(next_flutter_event_time, ProcessFlutterMessages());
42 | }
43 | }
44 | }
45 |
46 | void RunLoop::RegisterFlutterInstance(
47 | flutter::FlutterEngine* flutter_instance) {
48 | flutter_instances_.insert(flutter_instance);
49 | }
50 |
51 | void RunLoop::UnregisterFlutterInstance(
52 | flutter::FlutterEngine* flutter_instance) {
53 | flutter_instances_.erase(flutter_instance);
54 | }
55 |
56 | RunLoop::TimePoint RunLoop::ProcessFlutterMessages() {
57 | TimePoint next_event_time = TimePoint::max();
58 | for (auto instance : flutter_instances_) {
59 | std::chrono::nanoseconds wait_duration = instance->ProcessMessages();
60 | if (wait_duration != std::chrono::nanoseconds::max()) {
61 | next_event_time =
62 | std::min(next_event_time, TimePoint::clock::now() + wait_duration);
63 | }
64 | }
65 | return next_event_time;
66 | }
67 |
--------------------------------------------------------------------------------
/example/windows/runner/run_loop.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_RUN_LOOP_H_
2 | #define RUNNER_RUN_LOOP_H_
3 |
4 | #include
5 |
6 | #include
7 | #include
8 |
9 | // A runloop that will service events for Flutter instances as well
10 | // as native messages.
11 | class RunLoop {
12 | public:
13 | RunLoop();
14 | ~RunLoop();
15 |
16 | // Prevent copying
17 | RunLoop(RunLoop const&) = delete;
18 | RunLoop& operator=(RunLoop const&) = delete;
19 |
20 | // Runs the run loop until the application quits.
21 | void Run();
22 |
23 | // Registers the given Flutter instance for event servicing.
24 | void RegisterFlutterInstance(
25 | flutter::FlutterEngine* flutter_instance);
26 |
27 | // Unregisters the given Flutter instance from event servicing.
28 | void UnregisterFlutterInstance(
29 | flutter::FlutterEngine* flutter_instance);
30 |
31 | private:
32 | using TimePoint = std::chrono::steady_clock::time_point;
33 |
34 | // Processes all currently pending messages for registered Flutter instances.
35 | TimePoint ProcessFlutterMessages();
36 |
37 | std::set flutter_instances_;
38 | };
39 |
40 | #endif // RUNNER_RUN_LOOP_H_
41 |
--------------------------------------------------------------------------------
/example/windows/runner/runner.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PerMonitorV2
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/example/windows/runner/utils.cpp:
--------------------------------------------------------------------------------
1 | #include "utils.h"
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | #include
9 |
10 | void CreateAndAttachConsole() {
11 | if (::AllocConsole()) {
12 | FILE *unused;
13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
14 | _dup2(_fileno(stdout), 1);
15 | }
16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) {
17 | _dup2(_fileno(stdout), 2);
18 | }
19 | std::ios::sync_with_stdio();
20 | FlutterDesktopResyncOutputStreams();
21 | }
22 | }
23 |
24 | std::vector GetCommandLineArguments() {
25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use.
26 | int argc;
27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
28 | if (argv == nullptr) {
29 | return std::vector();
30 | }
31 |
32 | std::vector command_line_arguments;
33 |
34 | // Skip the first argument as it's the binary name.
35 | for (int i = 1; i < argc; i++) {
36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i]));
37 | }
38 |
39 | ::LocalFree(argv);
40 |
41 | return command_line_arguments;
42 | }
43 |
44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) {
45 | if (utf16_string == nullptr) {
46 | return std::string();
47 | }
48 | int target_length = ::WideCharToMultiByte(
49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
50 | -1, nullptr, 0, nullptr, nullptr);
51 | if (target_length == 0) {
52 | return std::string();
53 | }
54 | std::string utf8_string;
55 | utf8_string.resize(target_length);
56 | int converted_length = ::WideCharToMultiByte(
57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
58 | -1, utf8_string.data(),
59 | target_length, nullptr, nullptr);
60 | if (converted_length == 0) {
61 | return std::string();
62 | }
63 | return utf8_string;
64 | }
65 |
--------------------------------------------------------------------------------
/example/windows/runner/utils.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_UTILS_H_
2 | #define RUNNER_UTILS_H_
3 |
4 | #include
5 | #include
6 |
7 | // Creates a console for the process, and redirects stdout and stderr to
8 | // it for both the runner and the Flutter library.
9 | void CreateAndAttachConsole();
10 |
11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string
12 | // encoded in UTF-8. Returns an empty std::string on failure.
13 | std::string Utf8FromUtf16(const wchar_t* utf16_string);
14 |
15 | // Gets the command line arguments passed in as a std::vector,
16 | // encoded in UTF-8. Returns an empty std::vector on failure.
17 | std::vector GetCommandLineArguments();
18 |
19 | #endif // RUNNER_UTILS_H_
20 |
--------------------------------------------------------------------------------
/example/windows/runner/win32_window.cpp:
--------------------------------------------------------------------------------
1 | #include "win32_window.h"
2 |
3 | #include
4 |
5 | #include "resource.h"
6 |
7 | namespace {
8 |
9 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
10 |
11 | // The number of Win32Window objects that currently exist.
12 | static int g_active_window_count = 0;
13 |
14 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd);
15 |
16 | // Scale helper to convert logical scaler values to physical using passed in
17 | // scale factor
18 | int Scale(int source, double scale_factor) {
19 | return static_cast(source * scale_factor);
20 | }
21 |
22 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module.
23 | // This API is only needed for PerMonitor V1 awareness mode.
24 | void EnableFullDpiSupportIfAvailable(HWND hwnd) {
25 | HMODULE user32_module = LoadLibraryA("User32.dll");
26 | if (!user32_module) {
27 | return;
28 | }
29 | auto enable_non_client_dpi_scaling =
30 | reinterpret_cast(
31 | GetProcAddress(user32_module, "EnableNonClientDpiScaling"));
32 | if (enable_non_client_dpi_scaling != nullptr) {
33 | enable_non_client_dpi_scaling(hwnd);
34 | FreeLibrary(user32_module);
35 | }
36 | }
37 |
38 | } // namespace
39 |
40 | // Manages the Win32Window's window class registration.
41 | class WindowClassRegistrar {
42 | public:
43 | ~WindowClassRegistrar() = default;
44 |
45 | // Returns the singleton registar instance.
46 | static WindowClassRegistrar* GetInstance() {
47 | if (!instance_) {
48 | instance_ = new WindowClassRegistrar();
49 | }
50 | return instance_;
51 | }
52 |
53 | // Returns the name of the window class, registering the class if it hasn't
54 | // previously been registered.
55 | const wchar_t* GetWindowClass();
56 |
57 | // Unregisters the window class. Should only be called if there are no
58 | // instances of the window.
59 | void UnregisterWindowClass();
60 |
61 | private:
62 | WindowClassRegistrar() = default;
63 |
64 | static WindowClassRegistrar* instance_;
65 |
66 | bool class_registered_ = false;
67 | };
68 |
69 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr;
70 |
71 | const wchar_t* WindowClassRegistrar::GetWindowClass() {
72 | if (!class_registered_) {
73 | WNDCLASS window_class{};
74 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW);
75 | window_class.lpszClassName = kWindowClassName;
76 | window_class.style = CS_HREDRAW | CS_VREDRAW;
77 | window_class.cbClsExtra = 0;
78 | window_class.cbWndExtra = 0;
79 | window_class.hInstance = GetModuleHandle(nullptr);
80 | window_class.hIcon =
81 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON));
82 | window_class.hbrBackground = 0;
83 | window_class.lpszMenuName = nullptr;
84 | window_class.lpfnWndProc = Win32Window::WndProc;
85 | RegisterClass(&window_class);
86 | class_registered_ = true;
87 | }
88 | return kWindowClassName;
89 | }
90 |
91 | void WindowClassRegistrar::UnregisterWindowClass() {
92 | UnregisterClass(kWindowClassName, nullptr);
93 | class_registered_ = false;
94 | }
95 |
96 | Win32Window::Win32Window() {
97 | ++g_active_window_count;
98 | }
99 |
100 | Win32Window::~Win32Window() {
101 | --g_active_window_count;
102 | Destroy();
103 | }
104 |
105 | bool Win32Window::CreateAndShow(const std::wstring& title,
106 | const Point& origin,
107 | const Size& size) {
108 | Destroy();
109 |
110 | const wchar_t* window_class =
111 | WindowClassRegistrar::GetInstance()->GetWindowClass();
112 |
113 | const POINT target_point = {static_cast(origin.x),
114 | static_cast(origin.y)};
115 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST);
116 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor);
117 | double scale_factor = dpi / 96.0;
118 |
119 | HWND window = CreateWindow(
120 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE,
121 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor),
122 | Scale(size.width, scale_factor), Scale(size.height, scale_factor),
123 | nullptr, nullptr, GetModuleHandle(nullptr), this);
124 |
125 | if (!window) {
126 | return false;
127 | }
128 |
129 | return OnCreate();
130 | }
131 |
132 | // static
133 | LRESULT CALLBACK Win32Window::WndProc(HWND const window,
134 | UINT const message,
135 | WPARAM const wparam,
136 | LPARAM const lparam) noexcept {
137 | if (message == WM_NCCREATE) {
138 | auto window_struct = reinterpret_cast(lparam);
139 | SetWindowLongPtr(window, GWLP_USERDATA,
140 | reinterpret_cast(window_struct->lpCreateParams));
141 |
142 | auto that = static_cast(window_struct->lpCreateParams);
143 | EnableFullDpiSupportIfAvailable(window);
144 | that->window_handle_ = window;
145 | } else if (Win32Window* that = GetThisFromHandle(window)) {
146 | return that->MessageHandler(window, message, wparam, lparam);
147 | }
148 |
149 | return DefWindowProc(window, message, wparam, lparam);
150 | }
151 |
152 | LRESULT
153 | Win32Window::MessageHandler(HWND hwnd,
154 | UINT const message,
155 | WPARAM const wparam,
156 | LPARAM const lparam) noexcept {
157 | switch (message) {
158 | case WM_DESTROY:
159 | window_handle_ = nullptr;
160 | Destroy();
161 | if (quit_on_close_) {
162 | PostQuitMessage(0);
163 | }
164 | return 0;
165 |
166 | case WM_DPICHANGED: {
167 | auto newRectSize = reinterpret_cast(lparam);
168 | LONG newWidth = newRectSize->right - newRectSize->left;
169 | LONG newHeight = newRectSize->bottom - newRectSize->top;
170 |
171 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth,
172 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE);
173 |
174 | return 0;
175 | }
176 | case WM_SIZE: {
177 | RECT rect = GetClientArea();
178 | if (child_content_ != nullptr) {
179 | // Size and position the child window.
180 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left,
181 | rect.bottom - rect.top, TRUE);
182 | }
183 | return 0;
184 | }
185 |
186 | case WM_ACTIVATE:
187 | if (child_content_ != nullptr) {
188 | SetFocus(child_content_);
189 | }
190 | return 0;
191 | }
192 |
193 | return DefWindowProc(window_handle_, message, wparam, lparam);
194 | }
195 |
196 | void Win32Window::Destroy() {
197 | OnDestroy();
198 |
199 | if (window_handle_) {
200 | DestroyWindow(window_handle_);
201 | window_handle_ = nullptr;
202 | }
203 | if (g_active_window_count == 0) {
204 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass();
205 | }
206 | }
207 |
208 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept {
209 | return reinterpret_cast(
210 | GetWindowLongPtr(window, GWLP_USERDATA));
211 | }
212 |
213 | void Win32Window::SetChildContent(HWND content) {
214 | child_content_ = content;
215 | SetParent(content, window_handle_);
216 | RECT frame = GetClientArea();
217 |
218 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left,
219 | frame.bottom - frame.top, true);
220 |
221 | SetFocus(child_content_);
222 | }
223 |
224 | RECT Win32Window::GetClientArea() {
225 | RECT frame;
226 | GetClientRect(window_handle_, &frame);
227 | return frame;
228 | }
229 |
230 | HWND Win32Window::GetHandle() {
231 | return window_handle_;
232 | }
233 |
234 | void Win32Window::SetQuitOnClose(bool quit_on_close) {
235 | quit_on_close_ = quit_on_close;
236 | }
237 |
238 | bool Win32Window::OnCreate() {
239 | // No-op; provided for subclasses.
240 | return true;
241 | }
242 |
243 | void Win32Window::OnDestroy() {
244 | // No-op; provided for subclasses.
245 | }
246 |
--------------------------------------------------------------------------------
/example/windows/runner/win32_window.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_WIN32_WINDOW_H_
2 | #define RUNNER_WIN32_WINDOW_H_
3 |
4 | #include
5 |
6 | #include
7 | #include
8 | #include
9 |
10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be
11 | // inherited from by classes that wish to specialize with custom
12 | // rendering and input handling
13 | class Win32Window {
14 | public:
15 | struct Point {
16 | unsigned int x;
17 | unsigned int y;
18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {}
19 | };
20 |
21 | struct Size {
22 | unsigned int width;
23 | unsigned int height;
24 | Size(unsigned int width, unsigned int height)
25 | : width(width), height(height) {}
26 | };
27 |
28 | Win32Window();
29 | virtual ~Win32Window();
30 |
31 | // Creates and shows a win32 window with |title| and position and size using
32 | // |origin| and |size|. New windows are created on the default monitor. Window
33 | // sizes are specified to the OS in physical pixels, hence to ensure a
34 | // consistent size to will treat the width height passed in to this function
35 | // as logical pixels and scale to appropriate for the default monitor. Returns
36 | // true if the window was created successfully.
37 | bool CreateAndShow(const std::wstring& title,
38 | const Point& origin,
39 | const Size& size);
40 |
41 | // Release OS resources associated with window.
42 | void Destroy();
43 |
44 | // Inserts |content| into the window tree.
45 | void SetChildContent(HWND content);
46 |
47 | // Returns the backing Window handle to enable clients to set icon and other
48 | // window properties. Returns nullptr if the window has been destroyed.
49 | HWND GetHandle();
50 |
51 | // If true, closing this window will quit the application.
52 | void SetQuitOnClose(bool quit_on_close);
53 |
54 | // Return a RECT representing the bounds of the current client area.
55 | RECT GetClientArea();
56 |
57 | protected:
58 | // Processes and route salient window messages for mouse handling,
59 | // size change and DPI. Delegates handling of these to member overloads that
60 | // inheriting classes can handle.
61 | virtual LRESULT MessageHandler(HWND window,
62 | UINT const message,
63 | WPARAM const wparam,
64 | LPARAM const lparam) noexcept;
65 |
66 | // Called when CreateAndShow is called, allowing subclass window-related
67 | // setup. Subclasses should return false if setup fails.
68 | virtual bool OnCreate();
69 |
70 | // Called when Destroy is called.
71 | virtual void OnDestroy();
72 |
73 | private:
74 | friend class WindowClassRegistrar;
75 |
76 | // OS callback called by message pump. Handles the WM_NCCREATE message which
77 | // is passed when the non-client area is being created and enables automatic
78 | // non-client DPI scaling so that the non-client area automatically
79 | // responsponds to changes in DPI. All other messages are handled by
80 | // MessageHandler.
81 | static LRESULT CALLBACK WndProc(HWND const window,
82 | UINT const message,
83 | WPARAM const wparam,
84 | LPARAM const lparam) noexcept;
85 |
86 | // Retrieves a class instance pointer for |window|
87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept;
88 |
89 | bool quit_on_close_ = false;
90 |
91 | // window handle for top level window.
92 | HWND window_handle_ = nullptr;
93 |
94 | // window handle for hosted content.
95 | HWND child_content_ = nullptr;
96 | };
97 |
98 | #endif // RUNNER_WIN32_WINDOW_H_
99 |
--------------------------------------------------------------------------------
/lib/popover.dart:
--------------------------------------------------------------------------------
1 | export 'src/popover.dart';
2 | export 'src/popover_direction.dart';
3 | export 'src/popover_route.dart';
4 | export 'src/popover_transition.dart';
5 |
--------------------------------------------------------------------------------
/lib/src/popover.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'popover_direction.dart';
4 | import 'popover_item.dart';
5 | import 'popover_route.dart';
6 | import 'popover_transition.dart';
7 | import 'utils/popover_utils.dart';
8 |
9 | /// A popover is a transient view that appears above other content onscreen
10 | /// when you tap a control or in an area.
11 | ///
12 | /// Note that when [allowClicksOnBackground] is set to true,
13 | /// [barrierDismissible] is ignored (will behave as if it was set to false).
14 | ///
15 | /// This function allows for customization of aspects of the dialog popup.
16 | ///
17 | /// `bodyBuilder` argument is builder which builds body/content of popover.
18 | ///
19 | /// The `direction` is desired Popover's direction behavior.
20 | /// This argument defaults to `PopoverDirection.bottom`.
21 | ///
22 | /// The `transition` is desired Popover's transition behavior.
23 | /// This argument defaults to `PopoverTransition.scale`.
24 | ///
25 | /// The `backgroundColor` is background [Color] of popover.
26 | /// This argument defaults to `Color(0x8FFFFFFFF)`.
27 | ///
28 | /// The `barrierColor` is barrier [Color] of screen when popover is presented.
29 | /// This argument defaults to `Color(0x80000000)`.
30 | ///
31 | /// The `transitionDuration` argument is used to determine how long it takes
32 | /// for the route to arrive on or leave off the screen. This argument defaults
33 | /// to 200 milliseconds.
34 | ///
35 | /// The `radius` of popover's body.
36 | /// This argument defaults to 8.
37 | ///
38 | /// The `shadow` is [BoxShadow] of popover body.
39 | /// This argument defaults to
40 | /// `[BoxShadow(color: Color(0x1F000000), blurRadius: 5)]`.
41 | ///
42 | /// The `arrowWidth` is width of arrow.
43 | /// This argument defaults to 24.
44 | ///
45 | /// The `arrowHeight` is height of arrow.
46 | /// This argument defaults to 12.
47 | ///
48 | /// The `arrowDxOffset` offsets arrow position on X axis.
49 | /// It can be positive or negative number.
50 | /// This argument defaults to 0.
51 | ///
52 | /// The `arrowDyOffset` offsets arrow position on Y axis.
53 | /// It can be positive or negative number.
54 | /// This argument defaults to 0.
55 | ///
56 | /// The`contentDyOffset` offsets [Popover]s content
57 | /// position on Y axis. It can be positive or negative number.
58 | /// This argument defaults to 0.
59 | ///
60 | /// The`contentDxOffset` offsets [Popover]s content
61 | /// position on X axis. It can be positive or negative number.
62 | /// This argument defaults to 0.
63 | ///
64 | /// The `barrierDismissible` argument is used to determine whether this route
65 | /// can be dismissed by tapping the modal barrier. This argument defaults
66 | /// to true.
67 | ///
68 | /// The `width` is popover's body/content widget width.
69 | ///
70 | /// The` height` is popover's body/content widget height.
71 | ///
72 | /// The `onPop` called to veto attempts by the user to dismiss the popover.
73 | ///
74 | /// The `constraints` is popover's constraints.
75 | ///
76 | /// The `routeSettings` is data that might be useful in constructing a [Route].
77 | ///
78 | /// The `barrierLabel` is semantic label used for a dismissible barrier.
79 | ///
80 | ///The `popoverBuilder` is used for transition builder
81 |
82 | Future showPopover({
83 | required BuildContext context,
84 | required WidgetBuilder bodyBuilder,
85 | PopoverDirection direction = PopoverDirection.bottom,
86 | PopoverTransition transition = PopoverTransition.scale,
87 | Color backgroundColor = const Color(0x8FFFFFFFF),
88 | Color barrierColor = const Color(0x80000000),
89 | Duration transitionDuration = const Duration(milliseconds: 200),
90 | double radius = 8,
91 | List shadow = const [
92 | BoxShadow(
93 | color: Color(0x1F000000),
94 | blurRadius: 5,
95 | )
96 | ],
97 | double arrowWidth = 24,
98 | double arrowHeight = 12,
99 | double arrowDxOffset = 0,
100 | double arrowDyOffset = 0,
101 | double contentDyOffset = 0,
102 | double contentDxOffset = 0,
103 | bool barrierDismissible = true,
104 | double? width,
105 | double? height,
106 | VoidCallback? onPop,
107 | @Deprecated(
108 | 'This argument is ignored. Implementation of [PopoverItem] was updated.'
109 | 'This feature was deprecated in v0.2.8',
110 | )
111 | bool Function()? isParentAlive,
112 | BoxConstraints? constraints,
113 | RouteSettings? routeSettings,
114 | String? barrierLabel,
115 | PopoverTransitionBuilder? popoverTransitionBuilder,
116 | Key? key,
117 | bool allowClicksOnBackground = false,
118 | }) {
119 | constraints = (width != null || height != null)
120 | ? constraints?.tighten(width: width, height: height) ??
121 | BoxConstraints.tightFor(width: width, height: height)
122 | : constraints;
123 |
124 | return Navigator.of(context, rootNavigator: true).push(
125 | PopoverRoute(
126 | allowClicksOnBackground: allowClicksOnBackground,
127 | pageBuilder: (_, animation, __) {
128 | return PopScope(
129 | onPopInvokedWithResult: (didPop, _) => onPop?.call(),
130 | child: PopoverItem(
131 | transition: transition,
132 | child: Builder(builder: bodyBuilder),
133 | context: context,
134 | backgroundColor: backgroundColor,
135 | direction: direction,
136 | radius: radius,
137 | boxShadow: shadow,
138 | animation: animation,
139 | arrowWidth: arrowWidth,
140 | arrowHeight: arrowHeight,
141 | constraints: constraints,
142 | arrowDxOffset: arrowDxOffset,
143 | arrowDyOffset: arrowDyOffset,
144 | contentDyOffset: contentDyOffset,
145 | contentDxOffset: contentDxOffset,
146 | key: key,
147 | ),
148 | );
149 | },
150 | barrierDismissible: barrierDismissible,
151 | barrierLabel: barrierLabel ??
152 | MaterialLocalizations.of(context).modalBarrierDismissLabel,
153 | barrierColor: barrierColor,
154 | transitionDuration: transitionDuration,
155 | settings: routeSettings,
156 | transitionBuilder: (builderContext, animation, _, child) {
157 | return popoverTransitionBuilder == null
158 | ? FadeTransition(
159 | opacity: CurvedAnimation(
160 | parent: animation,
161 | curve: Curves.easeOut,
162 | ),
163 | child: child,
164 | )
165 | : popoverTransitionBuilder(animation, child);
166 | },
167 | ),
168 | );
169 | }
170 |
--------------------------------------------------------------------------------
/lib/src/popover_context.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'popover_direction.dart';
4 | import 'popover_render_shifted_box.dart';
5 | import 'popover_transition.dart';
6 |
7 | final class PopoverContext extends SingleChildRenderObjectWidget {
8 | final PopoverTransition transition;
9 | final Animation animation;
10 | final Rect attachRect;
11 | final Color? backgroundColor;
12 | final List? boxShadow;
13 | final double? radius;
14 | final PopoverDirection? direction;
15 | final double? arrowWidth;
16 | final double arrowHeight;
17 |
18 | const PopoverContext({
19 | required this.transition,
20 | required this.animation,
21 | required this.attachRect,
22 | required this.arrowHeight,
23 | super.child,
24 | this.backgroundColor,
25 | this.boxShadow,
26 | this.radius,
27 | this.direction,
28 | this.arrowWidth,
29 | });
30 |
31 | @override
32 | RenderObject createRenderObject(BuildContext context) {
33 | return PopoverRenderShiftedBox(
34 | attachRect: attachRect,
35 | color: backgroundColor,
36 | boxShadow: boxShadow,
37 | scale: animation.value,
38 | direction: direction,
39 | radius: radius,
40 | arrowWidth: arrowWidth,
41 | arrowHeight: arrowHeight,
42 | );
43 | }
44 |
45 | @override
46 | void updateRenderObject(
47 | BuildContext context,
48 | PopoverRenderShiftedBox renderObject,
49 | ) {
50 | renderObject
51 | ..attachRect = attachRect
52 | ..color = backgroundColor
53 | ..boxShadow = boxShadow
54 | ..scale = transition == PopoverTransition.scale ? animation.value : 1.0
55 | ..direction = direction
56 | ..radius = radius
57 | ..arrowWidth = arrowWidth
58 | ..arrowHeight = arrowHeight;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/lib/src/popover_direction.dart:
--------------------------------------------------------------------------------
1 | /// Popover direction
2 | enum PopoverDirection {
3 | top,
4 | bottom,
5 | left,
6 | right,
7 | }
8 |
--------------------------------------------------------------------------------
/lib/src/popover_item.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import '../popover.dart';
4 | import 'popover_context.dart';
5 | import 'popover_position_widget.dart';
6 | import 'utils/build_context_extension.dart';
7 |
8 | class PopoverItem extends StatefulWidget {
9 | final Widget child;
10 | final Color? backgroundColor;
11 | final PopoverDirection? direction;
12 | final double? radius;
13 | final List? boxShadow;
14 | final Animation animation;
15 | final double? arrowWidth;
16 | final double arrowHeight;
17 | final BoxConstraints? constraints;
18 | final BuildContext context;
19 | final double arrowDxOffset;
20 | final double arrowDyOffset;
21 | final double contentDyOffset;
22 | final double contentDxOffset;
23 | final PopoverTransition transition;
24 |
25 | const PopoverItem({
26 | required this.child,
27 | required this.context,
28 | required this.transition,
29 | required this.animation,
30 | required this.arrowHeight,
31 | this.backgroundColor,
32 | this.direction,
33 | this.radius,
34 | this.boxShadow,
35 | this.arrowWidth,
36 | this.constraints,
37 | this.arrowDxOffset = 0,
38 | this.arrowDyOffset = 0,
39 | this.contentDyOffset = 0,
40 | this.contentDxOffset = 0,
41 | super.key,
42 | });
43 |
44 | @override
45 | _PopoverItemState createState() => _PopoverItemState();
46 | }
47 |
48 | class _PopoverItemState extends State {
49 | late Rect _attachRect;
50 | late BoxConstraints _constraints;
51 |
52 | @override
53 | Widget build(BuildContext context) {
54 | return Stack(
55 | children: [
56 | PopoverPositionWidget(
57 | attachRect: _attachRect,
58 | constraints: _constraints,
59 | direction: widget.direction,
60 | arrowHeight: widget.arrowHeight,
61 | child: AnimatedBuilder(
62 | animation: widget.animation,
63 | builder: (context, child) {
64 | return PopoverContext(
65 | attachRect: _attachRect,
66 | animation: widget.animation,
67 | radius: widget.radius,
68 | backgroundColor: widget.backgroundColor,
69 | boxShadow: widget.boxShadow,
70 | direction: widget.direction,
71 | arrowWidth: widget.arrowWidth,
72 | arrowHeight: widget.arrowHeight,
73 | transition: widget.transition,
74 | child: child,
75 | );
76 | },
77 | child: Material(
78 | child: widget.child,
79 | color: widget.backgroundColor,
80 | ),
81 | ),
82 | )
83 | ],
84 | );
85 | }
86 |
87 | @override
88 | void didChangeDependencies() {
89 | _configureConstraints();
90 | WidgetsBinding.instance.addPostFrameCallback(
91 | (_) => setState(_configureRect),
92 | );
93 |
94 | super.didChangeDependencies();
95 | }
96 |
97 | @override
98 | void initState() {
99 | _configureRect();
100 | super.initState();
101 | }
102 |
103 | void _configureConstraints() {
104 | final size = MediaQuery.of(context).size;
105 | var constraints = BoxConstraints.loose(size);
106 |
107 | if (widget.constraints != null) {
108 | constraints = constraints.copyWith(
109 | minWidth: widget.constraints!.minWidth.isFinite
110 | ? widget.constraints!.minWidth
111 | : null,
112 | minHeight: widget.constraints!.minHeight.isFinite
113 | ? widget.constraints!.minHeight
114 | : null,
115 | maxWidth: widget.constraints!.maxWidth.isFinite
116 | ? widget.constraints!.maxWidth
117 | : null,
118 | maxHeight: widget.constraints!.maxHeight.isFinite
119 | ? widget.constraints!.maxHeight
120 | : null,
121 | );
122 | }
123 |
124 | if (widget.direction == PopoverDirection.top ||
125 | widget.direction == PopoverDirection.bottom) {
126 | final maxHeight = constraints.maxHeight + widget.arrowHeight;
127 | constraints = constraints.copyWith(maxHeight: maxHeight);
128 | } else {
129 | constraints = constraints.copyWith(
130 | maxHeight: constraints.maxHeight + widget.arrowHeight,
131 | maxWidth: constraints.maxWidth + widget.arrowWidth!,
132 | );
133 | }
134 |
135 | _constraints = constraints;
136 | }
137 |
138 | void _configureRect() {
139 | if (!widget.context.mounted) return;
140 | final offset = BuildContextExtension.getWidgetLocalToGlobal(widget.context);
141 | final bounds = BuildContextExtension.getWidgetBounds(widget.context);
142 |
143 | if (offset != null && bounds != null) {
144 | _attachRect = Rect.fromLTWH(
145 | offset.dx + (widget.arrowDxOffset),
146 | offset.dy + (widget.arrowDyOffset),
147 | bounds.width + (widget.contentDxOffset),
148 | bounds.height + (widget.contentDyOffset),
149 | );
150 | }
151 | }
152 | }
153 |
--------------------------------------------------------------------------------
/lib/src/popover_path.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/painting.dart';
2 |
3 | import 'popover_direction.dart';
4 |
5 | final class PopoverPath {
6 | final double radius;
7 |
8 | const PopoverPath(this.radius);
9 |
10 | Path draw(
11 | PopoverDirection? direction,
12 | Rect? arrowRect,
13 | Rect bodyRect,
14 | ) {
15 | final path = Path();
16 |
17 | if (arrowRect != null) {
18 | if (direction == PopoverDirection.top) {
19 | _drawTopElement(path, arrowRect, bodyRect);
20 | } else if (direction == PopoverDirection.right) {
21 | _drawRightElement(path, arrowRect, bodyRect);
22 | } else if (direction == PopoverDirection.left) {
23 | _drawLeftElement(path, arrowRect, bodyRect);
24 | } else {
25 | _drawBottomElement(path, arrowRect, bodyRect);
26 | }
27 | path.close();
28 | return path;
29 | } else {
30 | path.close();
31 | return path;
32 | }
33 | }
34 |
35 | void _drawBottomElement(Path path, Rect arrowRect, Rect bodyRect) {
36 | path.moveTo(arrowRect.left, arrowRect.bottom);
37 | path.lineTo(arrowRect.left + arrowRect.width / 2, arrowRect.top);
38 | path.lineTo(arrowRect.right, arrowRect.bottom);
39 |
40 | path.lineTo(bodyRect.right - radius, bodyRect.top);
41 | path.conicTo(
42 | bodyRect.right,
43 | bodyRect.top,
44 | bodyRect.right,
45 | bodyRect.top + radius,
46 | 1,
47 | );
48 |
49 | path.lineTo(bodyRect.right, bodyRect.bottom - radius);
50 | path.conicTo(
51 | bodyRect.right,
52 | bodyRect.bottom,
53 | bodyRect.right - radius,
54 | bodyRect.bottom,
55 | 1,
56 | );
57 |
58 | path.lineTo(bodyRect.left + radius, bodyRect.bottom);
59 | path.conicTo(
60 | bodyRect.left,
61 | bodyRect.bottom,
62 | bodyRect.left,
63 | bodyRect.bottom - radius,
64 | 1,
65 | );
66 |
67 | path.lineTo(bodyRect.left, bodyRect.top + radius);
68 | path.conicTo(
69 | bodyRect.left,
70 | bodyRect.top,
71 | bodyRect.left + radius,
72 | bodyRect.top,
73 | 1,
74 | );
75 | }
76 |
77 | void _drawLeftElement(Path path, Rect arrowRect, Rect bodyRect) {
78 | path.moveTo(arrowRect.left, arrowRect.top);
79 | path.lineTo(arrowRect.right, arrowRect.top + arrowRect.height / 2);
80 | path.lineTo(arrowRect.left, arrowRect.bottom);
81 |
82 | path.lineTo(bodyRect.right, bodyRect.bottom - radius);
83 | path.conicTo(
84 | bodyRect.right,
85 | bodyRect.bottom,
86 | bodyRect.right - radius,
87 | bodyRect.bottom,
88 | 1,
89 | );
90 |
91 | path.lineTo(bodyRect.left + radius, bodyRect.bottom);
92 | path.conicTo(
93 | bodyRect.left,
94 | bodyRect.bottom,
95 | bodyRect.left,
96 | bodyRect.bottom - radius,
97 | 1,
98 | );
99 |
100 | path.lineTo(bodyRect.left, bodyRect.top + radius);
101 | path.conicTo(
102 | bodyRect.left,
103 | bodyRect.top,
104 | bodyRect.left + radius,
105 | bodyRect.top,
106 | 1,
107 | );
108 |
109 | path.lineTo(bodyRect.right - radius, bodyRect.top);
110 | path.conicTo(
111 | bodyRect.right,
112 | bodyRect.top,
113 | bodyRect.right,
114 | bodyRect.top + radius,
115 | 1,
116 | );
117 | }
118 |
119 | void _drawRightElement(Path path, Rect arrowRect, Rect bodyRect) {
120 | path.moveTo(arrowRect.right, arrowRect.top);
121 | path.lineTo(arrowRect.left, arrowRect.top + arrowRect.height / 2);
122 | path.lineTo(arrowRect.right, arrowRect.bottom);
123 |
124 | path.lineTo(bodyRect.left, bodyRect.bottom - radius);
125 | path.conicTo(
126 | bodyRect.left,
127 | bodyRect.bottom,
128 | bodyRect.left + radius,
129 | bodyRect.bottom,
130 | 1,
131 | );
132 |
133 | path.lineTo(bodyRect.right - radius, bodyRect.bottom);
134 | path.conicTo(
135 | bodyRect.right,
136 | bodyRect.bottom,
137 | bodyRect.right,
138 | bodyRect.bottom - radius,
139 | 1,
140 | );
141 |
142 | path.lineTo(bodyRect.right, bodyRect.top + radius);
143 | path.conicTo(
144 | bodyRect.right,
145 | bodyRect.top,
146 | bodyRect.right - radius,
147 | bodyRect.top,
148 | 1,
149 | );
150 |
151 | path.lineTo(bodyRect.left + radius, bodyRect.top);
152 | path.conicTo(
153 | bodyRect.left,
154 | bodyRect.top,
155 | bodyRect.left,
156 | bodyRect.top + radius,
157 | 1,
158 | );
159 | }
160 |
161 | void _drawTopElement(Path path, Rect arrowRect, Rect bodyRect) {
162 | path.moveTo(arrowRect.left, arrowRect.top);
163 | path.lineTo(arrowRect.left + arrowRect.width / 2, arrowRect.bottom);
164 | path.lineTo(arrowRect.right, arrowRect.top);
165 |
166 | path.lineTo(bodyRect.right - radius, bodyRect.bottom);
167 | path.conicTo(
168 | bodyRect.right,
169 | bodyRect.bottom,
170 | bodyRect.right,
171 | bodyRect.bottom - radius,
172 | 1,
173 | );
174 |
175 | path.lineTo(bodyRect.right, bodyRect.top + radius);
176 | path.conicTo(
177 | bodyRect.right,
178 | bodyRect.top,
179 | bodyRect.right - radius,
180 | bodyRect.top,
181 | 1,
182 | );
183 |
184 | path.lineTo(bodyRect.left + radius, bodyRect.top);
185 | path.conicTo(
186 | bodyRect.left,
187 | bodyRect.top,
188 | bodyRect.left,
189 | bodyRect.top + radius,
190 | 1,
191 | );
192 |
193 | path.lineTo(bodyRect.left, bodyRect.bottom - radius);
194 | path.conicTo(
195 | bodyRect.left,
196 | bodyRect.bottom,
197 | bodyRect.left + radius,
198 | bodyRect.bottom,
199 | 1,
200 | );
201 | }
202 | }
203 |
--------------------------------------------------------------------------------
/lib/src/popover_position_render_object.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/rendering.dart';
2 |
3 | import 'popover_direction.dart';
4 | import 'utils/popover_utils.dart';
5 |
6 | final class PopoverPositionRenderObject extends RenderShiftedBox {
7 | late Rect _attachRect;
8 | double arrowHeight;
9 | BoxConstraints? _additionalConstraints;
10 | PopoverDirection? _direction;
11 |
12 | PopoverPositionRenderObject({
13 | required this.arrowHeight,
14 | required Rect attachRect,
15 | RenderBox? child,
16 | BoxConstraints? constraints,
17 | PopoverDirection? direction,
18 | }) : super(child) {
19 | _attachRect = attachRect;
20 | _additionalConstraints = constraints;
21 | _direction = direction;
22 | }
23 |
24 | BoxConstraints? get additionalConstraints => _additionalConstraints;
25 | set additionalConstraints(BoxConstraints? value) {
26 | if (_additionalConstraints == value) return;
27 | _additionalConstraints = value;
28 | markNeedsLayout();
29 | }
30 |
31 | Rect get attachRect => _attachRect;
32 | set attachRect(Rect value) {
33 | if (_attachRect == value) return;
34 | _attachRect = value;
35 | markNeedsLayout();
36 | }
37 |
38 | PopoverDirection? get direction => _direction;
39 | set direction(PopoverDirection? value) {
40 | if (_direction == value) return;
41 | _direction = value;
42 | markNeedsLayout();
43 | }
44 |
45 | Offset calculateOffset(Size size) {
46 | final _direction = PopoverUtils.popoverDirection(
47 | attachRect,
48 | size,
49 | arrowHeight,
50 | direction,
51 | );
52 |
53 | if (_direction == PopoverDirection.top ||
54 | _direction == PopoverDirection.bottom) {
55 | return _dxOffset(_direction, _horizontalOffset(size), size);
56 | } else {
57 | return _dyOffset(_direction, _verticalOffset(size), size);
58 | }
59 | }
60 |
61 | @override
62 | void performLayout() {
63 | child!.layout(
64 | _additionalConstraints!.enforce(constraints),
65 | parentUsesSize: true,
66 | );
67 | size = Size(constraints.maxWidth, constraints.maxHeight);
68 | final childParentData = child!.parentData as BoxParentData;
69 | childParentData.offset = calculateOffset(child!.size);
70 | }
71 |
72 | Offset _dxOffset(
73 | PopoverDirection direction,
74 | double horizontalOffset,
75 | Size size,
76 | ) {
77 | if (direction == PopoverDirection.bottom) {
78 | return Offset(horizontalOffset, attachRect.bottom);
79 | } else {
80 | return Offset(horizontalOffset, attachRect.top - size.height);
81 | }
82 | }
83 |
84 | Offset _dyOffset(
85 | PopoverDirection _direction,
86 | double verticalOffset,
87 | Size size,
88 | ) {
89 | if (_direction == PopoverDirection.right) {
90 | return Offset(attachRect.right, verticalOffset);
91 | } else {
92 | return Offset(attachRect.left - size.width, verticalOffset);
93 | }
94 | }
95 |
96 | double _horizontalOffset(Size size) {
97 | var offset = 0.0;
98 |
99 | if (attachRect.left > size.width / 2 &&
100 | PopoverUtils.physicalSize.width - attachRect.right > size.width / 2) {
101 | offset = attachRect.left + attachRect.width / 2 - size.width / 2;
102 | } else if (attachRect.left < size.width / 2) {
103 | offset = arrowHeight;
104 | } else {
105 | offset = PopoverUtils.physicalSize.width - arrowHeight - size.width;
106 | }
107 | return offset;
108 | }
109 |
110 | double _verticalOffset(Size size) {
111 | var offset = 0.0;
112 |
113 | if (attachRect.top > size.height / 2 &&
114 | PopoverUtils.physicalSize.height - attachRect.bottom >
115 | size.height / 2) {
116 | offset = attachRect.top + attachRect.height / 2 - size.height / 2;
117 | } else if (attachRect.top < size.height / 2) {
118 | offset = arrowHeight;
119 | } else {
120 | offset = PopoverUtils.physicalSize.height - arrowHeight - size.height;
121 | }
122 | return offset;
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/lib/src/popover_position_widget.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'popover_direction.dart';
4 | import 'popover_position_render_object.dart';
5 |
6 | final class PopoverPositionWidget extends SingleChildRenderObjectWidget {
7 | final Rect attachRect;
8 | final double arrowHeight;
9 | final BoxConstraints? constraints;
10 | final PopoverDirection? direction;
11 |
12 | const PopoverPositionWidget({
13 | required this.arrowHeight,
14 | required this.attachRect,
15 | this.constraints,
16 | this.direction,
17 | Widget? child,
18 | }) : super(child: child);
19 |
20 | @override
21 | RenderObject createRenderObject(BuildContext context) {
22 | return PopoverPositionRenderObject(
23 | attachRect: attachRect,
24 | direction: direction,
25 | constraints: constraints,
26 | arrowHeight: arrowHeight,
27 | );
28 | }
29 |
30 | @override
31 | void updateRenderObject(
32 | BuildContext context,
33 | PopoverPositionRenderObject renderObject,
34 | ) {
35 | renderObject
36 | ..attachRect = attachRect
37 | ..direction = direction
38 | ..additionalConstraints = constraints;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/lib/src/popover_render_shifted_box.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/rendering.dart';
2 |
3 | import 'popover_direction.dart';
4 | import 'popover_path.dart';
5 | import 'utils/popover_utils.dart';
6 |
7 | final class PopoverRenderShiftedBox extends RenderShiftedBox {
8 | late Rect _attachRect;
9 | double? arrowWidth;
10 | double arrowHeight;
11 | PopoverDirection? _direction;
12 | Color? _color;
13 | List? _boxShadow;
14 | double? _scale;
15 | double? _radius;
16 |
17 | PopoverRenderShiftedBox({
18 | required Rect attachRect,
19 | required this.arrowHeight,
20 | this.arrowWidth,
21 | RenderBox? child,
22 | Color? color,
23 | List? boxShadow,
24 | double? scale,
25 | double? radius,
26 | PopoverDirection? direction,
27 | }) : super(child) {
28 | _attachRect = attachRect;
29 | _color = color;
30 | _boxShadow = boxShadow;
31 | _scale = scale;
32 | _radius = radius;
33 | _direction = direction;
34 | }
35 |
36 | Rect get attachRect => _attachRect;
37 | set attachRect(Rect value) {
38 | if (_attachRect == value) return;
39 | _attachRect = value;
40 | markNeedsLayout();
41 | }
42 |
43 | List? get boxShadow => _boxShadow;
44 | set boxShadow(List? value) {
45 | if (_boxShadow == value) return;
46 | _boxShadow = value;
47 | markNeedsLayout();
48 | }
49 |
50 | Color? get color => _color;
51 | set color(Color? value) {
52 | if (_color == value) return;
53 | _color = value;
54 | markNeedsLayout();
55 | }
56 |
57 | PopoverDirection? get direction => _direction;
58 | set direction(PopoverDirection? value) {
59 | if (_direction == value) return;
60 | _direction = value;
61 | markNeedsLayout();
62 | }
63 |
64 | double? get radius => _radius;
65 | set radius(double? value) {
66 | if (_radius == value) return;
67 | _radius = value;
68 | markNeedsLayout();
69 | }
70 |
71 | double? get scale => _scale;
72 | set scale(double? value) {
73 | _scale = value;
74 | markNeedsLayout();
75 | }
76 |
77 | @override
78 | void paint(PaintingContext context, Offset offset) {
79 | final transform = Matrix4.identity();
80 | final childParentData = child!.parentData as BoxParentData;
81 | final _direction = PopoverUtils.popoverDirection(
82 | attachRect,
83 | size,
84 | arrowHeight,
85 | direction,
86 | );
87 | final bodyRect = childParentData.offset & child!.size;
88 |
89 | final arrowLeft =
90 | attachRect.left + attachRect.width / 2 - arrowWidth! / 2 - offset.dx;
91 |
92 | final arrowTop =
93 | attachRect.top + attachRect.height / 2 - arrowWidth! / 2 - offset.dy;
94 |
95 | late Rect arrowRect;
96 | late Offset translation;
97 |
98 | switch (_direction) {
99 | case PopoverDirection.top:
100 | arrowRect = Rect.fromLTWH(
101 | arrowLeft,
102 | child!.size.height,
103 | arrowWidth!,
104 | arrowHeight,
105 | );
106 |
107 | translation = Offset(arrowLeft + arrowWidth! / 2, size.height);
108 | break;
109 | case PopoverDirection.bottom:
110 | arrowRect = Rect.fromLTWH(arrowLeft, 0, arrowWidth!, arrowHeight);
111 | translation = Offset(arrowLeft + arrowWidth! / 2, 0);
112 | break;
113 | case PopoverDirection.left:
114 | arrowRect = Rect.fromLTWH(
115 | child!.size.width,
116 | arrowTop,
117 | arrowHeight,
118 | arrowWidth!,
119 | );
120 |
121 | translation = Offset(size.width, arrowTop + arrowWidth! / 2);
122 | break;
123 | case PopoverDirection.right:
124 | arrowRect = Rect.fromLTWH(
125 | 0,
126 | arrowTop,
127 | arrowHeight,
128 | arrowWidth!,
129 | );
130 | translation = Offset(0, arrowTop + arrowWidth! / 2);
131 | break;
132 | }
133 |
134 | _transform(transform, translation);
135 |
136 | _paintShadows(context, transform, offset, _direction, arrowRect, bodyRect);
137 |
138 | _pushClipPath(
139 | context,
140 | offset,
141 | PopoverPath(radius!).draw(_direction, arrowRect, bodyRect),
142 | transform,
143 | );
144 | }
145 |
146 | @override
147 | void performLayout() {
148 | assert(constraints.maxHeight.isFinite);
149 |
150 | _configureChildConstrains();
151 | _configureChildSize();
152 | _configureChildOffset();
153 | }
154 |
155 | void _configureChildConstrains() {
156 | BoxConstraints childConstraints;
157 |
158 | if (direction == PopoverDirection.top ||
159 | direction == PopoverDirection.bottom) {
160 | childConstraints = BoxConstraints(
161 | maxHeight: constraints.maxHeight - arrowHeight,
162 | ).enforce(constraints);
163 | } else {
164 | childConstraints = BoxConstraints(
165 | maxWidth: constraints.maxWidth - arrowHeight,
166 | ).enforce(constraints);
167 | }
168 |
169 | child!.layout(childConstraints, parentUsesSize: true);
170 | }
171 |
172 | void _configureChildOffset() {
173 | final _direction = PopoverUtils.popoverDirection(
174 | attachRect,
175 | size,
176 | arrowHeight,
177 | direction,
178 | );
179 |
180 | final childParentData = child!.parentData as BoxParentData?;
181 | if (_direction == PopoverDirection.bottom) {
182 | childParentData!.offset = Offset(0, arrowHeight);
183 | } else if (_direction == PopoverDirection.right) {
184 | childParentData!.offset = Offset(arrowHeight, 0);
185 | } else {
186 | childParentData!.offset = const Offset(0, 0);
187 | }
188 | }
189 |
190 | void _configureChildSize() {
191 | if (direction == PopoverDirection.top ||
192 | direction == PopoverDirection.bottom) {
193 | size = Size(child!.size.width, child!.size.height + arrowHeight);
194 | } else {
195 | size = Size(child!.size.width + arrowHeight, child!.size.height);
196 | }
197 | }
198 |
199 | void _paintShadows(
200 | PaintingContext context,
201 | Matrix4 transform,
202 | Offset offset,
203 | PopoverDirection direction,
204 | Rect? arrowRect,
205 | Rect bodyRect,
206 | ) {
207 | if (boxShadow == null) return;
208 | for (final boxShadow in boxShadow!) {
209 | final paint = boxShadow.toPaint();
210 |
211 | arrowRect = arrowRect!
212 | .shift(offset)
213 | .shift(boxShadow.offset)
214 | .inflate(boxShadow.spreadRadius);
215 |
216 | bodyRect = bodyRect
217 | .shift(offset)
218 | .shift(boxShadow.offset)
219 | .inflate(boxShadow.spreadRadius);
220 |
221 | final path = PopoverPath(radius!).draw(_direction, arrowRect, bodyRect);
222 |
223 | context.pushTransform(needsCompositing, offset, transform, (
224 | context,
225 | offset,
226 | ) {
227 | context.canvas.drawPath(path, paint);
228 | });
229 | }
230 | }
231 |
232 | void _pushClipPath(
233 | PaintingContext context,
234 | Offset offset,
235 | Path path,
236 | Matrix4 transform,
237 | ) {
238 | context.pushClipPath(needsCompositing, offset, offset & size, path, (
239 | context,
240 | offset,
241 | ) {
242 | context.pushTransform(needsCompositing, offset, transform, (
243 | context,
244 | offset,
245 | ) {
246 | final backgroundPaint = Paint();
247 | backgroundPaint.color = color!;
248 | context.canvas.drawRect(offset & size, backgroundPaint);
249 | super.paint(context, offset);
250 | });
251 | });
252 | }
253 |
254 | void _transform(Matrix4 transform, Offset translation) {
255 | transform.translate(translation.dx, translation.dy);
256 | transform.scale(scale, scale, 1);
257 | transform.translate(-translation.dx, -translation.dy);
258 | }
259 | }
260 |
--------------------------------------------------------------------------------
/lib/src/popover_route.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | class PopoverRoute extends RawDialogRoute {
4 | /// If true, widgets behind the barrier can receive pointer events.
5 | final bool allowClicksOnBackground;
6 |
7 | PopoverRoute({
8 | required super.pageBuilder,
9 | super.anchorPoint,
10 | super.barrierColor,
11 | super.barrierDismissible,
12 | super.barrierLabel,
13 | super.settings,
14 | super.transitionBuilder,
15 | super.transitionDuration,
16 | super.traversalEdgeBehavior,
17 | this.allowClicksOnBackground = false,
18 | });
19 |
20 | @override
21 | Widget buildModalBarrier() {
22 | return IgnorePointer(
23 | ignoring: allowClicksOnBackground,
24 | child: super.buildModalBarrier(),
25 | );
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/lib/src/popover_transition.dart:
--------------------------------------------------------------------------------
1 | /// Popover Transition
2 | enum PopoverTransition { scale, other }
3 |
--------------------------------------------------------------------------------
/lib/src/utils/build_context_extension.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | extension BuildContextExtension on BuildContext {
4 | static Rect? getWidgetBounds(BuildContext context) {
5 | final box = context.findRenderObject() as RenderBox?;
6 | return (box != null) ? box.semanticBounds : null;
7 | }
8 |
9 | static Offset? getWidgetLocalToGlobal(BuildContext context) {
10 | final box = context.findRenderObject() as RenderBox?;
11 | return (box != null) ? box.localToGlobal(Offset.zero) : null;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/lib/src/utils/popover_utils.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/foundation.dart';
2 | import 'package:flutter/material.dart';
3 |
4 | import '../popover_direction.dart';
5 |
6 | abstract class PopoverUtils {
7 | static PopoverDirection popoverDirection(
8 | Rect attachRect,
9 | Size size,
10 | double arrowHeight,
11 | PopoverDirection? direction,
12 | ) {
13 | switch (direction) {
14 | case PopoverDirection.top:
15 | return (attachRect.top < size.height + arrowHeight)
16 | ? PopoverDirection.bottom
17 | : PopoverDirection.top;
18 | case PopoverDirection.bottom:
19 | return physicalSize.height >
20 | attachRect.bottom + size.height + arrowHeight
21 | ? PopoverDirection.bottom
22 | : PopoverDirection.top;
23 | case PopoverDirection.left:
24 | return (attachRect.left < size.width + arrowHeight)
25 | ? PopoverDirection.right
26 | : PopoverDirection.left;
27 | case PopoverDirection.right:
28 | return physicalSize.width > attachRect.right + size.width + arrowHeight
29 | ? PopoverDirection.right
30 | : PopoverDirection.left;
31 | default:
32 | return PopoverDirection.bottom;
33 | }
34 | }
35 |
36 | static Size get physicalSize =>
37 | PlatformDispatcher.instance.views.first.physicalSize /
38 | PlatformDispatcher.instance.views.first.devicePixelRatio;
39 | }
40 |
41 | typedef PopoverTransitionBuilder = Widget Function(
42 | Animation animation,
43 | Widget child,
44 | );
45 |
--------------------------------------------------------------------------------
/pubspec.lock:
--------------------------------------------------------------------------------
1 | # Generated by pub
2 | # See https://dart.dev/tools/pub/glossary#lockfile
3 | packages:
4 | async:
5 | dependency: transitive
6 | description:
7 | name: async
8 | sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
9 | url: "https://pub.dev"
10 | source: hosted
11 | version: "2.11.0"
12 | boolean_selector:
13 | dependency: transitive
14 | description:
15 | name: boolean_selector
16 | sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
17 | url: "https://pub.dev"
18 | source: hosted
19 | version: "2.1.1"
20 | characters:
21 | dependency: transitive
22 | description:
23 | name: characters
24 | sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
25 | url: "https://pub.dev"
26 | source: hosted
27 | version: "1.3.0"
28 | clock:
29 | dependency: transitive
30 | description:
31 | name: clock
32 | sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
33 | url: "https://pub.dev"
34 | source: hosted
35 | version: "1.1.1"
36 | collection:
37 | dependency: transitive
38 | description:
39 | name: collection
40 | sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
41 | url: "https://pub.dev"
42 | source: hosted
43 | version: "1.18.0"
44 | fake_async:
45 | dependency: transitive
46 | description:
47 | name: fake_async
48 | sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
49 | url: "https://pub.dev"
50 | source: hosted
51 | version: "1.3.1"
52 | flutter:
53 | dependency: "direct main"
54 | description: flutter
55 | source: sdk
56 | version: "0.0.0"
57 | flutter_test:
58 | dependency: "direct dev"
59 | description: flutter
60 | source: sdk
61 | version: "0.0.0"
62 | leak_tracker:
63 | dependency: transitive
64 | description:
65 | name: leak_tracker
66 | sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
67 | url: "https://pub.dev"
68 | source: hosted
69 | version: "10.0.5"
70 | leak_tracker_flutter_testing:
71 | dependency: transitive
72 | description:
73 | name: leak_tracker_flutter_testing
74 | sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
75 | url: "https://pub.dev"
76 | source: hosted
77 | version: "3.0.5"
78 | leak_tracker_testing:
79 | dependency: transitive
80 | description:
81 | name: leak_tracker_testing
82 | sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
83 | url: "https://pub.dev"
84 | source: hosted
85 | version: "3.0.1"
86 | matcher:
87 | dependency: transitive
88 | description:
89 | name: matcher
90 | sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
91 | url: "https://pub.dev"
92 | source: hosted
93 | version: "0.12.16+1"
94 | material_color_utilities:
95 | dependency: transitive
96 | description:
97 | name: material_color_utilities
98 | sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
99 | url: "https://pub.dev"
100 | source: hosted
101 | version: "0.11.1"
102 | meta:
103 | dependency: transitive
104 | description:
105 | name: meta
106 | sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
107 | url: "https://pub.dev"
108 | source: hosted
109 | version: "1.15.0"
110 | path:
111 | dependency: transitive
112 | description:
113 | name: path
114 | sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
115 | url: "https://pub.dev"
116 | source: hosted
117 | version: "1.9.0"
118 | sky_engine:
119 | dependency: transitive
120 | description: flutter
121 | source: sdk
122 | version: "0.0.99"
123 | source_span:
124 | dependency: transitive
125 | description:
126 | name: source_span
127 | sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
128 | url: "https://pub.dev"
129 | source: hosted
130 | version: "1.10.0"
131 | stack_trace:
132 | dependency: transitive
133 | description:
134 | name: stack_trace
135 | sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
136 | url: "https://pub.dev"
137 | source: hosted
138 | version: "1.11.1"
139 | stream_channel:
140 | dependency: transitive
141 | description:
142 | name: stream_channel
143 | sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
144 | url: "https://pub.dev"
145 | source: hosted
146 | version: "2.1.2"
147 | string_scanner:
148 | dependency: transitive
149 | description:
150 | name: string_scanner
151 | sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
152 | url: "https://pub.dev"
153 | source: hosted
154 | version: "1.2.0"
155 | term_glyph:
156 | dependency: transitive
157 | description:
158 | name: term_glyph
159 | sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
160 | url: "https://pub.dev"
161 | source: hosted
162 | version: "1.2.1"
163 | test_api:
164 | dependency: transitive
165 | description:
166 | name: test_api
167 | sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
168 | url: "https://pub.dev"
169 | source: hosted
170 | version: "0.7.2"
171 | vector_math:
172 | dependency: transitive
173 | description:
174 | name: vector_math
175 | sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
176 | url: "https://pub.dev"
177 | source: hosted
178 | version: "2.1.4"
179 | vm_service:
180 | dependency: transitive
181 | description:
182 | name: vm_service
183 | sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
184 | url: "https://pub.dev"
185 | source: hosted
186 | version: "14.2.5"
187 | sdks:
188 | dart: ">=3.5.0 <4.0.0"
189 | flutter: ">=3.24.0"
190 |
--------------------------------------------------------------------------------
/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: popover
2 | description: A popover is a transient view that appears above other content onscreen when you tap a control or in an area.
3 | version: 0.3.1
4 | homepage: https://github.com/minikin/popover
5 |
6 | environment:
7 | sdk: '>=3.5.0 <4.0.0'
8 | flutter: '>=3.24.0'
9 |
10 | dependencies:
11 | flutter:
12 | sdk: flutter
13 |
14 | dev_dependencies:
15 | flutter_test:
16 | sdk: flutter
17 |
--------------------------------------------------------------------------------
/test/popover_test.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_test/flutter_test.dart';
3 | import 'package:popover/popover.dart';
4 |
5 | void main() {
6 | setUp(WidgetsFlutterBinding.ensureInitialized);
7 |
8 | testWidgets('Popover dialog control test', (tester) async {
9 | var didDelete = false;
10 |
11 | await tester.pumpWidget(
12 | createAppWithButtonThatLaunchesDialog(
13 | dialogBuilder: (context) {
14 | return InkWell(
15 | onTap: () {
16 | didDelete = true;
17 | Navigator.pop(context);
18 | },
19 | child: const Text('Delete'),
20 | );
21 | },
22 | ),
23 | );
24 |
25 | await tester.tap(find.text('Go'));
26 | await tester.pumpAndSettle();
27 |
28 | expect(didDelete, isFalse);
29 |
30 | await tester.tap(find.textContaining('Delete'));
31 | await tester.pumpAndSettle();
32 |
33 | expect(didDelete, isTrue);
34 | expect(find.text('Delete'), findsNothing);
35 | });
36 |
37 | testWidgets('Popover is barrier dismissible by default', (tester) async {
38 | await tester.pumpWidget(createAppWithCenteredButton(const Text('Go')));
39 |
40 | final BuildContext context = tester.element(find.text('Go'));
41 |
42 | showPopover(
43 | context: context,
44 | bodyBuilder: (context) {
45 | return Container(
46 | width: 100.0,
47 | height: 100.0,
48 | alignment: Alignment.center,
49 | child: const Text('Dialog'),
50 | );
51 | },
52 | );
53 |
54 | await tester.pumpAndSettle(const Duration(seconds: 1));
55 | expect(find.text('Dialog'), findsOneWidget);
56 |
57 | // Tap off the barrier.
58 | await tester.tapAt(const Offset(10.0, 10.0));
59 |
60 | await tester.pumpAndSettle(const Duration(seconds: 1));
61 | expect(find.text('Dialog'), findsNothing);
62 | });
63 |
64 | testWidgets('Popover configurable to be not barrier dismissible',
65 | (tester) async {
66 | await tester.pumpWidget(createAppWithCenteredButton(const Text('Go')));
67 |
68 | final BuildContext context = tester.element(find.text('Go'));
69 |
70 | showPopover(
71 | context: context,
72 | bodyBuilder: (context) {
73 | return Container(
74 | width: 100.0,
75 | height: 100.0,
76 | alignment: Alignment.center,
77 | child: const Text('Dialog'),
78 | );
79 | },
80 | barrierDismissible: false,
81 | );
82 |
83 | await tester.pumpAndSettle(const Duration(seconds: 1));
84 | expect(find.text('Dialog'), findsOneWidget);
85 |
86 | // Tap on the barrier, which shouldn't do anything this time.
87 | await tester.tapAt(const Offset(10.0, 10.0));
88 |
89 | await tester.pumpAndSettle(const Duration(seconds: 1));
90 | expect(find.text('Dialog'), findsOneWidget);
91 | });
92 |
93 | testWidgets('Clicks on background are disabled on default', (tester) async {
94 | var didOpenDialog = false;
95 |
96 | await tester.pumpWidget(
97 | createAppWithButtonThatLaunchesDialog(
98 | dialogBuilder: (context) {
99 | didOpenDialog = true;
100 | return InkWell(
101 | onTap: () {
102 | Navigator.pop(context);
103 | },
104 | child: const Text('This should not happen'),
105 | );
106 | },
107 | ),
108 | );
109 |
110 | final BuildContext context = tester.element(find.text('Go'));
111 |
112 | showPopover(
113 | context: context,
114 | bodyBuilder: (context) {
115 | return Container(
116 | width: 100.0,
117 | height: 100.0,
118 | alignment: Alignment.center,
119 | child: const Text('Popover'),
120 | );
121 | },
122 | );
123 |
124 | await tester.pumpAndSettle(const Duration(seconds: 1));
125 | expect(find.text('Popover'), findsOneWidget);
126 |
127 | // Tap on the 'Go' button, which should not open the dialog.
128 | await tester.tap(find.text('Go'));
129 |
130 | await tester.pumpAndSettle(const Duration(seconds: 1));
131 |
132 | expect(didOpenDialog, isFalse);
133 | });
134 |
135 | testWidgets('Popover configurable to allow clicks on background',
136 | (tester) async {
137 | var didOpenDialog = false;
138 |
139 | await tester.pumpWidget(
140 | createAppWithButtonThatLaunchesDialog(
141 | dialogBuilder: (context) {
142 | didOpenDialog = true;
143 | return InkWell(
144 | onTap: () {
145 | Navigator.pop(context);
146 | },
147 | child: const Text('This should happen'),
148 | );
149 | },
150 | ),
151 | );
152 |
153 | final BuildContext context = tester.element(find.text('Go'));
154 |
155 | showPopover(
156 | context: context,
157 | bodyBuilder: (context) {
158 | return Container(
159 | width: 100.0,
160 | height: 100.0,
161 | alignment: Alignment.center,
162 | child: const Text('Popover'),
163 | );
164 | },
165 | allowClicksOnBackground: true,
166 | );
167 |
168 | await tester.pumpAndSettle(const Duration(seconds: 1));
169 | expect(find.text('Popover'), findsOneWidget);
170 |
171 | // Tap on the 'Go' button, which should open the dialog.
172 | await tester.tap(find.text('Go'));
173 |
174 | await tester.pumpAndSettle(const Duration(seconds: 1));
175 |
176 | expect(didOpenDialog, isTrue);
177 | });
178 |
179 | testWidgets('onPop is called after tap on barrier', (tester) async {
180 | var didPop = false;
181 |
182 | await tester.pumpWidget(createAppWithCenteredButton(const Text('Go')));
183 |
184 | final BuildContext context = tester.element(find.text('Go'));
185 |
186 | showPopover(
187 | context: context,
188 | bodyBuilder: (context) {
189 | return Container(
190 | width: 100.0,
191 | height: 100.0,
192 | alignment: Alignment.center,
193 | child: const Text('Dialog'),
194 | );
195 | },
196 | onPop: () => didPop = true,
197 | );
198 |
199 | await tester.tap(find.text('Go'), warnIfMissed: false);
200 | await tester.pump();
201 |
202 | expect(didPop, isFalse);
203 |
204 | // Tap off the barrier.
205 | await tester.tapAt(const Offset(10.0, 10.0));
206 |
207 | await tester.pumpAndSettle(const Duration(seconds: 1));
208 |
209 | expect(didPop, isTrue);
210 | });
211 |
212 | testWidgets('PopoverItem: direction top test', (tester) async {
213 | await tester.pumpWidget(createAppWithCenteredButton(const Text('Go')));
214 |
215 | final BuildContext context = tester.element(find.text('Go'));
216 |
217 | showPopover(
218 | context: context,
219 | direction: PopoverDirection.top,
220 | bodyBuilder: (context) {
221 | return Container(
222 | width: 100.0,
223 | height: 100.0,
224 | alignment: Alignment.center,
225 | child: const Text('Dialog'),
226 | );
227 | },
228 | );
229 |
230 | await tester.pumpAndSettle(const Duration(seconds: 1));
231 | expect(find.text('Dialog'), findsOneWidget);
232 | });
233 |
234 | testWidgets('PopoverItem: direction left test', (tester) async {
235 | await tester.pumpWidget(createAppWithCenteredButton(const Text('Go')));
236 |
237 | final BuildContext context = tester.element(find.text('Go'));
238 |
239 | showPopover(
240 | context: context,
241 | direction: PopoverDirection.left,
242 | bodyBuilder: (context) {
243 | return Container(
244 | width: 100.0,
245 | height: 100.0,
246 | alignment: Alignment.center,
247 | child: const Text('Dialog'),
248 | );
249 | },
250 | );
251 |
252 | await tester.pumpAndSettle(const Duration(seconds: 1));
253 | expect(find.text('Dialog'), findsOneWidget);
254 | });
255 |
256 | testWidgets('PopoverItem: direction right test', (tester) async {
257 | await tester.pumpWidget(createAppWithCenteredButton(const Text('Go')));
258 |
259 | final BuildContext context = tester.element(find.text('Go'));
260 |
261 | showPopover(
262 | context: context,
263 | direction: PopoverDirection.right,
264 | bodyBuilder: (context) {
265 | return Container(
266 | width: 100.0,
267 | height: 100.0,
268 | alignment: Alignment.center,
269 | child: const Text('Dialog'),
270 | );
271 | },
272 | );
273 |
274 | await tester.pumpAndSettle(const Duration(seconds: 1));
275 | expect(find.text('Dialog'), findsOneWidget);
276 | });
277 | }
278 |
279 | Widget createAppWithButtonThatLaunchesDialog({
280 | required WidgetBuilder dialogBuilder,
281 | }) {
282 | return MaterialApp(
283 | home: Material(
284 | child: Center(
285 | child: Builder(
286 | builder: (context) {
287 | return ElevatedButton(
288 | onPressed: () {
289 | showPopover(
290 | context: context,
291 | bodyBuilder: dialogBuilder,
292 | );
293 | },
294 | child: const Text('Go'),
295 | );
296 | },
297 | ),
298 | ),
299 | ),
300 | );
301 | }
302 |
303 | Widget boilerplate(Widget child) {
304 | return Directionality(
305 | textDirection: TextDirection.ltr,
306 | child: child,
307 | );
308 | }
309 |
310 | Widget createAppWithCenteredButton(Widget child) {
311 | return MaterialApp(
312 | home: Material(
313 | child: Center(
314 | child: ElevatedButton(onPressed: null, child: child),
315 | ),
316 | ),
317 | );
318 | }
319 |
--------------------------------------------------------------------------------