-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[camera_android_camerax] Restore torch state between camera switches #11541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
camsim99
wants to merge
13
commits into
flutter:main
Choose a base branch
from
camsim99:camx-i160956-torchstate
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+731
−17
Draft
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4f67ef5
rebase
camsim99 7a58f80
one camera working on emulator?
camsim99 eb00f8a
it works??? without switching cameras
camsim99 929a070
saved previewview fixes switching cameras, aspect ratio causing jump …
camsim99 d7c47d6
fix example code bug
camsim99 b181e26
working state, need to try to remove workarounds and see if this was …
camsim99 7cd5f5e
inital state
camsim99 fe75707
initial plan
camsim99 a6f4a41
second revision of implemntation plan
camsim99 61911c2
restore android
camsim99 b33f6ae
more cleanup of source + example
camsim99 9aeefb3
implementation plan iteration 3
camsim99 b2ef1cb
first implementation attempt + walkthrough
camsim99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| --- | ||
| name: dart-best-practices | ||
| description: |- | ||
| General best practices for Dart development. | ||
| Covers code style, effective Dart, and language features. | ||
| license: Apache-2.0 | ||
| --- | ||
|
|
||
| # Dart Best Practices | ||
|
|
||
| ## 1. When to use this skill | ||
| Use this skill when: | ||
| - Writing or reviewing Dart code. | ||
| - Looking for guidance on idiomatic Dart usage. | ||
|
|
||
| ## 2. Best Practices | ||
|
|
||
| ### Multi-line Strings | ||
| Prefer using multi-line strings (`'''`) over concatenating strings with `+` and | ||
| `\n`, especially for large blocks of text like SQL queries, HTML, or | ||
| PEM-encoded keys. This improves readability and avoids | ||
| `lines_longer_than_80_chars` lint errors by allowing natural line breaks. | ||
|
|
||
| **Avoid:** | ||
| ```dart | ||
| final pem = '-----BEGIN RSA PRIVATE KEY-----\n' + | ||
| base64Encode(fullBytes) + | ||
| '\n-----END RSA PRIVATE KEY-----'; | ||
| ``` | ||
|
|
||
| **Prefer:** | ||
| ```dart | ||
| final pem = ''' | ||
| -----BEGIN RSA PRIVATE KEY----- | ||
| ${base64Encode(fullBytes)} | ||
| -----END RSA PRIVATE KEY-----'''; | ||
| ``` | ||
|
|
||
| ### Line Length | ||
| Avoid lines longer than 80 characters, even in Markdown files and comments. | ||
| This ensures code is readable in split-screen views and on smaller screens | ||
| without horizontal scrolling. | ||
|
|
||
| **Prefer:** | ||
| Target 80 characters for wrapping text. Exceptions are allowed for long URLs | ||
| or identifiers that cannot be broken. | ||
|
|
||
| ## Related Skills | ||
|
|
||
| - **[dart-modern-features]**: For idiomatic | ||
| usage of modern Dart features like Pattern Matching (useful for deep JSON | ||
| extraction), Records, and Switch Expressions. | ||
|
|
||
| [dart-modern-features]: https://github.com/kevmoo/dash_skills/blob/main/.agent/skills/dart-modern-features/SKILL.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| --- | ||
| name: dart-package-maintenance | ||
| description: |- | ||
| Guidelines for maintaining external Dart packages, covering versioning, | ||
| publishing workflows, and pull request management. Use when updating Dart | ||
| packages, preparing for a release, or managing collaborative changes in a | ||
| repository. | ||
| --- | ||
|
|
||
| # Dart Package Maintenance | ||
|
|
||
| Guidelines for maintaining Dart packages in alignment with Dart team best | ||
| practices. | ||
|
|
||
| ## Versioning | ||
|
|
||
| ### Semantic Versioning | ||
| - **Major**: Breaking changes. | ||
| - **Minor**: New features (non-breaking API changes). | ||
| - **Patch**: Bug fixes, documentation, or non-impacting changes. | ||
| - **Unstable packages**: Use `0.major.minor+patch`. | ||
| - **Recommendation**: Aim for `1.0.0` as soon as the package is stable. | ||
|
|
||
| ### Pre-Edit Verification | ||
| - **Check Published Versions**: Before modifying `CHANGELOG.md` or | ||
| `pubspec.yaml`, ALWAYS check the currently released version (e.g., via | ||
| `git tag` or `pub.dev`). | ||
| - **Do Not Amend Released Versions**: Never add new entries to a version header | ||
| that corresponds to a released tag. | ||
| - **Increment for New Changes**: If the current version in `pubspec.yaml` | ||
| matches a released tag, increment the version (e.g., usually to `-wip`) and | ||
| create a new section in `CHANGELOG.md`. | ||
|
|
||
| - **Consistency**: The `CHANGELOG.md` header must match the new | ||
| `pubspec.yaml` version. | ||
|
|
||
| - **SemVer Guidelines**: | ||
| - **Breaking Changes**: Bump Major, reset Minor/Patch | ||
| (e.g., `2.0.0-wip`, `0.5.0-wip`). | ||
| - **New Features**: Bump Minor, reset Patch | ||
| (e.g., `1.1.0-wip`, `0.4.5-wip`). | ||
| - **Bug Fixes**: Bump Patch (e.g., `1.0.1-wip`). | ||
|
|
||
| ### Changelog Content | ||
| - **Focus on User Impact**: Entries in `CHANGELOG.md` should focus on changes | ||
| visible to or impacting the end-user (e.g., new features, bug fixes, | ||
| breaking changes). | ||
| - **Omit Internal Changes**: Do not include internal refactorings, test | ||
| changes, or other modifications that do not affect the package's behavior | ||
| or API for the user. | ||
|
|
||
| ### Work-in-Progress (WIP) Versions | ||
| - Immediately after a publish, or on the first change after a publish, update | ||
| `pubspec.yaml` and `CHANGELOG.md` with a `-wip` suffix (e.g., `1.1.0-wip`). | ||
| - This indicates the current state is not yet published. | ||
|
|
||
| ### Breaking Changes | ||
| - Evaluate the impact on dependent packages and internal projects. | ||
| - Consider running changes through internal presubmits if possible. | ||
| - Prefer incremental rollouts (e.g., new behavior as opt-in) to minimize | ||
| downstream breakage. | ||
|
|
||
| ## Publishing Process | ||
|
|
||
| 1. **Preparation**: Remove the `-wip` suffix from `pubspec.yaml` and | ||
| `CHANGELOG.md` in a dedicated pull request. | ||
| 2. **Execution**: Run `dart pub publish` (or `flutter pub publish`) and resolve | ||
| all warnings and errors. | ||
| 3. **Tagging**: Create and push a git tag for the published version: | ||
| - For single-package repos: `v1.2.3` | ||
| - For monorepos: `package_name-v1.2.3` | ||
| - Example: `git tag v1.2.3 && git push --tags` | ||
|
|
||
| ## Pull Request Management | ||
|
|
||
| - **Commits**: Each PR should generally correspond to a single squashed commit | ||
| upon merging. | ||
| - **Shared History**: Once a PR is open, avoid force pushing to the branch. | ||
| - **Conflict Resolution**: Prefer merging `main` into the PR branch rather than | ||
| rebasing to resolve conflicts. This preserves the review history and comments. | ||
| - **Reviewing**: Add comments from the "Files changed" view to batch them. | ||
| - **Local Inspection**: Use `gh pr checkout <number>` to inspect changes | ||
| locally in your IDE. |
127 changes: 127 additions & 0 deletions
127
packages/.agents/skills/dart-test-fundamentals/SKILL.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| --- | ||
| name: dart-test-fundamentals | ||
| description: |- | ||
| Core concepts and best practices for `package:test`. | ||
| Covers `test`, `group`, lifecycle methods (`setUp`, `tearDown`), and configuration (`dart_test.yaml`). | ||
| license: Apache-2.0 | ||
| --- | ||
|
|
||
| # Dart Test Fundamentals | ||
|
|
||
| ## When to use this skill | ||
| Use this skill when: | ||
| - Writing new test files. | ||
| - structuring test suites with `group`. | ||
| - Configuring test execution via `dart_test.yaml`. | ||
| - Understanding test lifecycle methods. | ||
|
|
||
| ## Core Concepts | ||
|
|
||
| ### 1. Test Structure (`test` and `group`) | ||
|
|
||
| - **`test`**: The fundamental unit of testing. | ||
| ```dart | ||
| test('description', () { | ||
| // assertions | ||
| }); | ||
| ``` | ||
| - **`group`**: Used to organize tests into logical blocks. | ||
| - Groups can be nested. | ||
| - Descriptions are concatenated (e.g., "Group Description Test Description"). | ||
| - Helps scope `setUp` and `tearDown` calls. | ||
| - **Naming**: Use `PascalCase` for groups that correspond to a class name | ||
| (e.g., `group('MyClient', ...)`). | ||
| - **Avoid Single Groups**: Do not wrap all tests in a file with a single | ||
| `group` call if it's the only one. | ||
|
|
||
| - **Naming Tests**: | ||
| - Avoid redundant "test" prefixes. | ||
| - Include the expected behavior or outcome in the description (e.g., | ||
| `'throws StateError'` or `'adds API key to URL'`). | ||
| - Descriptions should read well when concatenated with their group name. | ||
|
|
||
| - **Named Parameters Placement**: | ||
| - For `test` and `group` calls, place named parameters (e.g., `testOn`, | ||
| `timeout`, `skip`) immediately after the description string, before the | ||
| callback closure. This improves readability by keeping the test logic last. | ||
| ```dart | ||
| test('description', testOn: 'vm', () { | ||
| // assertions | ||
| }); | ||
| ``` | ||
|
|
||
| ### 2. Lifecycle Methods (`setUp`, `tearDown`) | ||
|
|
||
| - **`setUp`**: Runs *before* every `test` in the current `group` (and nested | ||
| groups). | ||
| - **`tearDown`**: Runs *after* every `test` in the current `group`. | ||
| - **`setUpAll`**: Runs *once* before any test in the group. | ||
| - **`tearDownAll`**: Runs *once* after all tests in the group. | ||
|
|
||
| **Best Practice:** | ||
| - Use `setUp` for resetting state to ensure test isolation. | ||
| - Avoid sharing mutable state between tests without resetting it. | ||
|
|
||
| ### 3. Configuration (`dart_test.yaml`) | ||
|
|
||
| The `dart_test.yaml` file configures the test runner. Common configurations | ||
| include: | ||
|
|
||
| #### Platforms | ||
| Define where tests run (vm, chrome, node). | ||
|
|
||
| ```yaml | ||
| platforms: | ||
| - vm | ||
| - chrome | ||
| ``` | ||
|
|
||
| #### Tags | ||
| Categorize tests to run specific subsets. | ||
|
|
||
| ```yaml | ||
| tags: | ||
| integration: | ||
| timeout: 2x | ||
| ``` | ||
|
|
||
| Usage in code: | ||
| ```dart | ||
| @Tags(['integration']) | ||
| import 'package:test/test.dart'; | ||
| ``` | ||
|
|
||
| Running tags: | ||
| `dart test --tags integration` | ||
|
|
||
| #### Timeouts | ||
| Set default timeouts for tests. | ||
|
|
||
| ```yaml | ||
| timeouts: | ||
| 2x # Double the default timeout | ||
| ``` | ||
|
|
||
| ### 4. File Naming | ||
| - Test files **must** end in `_test.dart` to be picked up by the test runner. | ||
| - Place tests in the `test/` directory. | ||
|
|
||
| ## Common commands | ||
|
|
||
| - `dart test`: Run all tests. | ||
| - `dart test test/path/to/file_test.dart`: Run a specific file. | ||
| - `dart test --name "substring"`: Run tests matching a description. | ||
|
|
||
| ## Related Skills | ||
|
|
||
| `dart-test-fundamentals` is the core skill for structuring and configuring | ||
| tests. For writing assertions within those tests, refer to: | ||
|
|
||
| - **[dart-matcher-best-practices]**: | ||
| Use this if the project sticks with the traditional | ||
| `package:matcher` (`expect` calls). | ||
| - **[dart-checks-migration]**: Use this | ||
| if the project is migrating to the modern `package:checks` (`check` calls). | ||
|
|
||
| [dart-matcher-best-practices]: https://github.com/kevmoo/dash_skills/blob/main/.agent/skills/dart-matcher-best-practices/SKILL.md | ||
| [dart-checks-migration]: https://github.com/kevmoo/dash_skills/blob/main/.agent/skills/dart-checks-migration/SKILL.md |
1 change: 1 addition & 0 deletions
1
packages/camera/camera_android_camerax/.agents/skills/dart-best-practices
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| .agents/skills/dart-best-practices/ |
1 change: 1 addition & 0 deletions
1
packages/camera/camera_android_camerax/.agents/skills/dart-package-maintenance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| .agents/skills/dart-package-maintenance/ |
1 change: 1 addition & 0 deletions
1
packages/camera/camera_android_camerax/.agents/skills/dart-test-fundamentals
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| .agents/skills/dart-test-fundamentals/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It used an older version on pigeon? We should instruct it not to do that. Maybe it needs to run
flutter pub upgradeor use pigeon from source.