diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000000..dedd30c6bdc --- /dev/null +++ b/.gitattributes @@ -0,0 +1,39 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Always perform LF normalization on these files +*.c text +*.cc text +*.cmake text +*.dart text +*.gradle text +*.h text +*.html text +*.java text +*.json text +*.md text +*.py text +*.sh text +*.swift text +*.txt text +*.xml text +*.yaml text + +# Make sure that these Windows files always have CRLF line endings in checkout +*.bat text eol=crlf +*.ps1 text eol=crlf +*.rc text eol=crlf +*.sln text eol=crlf +*.props text eol=crlf +*.vcxproj text eol=crlf +*.vcxproj.filters text eol=crlf +# Including templatized versions. +*.sln.tmpl text eol=crlf +*.props.tmpl text eol=crlf +*.vcxproj.tmpl text eol=crlf + +# Never perform LF normalization on these files +*.ico binary +*.jar binary +*.png binary +*.zip binary \ No newline at end of file diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000000..ae93fcaa877 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,22 @@ +*Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.* + +*List which issues are fixed by this PR. For larger changes, raising an issue first helps +reduce redundant work.* + +## Pre-launch Checklist + +- [ ] I read the [Flutter Style Guide] _recently_, and have followed its advice. +- [ ] I signed the [CLA]. +- [ ] I read the [Contributors Guide]. +- [ ] I have added sample code updates to the [changelog]. +- [ ] I updated/added relevant documentation (doc comments with `///`). + + +If you need help, consider asking for advice on the #hackers-devrel channel on [Discord]. + + +[Flutter Style Guide]: https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md +[CLA]: https://cla.developers.google.com/ +[Discord]: https://github.com/flutter/flutter/blob/master/docs/contributing/Chat.md +[Contributors Guide]: https://github.com/flutter/samples/blob/main/CONTRIBUTING.md +[changelog]: ../CHANGELOG.md \ No newline at end of file diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 00000000000..24dada51e37 --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,341 @@ +version: 2 +enable-beta-ecosystems: true +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + labels: + - "autosubmit" + # Updating patch versions for "github-actions" is too chatty. + # See https://github.com/flutter/flutter/issues/158350. + ignore: + - dependency-name: "*" + update-types: ["version-update:semver-patch"] + - package-ecosystem: "npm" + directory: "web_embedding/ng-flutter" + schedule: + interval: "weekly" + ignore: + - dependency-name: "*" + update-types: ["version-update:semver-minor", "version-update:semver-patch"] + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "add_to_app/android_view/flutter_module_using_plugin/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "add_to_app/books/flutter_module_books/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "add_to_app/fullscreen/flutter_module/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "add_to_app/multiple_flutters/multiple_flutters_module/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "add_to_app/plugin/flutter_module_using_plugin/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "add_to_app/prebuilt_module/flutter_module/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "analysis_defaults/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "android_splash_screen/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "animations/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "background_isolate_channels/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "code_sharing/client/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "code_sharing/server/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "code_sharing/shared/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "deeplink_store_example/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "desktop_photo_search/fluent_ui/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "desktop_photo_search/material/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "experimental/context_menus/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "experimental/federated_plugin/federated_plugin/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "experimental/federated_plugin/federated_plugin/example/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "experimental/federated_plugin/federated_plugin_macos/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "experimental/federated_plugin/federated_plugin_platform_interface/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "experimental/federated_plugin/federated_plugin_web/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "experimental/federated_plugin/federated_plugin_windows/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "experimental/material_3_demo/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "experimental/pedometer/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "experimental/pedometer/example/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "experimental/varfont_shader_puzzle/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "experimental/web_dashboard/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "flutter_maps_firestore/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "form_app/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "game_template/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "google_maps/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "infinite_list/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "ios_app_clip/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "isolate_example/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "jsonexample/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "material_3_demo/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "navigation_and_routing/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "place_tracker/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "platform_channels/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "platform_design/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "platform_view_swift/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "provider_counter/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "provider_shopper/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "simple_shader/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "simplistic_calculator/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "simplistic_editor/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "testing_app/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "veggieseasons/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "web/_tool/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "web/samples_index/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "web_embedding/element_embedding_demo/" + schedule: + interval: "daily" + labels: + - "autosubmit" + - package-ecosystem: "pub" + directory: "web_embedding/ng-flutter/flutter/" + schedule: + interval: "daily" + labels: + - "autosubmit" diff --git a/.github/no-response.yml b/.github/no-response.yml new file mode 100644 index 00000000000..c712897ad0a --- /dev/null +++ b/.github/no-response.yml @@ -0,0 +1,16 @@ +# Configuration for probot-no-response - https://github.com/probot/no-response + +# Number of days of inactivity before an issue is closed for lack of response. +daysUntilClose: 14 + +# Label requiring a response. +responseRequiredLabel: "needs-info" + +# Comment to post when closing an Issue for lack of response. +closeComment: >- + Without additional information we're not able to resolve this issue, + so it will be closed at this time. You're still free to add more info + and respond to any questions above, though. We'll reopen the case + if you do. + + Thanks for your contribution! diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml new file mode 100644 index 00000000000..396f360d400 --- /dev/null +++ b/.github/workflows/beta.yml @@ -0,0 +1,69 @@ +name: Beta Branch CI + +# Declare default permissions as read only. +permissions: read-all + +on: + push: + branches: [beta] + pull_request: + branches: [beta] + workflow_dispatch: + +defaults: + run: + shell: bash + +jobs: + # Run the stable test script on the beta channel. Since this branch will soon + # be merged into main as our stable-targeting code, this is the key thing we + # need to test. + stable-tests-on-beta: + runs-on: ${{ matrix.os }} + if: github.repository == 'flutter/samples' + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + - uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 + with: + distribution: 'zulu' + java-version: '17' + - uses: subosito/flutter-action@395322a6cded4e9ed503aebd4cc1965625f8e59a + with: + channel: beta + - run: ./tool/flutter_ci_script_stable.sh + + # Verify the Android add-to-app samples build and pass tests with the beta + # channel. + # android-build: + # runs-on: ubuntu-latest + # if: github.repository == 'flutter/samples' + # steps: + # - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + # - uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 + # with: + # distribution: 'zulu' + # java-version: '17' + # - uses: subosito/flutter-action@395322a6cded4e9ed503aebd4cc1965625f8e59a + # with: + # channel: beta + # - run: ./tool/android_ci_script.sh + + # Verify the iOS add-to-app samples build and pass tests with the beta + # channel. + ios-build: + runs-on: macos-latest + if: github.repository == 'flutter/samples' + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + - uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 + with: + distribution: 'zulu' + java-version: '17' + - uses: subosito/flutter-action@395322a6cded4e9ed503aebd4cc1965625f8e59a + with: + channel: beta + - run: ./tool/ios_ci_script.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000000..d7d013d94fc --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,66 @@ +name: Main Branch CI + +# Declare default permissions as read only. +permissions: read-all + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: + schedule: + - cron: "0 0 * * *" # Every day at midnight + +defaults: + run: + shell: bash + +jobs: + flutter-tests: + name: Test Flutter ${{ matrix.flutter_version }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + if: github.repository == 'flutter/samples' + strategy: + fail-fast: false + matrix: + flutter_version: [stable, beta, master] + os: [ubuntu-latest, macos-latest, windows-latest] + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + - uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 + with: + distribution: 'zulu' + java-version: '17' + - uses: subosito/flutter-action@395322a6cded4e9ed503aebd4cc1965625f8e59a + with: + channel: ${{ matrix.flutter_version }} + - run: ./tool/flutter_ci_script_${{ matrix.flutter_version }}.sh + + # android-build: + # runs-on: ubuntu-latest + # if: github.repository == 'flutter/samples' + # steps: + # - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + # - uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 + # with: + # distribution: 'zulu' + # java-version: '17' + # - uses: subosito/flutter-action@395322a6cded4e9ed503aebd4cc1965625f8e59a + # with: + # channel: stable + # - run: ./tool/android_ci_script.sh + + ios-build: + runs-on: macos-latest + if: github.repository == 'flutter/samples' + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + - uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 + with: + distribution: 'zulu' + java-version: '17' + - uses: subosito/flutter-action@395322a6cded4e9ed503aebd4cc1965625f8e59a + with: + channel: stable + - run: ./tool/ios_ci_script.sh diff --git a/.gitignore b/.gitignore index 345b5e305c9..ee83909856c 100644 --- a/.gitignore +++ b/.gitignore @@ -29,7 +29,7 @@ /build/ # Android related -**/android/**/gradle-wrapper.jar +**/gradle-wrapper.jar **/android/.gradle **/android/captures/ **/android/gradlew @@ -67,6 +67,14 @@ # Web related **/web/**/lib/generated_plugin_registrant.dart +# Service account files +svc-keyfile.json + +# Lockfiles +Podfile.lock +pubspec.lock +yarn.lock + # Exceptions to above rules. !**/ios/**/default.mode1v3 !**/ios/**/default.mode2v3 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4987600e949..00000000000 --- a/.travis.yml +++ /dev/null @@ -1,34 +0,0 @@ -os: - - linux -sudo: false -addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - libstdc++6 - - fonts-noto -git: - depth: 3 -env: - - FLUTTER_VERSION=stable - - FLUTTER_VERSION=beta -matrix: - allow_failures: - - env: FLUTTER_VERSION=beta -before_script: - - git clone https://github.com/flutter/flutter.git -b $FLUTTER_VERSION - - ./flutter/bin/flutter doctor - - chmod +x travis_script.sh -script: - - ./travis_script.sh -cache: - directories: - - $HOME/shared/.pub-cache -notifications: - email: - brogdon+github@gmail.com - -# Only building master means that we don't run two builds for each pull request. -branches: - only: [master] diff --git a/AUTHORS b/AUTHORS index 3da7b5f40e3..1448b6b6516 100644 --- a/AUTHORS +++ b/AUTHORS @@ -5,3 +5,4 @@ Google Inc. Abhijeeth Padarthi +Filip Hracek diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000000..7d8e5b733d8 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,32 @@ +# Changelog + +The purpose of this changelog is to track the freshness of samples and which +samples reflect *current best practices*. It describes **human-made, significant +** changes made to the repository or samples in the repository. + +While all samples in this repository build and run, some of them were written +long ago, and no longer reflect what we want developers to learn. For example, +samples should have been refactored when Dart 3 released to include patterns and +records, where appropriate. + +* **DO include:** + * The addition of new samples. + * The removal of existing samples. + * Considerable refactoring of any given sample. + +* **DO NOT include:** + * Simple changes that reflect minor version bumps in Flutter. For example, + in a recent Flutter update, `Color.red` became `Color.r`. + * Dependency updates. + * Bug fixes. + * Any changes made to simply 'keep the lights on'. + +# Log + +| DATE (YYYY-MM-DD) | Sample(s) | author | Changes | +|-------------------|-------------------|--------------|-----------------------------------------------| +| NEXT GOES HERE | | | | +| | | | | +| 2024-12-04 | N/A - repo change | ericwindmill | Added changelog | +| 2024-11-27 | fake_sample | ericwindmill | Refactored fake_sample to use Dart 3 features | +| 2020-04-17 | fake_sample | ericwindmill | Created fake_sample | diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1998c1dd3c7..57c7199f74e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,35 +1,45 @@ # Contributing -_See also: [Flutter's code of conduct](https://flutter.io/design-principles/#code-of-conduct)_ - Want to contribute to the Flutter sample ecosystem? Great! First, read this page (including the small print at the end). -## Is this the right place for your contribution? +Do you work at Google? Great! You should **definitely** read this page before submitting a PR :) + +* [Before you contribute] +* [Contribute enhancements and fixes] +* [Writing a new sample] +* [Sample checklist] + +_See also: [Flutter's code of conduct]_ + +
+ +# Before you contribute -This repo is used by members of the Flutter team and a few partners as a place -to store example apps and demos. It's not meant to be the one and only source of -truth for Flutter samples or the only place people go to learn about the best -ways to build with Flutter. What that means in practice is that if you've -written a great example app, it doesn't need to be maintained here in order to -get noticed, be of help to new Flutter devs, and have an impact on the -community. -You can maintain your sample app in your own repo (or with another source -control provider) and still be as important a part of the Flutter-verse as -anything you see here. You can let us know on the -[FlutterDev Google Group](https://groups.google.com/forum/#!forum/flutter-dev) -when you've published something and Tweet about it with the -[#flutterio](https://twitter.com/search?q=%23flutterio) hashtag. +## Is this the right place for your sample? -## So what should be contributed here, then? +In most cases, if you've written a great sample app, it should be maintained +in your own repoistory. You can maintain your sample app in your own repo +(or with another source control provider) and still be as important a part of +the Flutter-verse as anything you see here. -Fixes and necessary improvements to the existing samples, mostly. +**What should be contributed here, then?** -## Before you contribute +Fixes and necessary improvements to the existing samples, mostly. + +## File an issue first! + +If you see a bug or have an idea for a feature that you feel would improve one +of the samples already in the repo, **please [file an issue] before you begin +coding or send a PR**. This will help prevent duplicate work by letting us know +what you're up to. It will help avoid a situation in which you spend a lot of +time coding something that's not quite right for the repo or its goals. + +## Sign the license agreement. Before we can use your code, you must sign the -[Google Individual Contributor License Agreement](https://cla.developers.google.com/about/google-individual) +[Google Individual Contributor License Agreement] (CLA), which you can do online. The CLA is necessary mainly because you own the copyright to your changes, even after your contribution becomes part of our codebase, so we need your permission to use and distribute your code. We also @@ -43,20 +53,221 @@ us first through the issue tracker with your idea so that we can help out and possibly guide you. Coordinating up front makes it much easier to avoid frustration later on. -## Code reviews +
-All submissions, including submissions by project members, require review. +# Contribute enhancements and fixes + +Enhancements and bug fixes are welcome and appreciated. +If you spot an [issue] that you might want to fix but aren't sure how to get started, +feel free to comment on the issue and tag @ericwindmill with questions. + +## Filing issues and evaluating existing samples + +You can also contribute by filing issues against existing samples. This is thankless work +and is _greatly_ appreciated. It's also a good way to familiarize yourself with the repository. + +To evaluate a sample for possible issues, use the [Sample checklist] below. + +
+ +# Writing a new sample + +Before filing an issue for a new sample or submitting a PR, you must read the rest of this page. + +## What is a sample? + +Samples are reference materials that teach developers how to solve a specific problem. +Samples contain **correct and concise code** that developers can +**quickly understand** and **easily reuse** with minimal side effects. + +### What samples should we have? + +Samples in this repo demonstrates how to **use current features** of the **Flutter and Dart SDKs** using **best practices**. +In other words, a sample should meet the following criteria: + +* Demonstrates _how to use the SDKS_ rather than show an end-product. +* Covers a critical developer journey in the SDK that is useful to >80% of developers. +* Prefers primitives in the SDK over libraries. +* Demonstrates features available on the stable channel of Flutter. + +These guidelines can be broken in rare cases. For example, this is likely the best place in the +Flutter github org for demo apps, but those demo apps must be justified. + +## Is this the right place for your sample? (revisited) + +Validate your idea against the following criteria: + +1. **The sample solves a single problem or set of tightly coupled problems.**
+ If not, you're either writing a Demo app or an extended sample. These might + still be appropriate for the samples repos, but need to be justified. + +2. **The target audience for the sample isn’t beginners.** +3. **The sample code isn’t so complex that it needs video or text explanation.**
+ Samples are reference materials, and the code should speak for itself. If either of these aren't true, + you may prefer to write a blogpost or tutorial. + +5. **The sample isn’t tied to an event.**
+ If it is, you should likely use a personal repository. + +5. **The sample isn’t tied to a library or package.**
+ If it is, the usage example should likely be in the [repository of that package]. + +6. **The topic doesn’t have crossover with any existing samples.**
+ If it does, ensure that it wouldn't be better to update the existing sample. + +## What are your ongoing maintenance resposibilities? + +All sample code has an unbound maintenance cost. If you cannot commit to maintaining a sample +(for the forseeable future, barring changes in life circumstances), then you should talk to the +[primary maintainers] of this project, particularly @ericwindmill, before submitting a PR. + +Any new sample **must** have a CODEOWNER, and that owner is most likely you (the author). + +## What type of sample are your writing? + +This repository contains two types of sample apps: **quickstarts** and **demo apps**. + +### Quickstarts + +* **Purpose**: Provides starting points that a developer can extend. + Solves specific problems or implements generic app features. +* **Size**: <= 200 lines of code, not including boiler plate (guide, not rule) +* **Qualities:** + * Contains one feature or a small set of related features, but generally runnable. + * Generic and un-opinionated about the context in which it is used. + * Prioritizes being generic over best practices. + * The code is Copy+paste-able. + * In Flutter, this means that the code that is being demonstrated should be separated from and boiler plate (i.e. `runApp`) +* **Audience:** + * Developers with Flutter and Dart experience that don't need code explained to them. +* **Answers the questions:** + * “What’s the minimal amount of code needed to implement this feature…” + * “... so I can understand how it works?” + * “... so I can understand how to add it to my app?” + * “How can I make sure I know how to extend this feature without missing anything?” + * "What code should I use as a starting point given I want to solve a very similar problem?" + +### Demo apps + +* **Purpose**: Meant to be built and ran. Demos the _product_, not how to write code. +* **Criteria**: Demo apps _only_ belong here if they... + * ...aren't tied to an event or moment in time. + * ...aren't tied to another resource (website, workshop, etc). + * ...don't require explanation (other than a short README). + * ...aren't primarily used to demonstrate an SDK feature. + +### Other sample types + +Other sample types, like demo apps that accompany docs or events, do not belong in this repository. +They should be maintained alongside the accompanying resources (i.e. in the website repository), or in a personal repository. + +### The `experimental` folder + +The experimental folder is being deprecated. If you have an experiemental sample project, +you should manage it in a personal repository until it runs on the stable channel. + +
+ +# Sample checklist + +Every piece of code will have value to someone, but it is easy for maintenance costs to grow over time. +The more items checked on this list, the higher the value and lower the maintenance costs. + +Use this checklist to write new samples and evaluate existing ones. + +**NB:** Demo apps have looser requirements. Use your best judgement when following the guidelines. + +* Code + - [ ] Be designed to build against the current [stable] + release of the Flutter SDK. + - [ ] Sample is the only one for the API in question (across all Dash samples) + - [ ] Repository and pubspec name are titled for its ingredients (i.e. mvvm_architecture instead of compass_app) + - [ ] Only includes the minimal required code to demonstrate the feature or API and run the code. + - [ ] Sample favors 1P dependencies over 3P. + - [ ] Code has been sufficiently explained with doc comments. + - [ ] The sample app separates its bespoke code from general Flutter or Dart code. + - [ ] Favor readability over best practices unless readability requires an anti pattern. Use your best judgment. + - [ ] Avoid adding an onerous amount of blobs (typically images or other assets) to the repo. + - [ ] All files in the project must start with the appropriate [file headers]. + +* Tests, style and maintenance + - [ ] Sample has Dart tests that cover the business logic + - [ ] Sample is wired into the list of projects in the CI scripts for [stable](tool/flutter_ci_script_stable.sh), + [beta](tool/flutter_ci_script_beta.sh), and [master](tool/flutter_ci_script_master.sh), + which runs the analyzer, the formatter, and `flutter test`. + - [ ] Sample has a codeowner (it's likely you, the author) + - [ ] Sample is formatted with `dart format`. + - [ ] Sample has no analyzer errors or warnings. + - [ ] Add the new project directory to the [dependabot](.github/dependabot.yaml) configuration + to keep dependencies updated in an on-going basis. + - [ ] Follows the [Flutter style guide] + - [ ] Include the top level [`analysis_options.yaml`](analysis_options.yaml) + file used throughout the repo. This file include a base set of analyzer + conventions and lints. + +* README + - [ ] Describes the apps design and purpose. + - [ ] Describes common errors and debugging steps. + - [ ] Describes any steps necessary to build and run. + - [ ] Has ‘Open in IDX’ button, and a nix file (if compatible with IDX). ## File headers All files in the project must start with the following header. - // Copyright 2018 The Chromium Authors. All rights reserved. - // Use of this source code is governed by a BSD-style license that can be - // found in the LICENSE file. +``` +// Copyright 2024 The Flutter team. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +``` + +
+ +# Code reviews + +All submissions, including submissions by project members, require review. -## The small print +This repo is part of the [Flutter](https://github.com/flutter) GitHub account, +which means that a lot of folks have the ability to push and merge code. The +primary maintainers, though, are: + +* [@RedBrogdon](https://github.com/RedBrogdon) +* [@johnpryan](https://github.com/johnpryan) +* [@domesticmouse](https://github.com/domesticmouse) +* [@ericwindmill](https://github.com/ericwindmill) + +You are free to add one of these folks (particularly @ericwindmill) as a reviewer +to any PR sent to this repo. We're happy to comment, answer (or ask) questions, +and provide feedback. + +If you're part of a team that's already landed a sample in the repo (Hi, +Material!), and you're updating or fixing that sample, you are *not* expected to +wait on one of the above folks before merging the code. Have it reviewed by +someone you trust on your own team, and then merge it. + +However, if you're adding a new sample, updating a sample you've never worked on +before, or changing something that's a meta-concern like the CI setup, web +hosting, project setup, etc., please include one of the primary maintainers as a +reviewer. + +
+ +# The small print Contributions made by corporations are covered by a different agreement than the -one above, the -[Software Grant and Corporate Contributor License Agreement](https://developers.google.com/open-source/cla/corporate). +one above, the [Software Grant and Corporate Contributor License Agreement]. + +[Flutter's code of conduct]: https://github.com/flutter/flutter/blob/master/CODE_OF_CONDUCT.md +[Before you contribute]: https://github.com/flutter/samples/blob/main/CONTRIBUTING.md#before-you-contribute +[Contribute enhancements and fixes]: https://github.com/flutter/samples/blob/main/CONTRIBUTING.md#contribute-enhancements-and-fixes +[Writing a new sample]: https://github.com/flutter/samples/blob/main/CONTRIBUTING.md#writing-a-new-sample +[Sample checklist]: https://github.com/flutter/samples/blob/main/CONTRIBUTING.md#samples-checklist +[file headers]: https://github.com/flutter/samples/blob/main/CONTRIBUTING.md#file-headers +[Software Grant and Corporate Contributor License Agreement]: https://developers.google.com/open-source/cla/corporate +[issue]: https://github.com/flutter/samples/issues +[file an issue]: https://github.com/flutter/samples/issues/new +[repository of that package]: https://dart.dev/tools/pub/package-layout#examples +[stable]: https://github.com/flutter/flutter/blob/master/docs/releases/Flutter-build-release-channels.md +[Flutter style guide]: (https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md) +[Google Individual Contributor License Agreement]: https://cla.developers.google.com/about/google-individual +[primary maintainers]: https://github.com/flutter/samples/blob/main/CONTRIBUTING.md#code-reviews diff --git a/INDEX.md b/INDEX.md deleted file mode 100644 index 39959ac75d5..00000000000 --- a/INDEX.md +++ /dev/null @@ -1,153 +0,0 @@ -# A curated list of samples - -Contained in this list are sample apps, demos, and examples that can help you -grow your Flutter skills. Some are maintained here by the Flutter team, -but many have been created by the Flutter community and are kept in other repos -in and out of GitHub. - -This is not an exhaustive list of samples, and just because a project -isn't listed here doesn't mean that it's not worth exploring. Similarly, while -the Flutter team works to keep this list up to date, there are plenty of others -created by the community, such as -[Awesome Flutter](https://github.com/Solido/awesome-flutter) from @Solido. - -***Please don't submit pull requests directly updating this file. While we're -always happy to learn of new samples from the community, we need -to keep this file small. There are plenty of user-maintained indices (like -[Awesome Flutter](https://github.com/Solido/awesome-flutter)) that are meant to -be exhaustive, and those are great places for submitting your own work.*** - -## How-to Collections - -#### [Flutter Examples](https://github.com/nisrulz/flutter-examples) [![GitHub stars](https://img.shields.io/github/stars/nisrulz/flutter-examples.svg?style=social&label=Star)](https://github.com/nisrulz/flutter-examples) [![GitHub forks](https://img.shields.io/github/forks/nisrulz/flutter-examples.svg?style=social&label=Fork)](https://github.com/nisrulz/flutter-examples/fork) - -A collection of single-topic examples from Nishant Srivastava. These include -everything from gradients to JSON to routing and more. - -#### [Flutter Example Apps](https://github.com/iampawan/FlutterExampleApps) [![GitHub stars](https://img.shields.io/github/stars/iampawan/FlutterExampleApps.svg?style=social&label=Star)](https://github.com/iampawan/FlutterExampleApps) [![GitHub forks](https://img.shields.io/github/forks/iampawan/FlutterExampleApps.svg?style=social&label=Fork)](https://github.com/iampawan/FlutterExampleApps/fork) - -Several dozen examples from Flutter GDE Pawan Kumar. These cover state -management, Firebase, UI design, and many other topics. Each one comes with a -YouTube video showing implementation. - -#### [Flutter by Example](https://github.com/mjohnsullivan/flutter-by-example) [![GitHub stars](https://img.shields.io/github/stars/mjohnsullivan/flutter-by-example.svg?style=social&label=Star)](https://github.com/mjohnsullivan/flutter-by-example) [![GitHub forks](https://img.shields.io/github/forks/mjohnsullivan/flutter-by-example.svg?style=social&label=Fork)](https://github.com/mjohnsullivan/flutter-by-example/fork) - -Twenty-odd samples detailing common tasks with Flutter: how to use text fields, -streams and StreamBuilders, and more. - -#### [Flutter for web samples](web) _(Flutter team)_ - -A collection of Flutter samples structured as Flutter for web projects. You -can see them in action at https://flutter.github.io/samples. - -## Architecture / networking / backend - -#### [Flutter Architectural Samples](https://github.com/brianegan/flutter_architecture_samples) [![GitHub stars](https://img.shields.io/github/stars/brianegan/flutter_architecture_samples.svg?style=social&label=Star)](https://github.com/brianegan/flutter_architecture_samples) [![GitHub forks](https://img.shields.io/github/forks/brianegan/flutter_architecture_samples.svg?style=social&label=Fork)](https://github.com/brianegan/flutter_architecture_samples/fork) - -Brian Egan's implementations of TodoMVC using a variety of state management and -architectural approaches. If you'd like to see how an app built with -`flutter-redux` is different from one using BLoC, this is a great place to -start. - -#### [jsonexample](jsonexample) _(Flutter team)_ - -A simple app showing three different approaches to deserializing JSON: -hand-written constructors, `json_serializable`, and `built_value`. - -#### [provider_counter](provider_counter) _(Flutter team)_ - -The simplest possible app (the counter) using `provider` -for state management. This was previously known as `scoped_model_counter`, -and used `scoped_model` for state management. - -#### [provider_shopper](provider_shopper) _(Flutter team)_ - -A slightly more complex example of state management with `provider`. -This example demonstrates multiple `providers`, navigation between screens, -and some other advanced topics. - -## UI - -#### [Veggie Seasons](veggieseasons) _(Flutter team)_ - -[Available on the App Store!](https://itunes.apple.com/is/app/veggie-seasons/id1450855435) - -Veggie Seasons is a published iOS app that displays seasonality, vitamin -content, and trivia for a bunch of different fruits and veggies. If you're -interested in learning how to use Flutter's -[Cupertino](https://flutter.dev/docs/development/ui/widgets/cupertino) package -to build interfaces for iOS, it's a great place to start. - -#### [Flutter UI Kit](https://github.com/iampawan/Flutter-UI-Kit) [![GitHub stars](https://img.shields.io/github/stars/iampawan/Flutter-UI-Kit.svg?style=social&label=Star)](https://github.com/iampawan/Flutter-UI-Kit) [![GitHub forks](https://img.shields.io/github/forks/iampawan/Flutter-UI-Kit.svg?style=social&label=Fork)](https://github.com/iampawan/Flutter-UI-Kit/fork) -Another sample from Flutter GDE Pawan Kumar, this repo includes a variety of -polished UI examples. - -#### [FlutterPlayground](https://github.com/ibhavikmakwana/FlutterPlayground) [![GitHub stars](https://img.shields.io/github/stars/ibhavikmakwana/FlutterPlayground.svg?style=social&label=Star)](https://github.com/ibhavikmakwana/FlutterPlayground) [![GitHub forks](https://img.shields.io/github/forks/ibhavikmakwana/FlutterPlayground.svg?style=social&label=Fork)](https://github.com/ibhavikmakwana/FlutterPlayground/fork) - -A repo full of short, specific examples (with animated screenshots!) showing -commonly used widgets and how to put them to work. - -#### [Flutter Challenges](https://github.com/matthew-carroll?tab=repositories&q=flutter_ui_challenge) -More a GitHub search result than a single repo, Matt Carroll's Flutter UI -challenges showcase some amazing designs powered by Flutter. Make sure to check -the accompanying YouTube video so you can watch Matt implement them. - -#### [Platform Design](platform_design) _(Flutter team)_ - -An app designed to look great on both iOS and Android, this sample -shows how to add platform-specific design touches to an app -while reusing as much code as possible. - -#### [Animation examples](animations) _(Flutter team)_ - -_currently in development_ - -A collection of animation examples. The app starts with basic concepts like -`AnimationController` and `Tween`, then progresses to transitions and -advanced demos. - -## Maps - -#### [Place tracker](place_tracker) _(Flutter team)_ - -A simple integration of the Google Maps plugin for Flutter, this app -shows how to add a map to the Flutter widget hierarchy, create markers, -and more. - -#### [Flutter, maps, and Cloud Firestore](flutter_maps_firestore) _(Flutter team)_ - -This app shows the use of a Google map with data loaded from Cloud Firestore. -It was [built live on stage](https://www.youtube.com/watch?v=RpQLFAFqMlw) at -Cloud Next '19. - -## Full apps - -#### [It's All Widgets!](https://itsallwidgets.com?open_source=true) -Created and maintained by the Flutter community, *It's All Widgets* collects -links to apps built with Flutter. Many are open source and include links to -their source code, so you can browse through the list until you find something -that looks interesting, and then go see how it was built. - -#### [inKino](https://github.com/roughike/inKino) [![GitHub stars](https://img.shields.io/github/stars/roughike/inKino.svg?style=social&label=Star)](https://github.com/roughike/inKino) [![GitHub forks](https://img.shields.io/github/forks/roughike/inKino.svg?style=social&label=Fork)](https://github.com/roughike/inKino/fork) -An unofficial Finnkino client that shows movies and showtimes of Finnkino -cinemas in Finland. It uses Redux, has a comprehensive set of tests, and shares -40% of its code between the Flutter app and the AngularDart web app. -It's currently available in the -[App Store](https://itunes.apple.com/gb/app/inkino/id1367181450?mt=8), -[Play Store](https://play.google.com/store/apps/details?id=com.roughike.inkino) -and as a [Progressive Web App](https://inkino.app). - -#### [FlutterFlip](https://github.com/redbrogdon/flutterflip) [![GitHub stars](https://img.shields.io/github/stars/redbrogdon/flutterflip.svg?style=social&label=Star)](https://github.com/redbrogdon/flutterflip) [![GitHub forks](https://img.shields.io/github/forks/redbrogdon/flutterflip.svg?style=social&label=Fork)](https://github.com/redbrogdon/flutterflip/fork) -A simple reversi clone built with Flutter. It showcases some implicit animations, -a stream-based, reactive architecture, and a technique to move work off the UI -thread and into an isolate. - -## Demos - -#### [Shrine](gallery/gallery/lib/studies/shrine) _(Flutter team)_ -The Shrine demo app from the Flutter team. It's designed to showcase how apps -can put their own spin on the Material Design components and how to use -ScopedModel to maintain app state across screens. - -#### [Flutter Gallery](gallery) _(Flutter team)_ -The official Flutter Gallery. There's tons of stuff in here. Just tons. diff --git a/MAINTENANCE.md b/MAINTENANCE.md deleted file mode 100644 index 72c7bfa1c13..00000000000 --- a/MAINTENANCE.md +++ /dev/null @@ -1,22 +0,0 @@ -# Sample app maintenance log - -This table records the last time someone from the Flutter team came did a -maintenance pass on a particular sample (read through the code, updated it to -match any new language/SDK features, etc.). - -| Sample | GH username | Date Updated | -| :------------------------ | -----------------: | -------------: | -| animations | theacodes | 10/7/19 | -| chrome-os-best-practices | | | -| experimental | | | -| flutter_maps_firestore | | | -| isolate_example | johnpryan | 11/21/19 | -| jsonexample | | | -| material_studies/shrine | | | -| place_tracker | | | -| platform_design | johnpryan | 10/7/19 | -| platform_view_swift | redbrogdon | 10/7/19 | -| provider_counter | redbrogdon | 11/21/19 | -| provider_shopper | redbrogdon | 11/21/19 | -| veggieseasons | | | -| web | | | diff --git a/README.md b/README.md index b5ba0c327b3..3b2b7e0bc57 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,191 @@ # Flutter samples -[![Build Status](https://travis-ci.org/flutter/samples.svg?branch=master)](https://travis-ci.org/flutter/samples) +[![Build Status](https://github.com/flutter/samples/workflows/Main%20Branch%20CI/badge.svg)](https://github.com/flutter/samples/actions?workflow=Main%20Branch%20CI) A collection of open source samples that illustrate best practices for -[Flutter](https://flutter.io). +[Flutter]. ## Index -For a curated list of samples in this repo and elsewhere, see the -[index](INDEX.md). +### Quickstarts + +* [`asset_transformation`] - Demonstrates how to transform images' color scales and formats. +* [`background_isolate_channels`] - Demonstrates how to use long-lived isolates. +* [`code_sharing`] - Demonstrates how to share business logic between Flutter client and Dart server using [`package:shelf`] ) +* [`context_menus`] - This sample shows how to create and customize cross-platform context menus, such as the text selection toolbar on mobile or the right click menu on desktop. +* [`desktop_photo_search`] - Demonstrates desktop features in both Material and FluentUI design systems. +* [`dynamic_theme`] - A developer sample demonstrating how to call on-device Flutter APIs based on output from the Gemini API. +* [`form_app`] - A sample demonstrating different types of forms and best practices. +* [`game_template`] - (**note: deprecated!**) A starter game in Flutter with all the bells and whistles of a mobile (iOS & Android) game. +* [`gemini_tasks`] - A developer sample written in Flutter demonstrating how to interact with a to-do list in natural language using the Gemini API. +* [`google_maps`] - Demonstrates the Google Maps for Flutter plugin. +* [`infinite_list`] - A Flutter sample app that shows an implementation of the "infinite list" UX pattern. +* [`isolate_example`] - A sample application that demonstrate best practices when using [isolates]. +* [`navigation_and_routing`] - A sample that shows how to use [go_router] API to handle common navigation scenarios. +* [`place_tracker`] - A sample place tracking app that uses the [google_maps_flutter plugin]. +* [`platform_design`] - This sample project shows a Flutter app that maximizes application code reuse while adhering to different design patterns on Android and iOS. +* [`provider_counter`] - The starter Flutter application, but using [package:provider] to manage state. +* [`provider_shopper`] - A Flutter sample app that shows a state management approach using [package:provider]. +* [`simple_shader`] - A simple [Flutter fragment shaders] sample project. +* [`simplistic_calculator`] - A calculator to demonstrate a simple start for a desktop Flutter app. +* [`simplistic_editor`] - This sample text editor showcases the use of [TextEditingDeltas] and a DeltaTextInputClient to expand and contract styled ranges of text. +* [`testing_app`] - A sample app that shows different types of testing in Flutter. +* [`web_embedding`] - This directory contains examples of how to embed Flutter in web apps (without iframes). + * [`element_embedding_demo`] - Modifies the index.html of a flutter app so it is launched in a custom hostElement. This is the most basic embedding example. + * [`ng-flutter`] - A simple Angular app (and component) that replicates the above example, but in an Angular style. + +### Native platform samples + +* [`add-to-app`] - Collection of samples that demonstrate embedding Flutter a view into a native app. + * [`fullscreen`] — Embeds a full screen instance of + Flutter into an existing iOS or Android app. + * [`prebuilt_module`] — Embeds a full screen + instance of Flutter as a prebuilt library that can be loaded into an existing + iOS or Android app. + * [`plugin`] — Embeds a full screen Flutter instance that + is using plugins into an existing iOS or Android app. + * [`books`] — Mimics a real world use-case of embedding Flutter into an + existing Android app and demonstrates using [Pigeon] to communicate between Flutter and + the host application. + * [`multiple_flutters`] — Shows the usage of the Flutter + Engine Group APIs to embed multiple instances of Flutter into an existing app + with low memory cost. + * [`android_view`] — Shows how to integrate a Flutter + add-to-app module at a view level for Android. +* [`android_splash_screen`] +* [`ios_app_clip`] +* [`platform_channels`] - A sample app which demonstrates how to use MethodChannel, EventChannel, BasicMessageChannel and MessageCodec in Flutter. +* [`platform_view_swift`] - A Flutter sample app that combines a native iOS UIViewController with a full-screen Flutter view. + +### Demo galleries + +* [`animations`] - Showcases Flutter's animation features +* [`material_3_demo`] - showcases [Material 3] features in the Flutter Material library. + +### Demo apps + +* [`compass_app`] - A sample application that implements MVVM architecture. +* [`deeplink_store_example`] - A demo app that implements deep-linking with go_router. +* [`veggie_seasons`] - A demo application. + +## Flutter sample code + +Samples are **correct and concise code** that developers +can **quickly understand** and **easily reuse** with minimal side effects. +Samples teach developers how to be successful using Flutter and Dart. +They are maintained on an ongoing basis +to reflect changing APIs and best practices. + +### Types of samples + +There are two types of sample code in this repository: + +* **Quickstarts** provide a starting point to extend. They answer the question, + "What is the minimal amount of code needed to implement this feature?" +* **Demo apps** are meant to be built and ran. They demo the _product_, + not how to write code. + +A majority of samples in this repository are quickstarts. + +## Usage + +Every sample in this repo is fully runnable. To run an example, +use `flutter run` inside that example's directory. +See the [getting started guide] to install the `flutter` tool. + +> [!IMPORTANT] +> If you want to run an add-to-app sample, there are additional requirements. +> We suggest reading the [add-to-app documentation]. + +### Tip: minimize download size + +As this repository is quite big, you can use +[svn] to download a single example. +For example: + +``` +svn co https://github.com/flutter/samples/trunk/provider_shopper +``` + +You can also use a [partial clone] to skip blob objects +that aren't currently checked out, while including the full commit history: + +``` +git clone --filter=blob:none https://github.com/flutter/samples.git +``` ## Interested in contributing? -See the [contributor's guide](CONTRIBUTING.md)! +See the [contributor's guide]! ## Questions or issues? If you have a general question about one of these samples or how to adapt its techniques for one of your own apps, try one of these resources: -* [The FlutterDev Google Group](https://groups.google.com/forum/#!forum/flutter-dev) -* [The Flutter Gitter channel](https://gitter.im/flutter/flutter) -* [StackOverflow](https://stackoverflow.com/questions/tagged/flutter) +* [The FlutterDev Discord] +* [The Flutter Community forum] If you run into a bug in one of the samples, please file an issue in the -[main Flutter repo](https://github.com/flutter/flutter/issues). +[`flutter/samples` issue tracker]. + + +[`asset_transformation`]: ./asset_transformation +[`background_isolate_channels`]: ./background_isolate_channels +[`code_sharing`]: ./code_sharing +[`context_menus`]: ./context_menus +[`desktop_photo_search`]: ./desktop_photo_search +[`dynamic_theme`]: ./dynamic_theme +[`form_app`]: ./form_app +[`game_template`]: ./game_template +[`gemini_tasks`]: ./gemini_tasks +[`google_maps`]: ./google_maps +[`infinite_list`]: ./infinite_list +[`isolate_example`]: ./isolate_example +[`navigation_and_routing`]: ./navigation_and_routing +[`place_tracker`]: ./place_tracker +[`platform_design`]: ./platform_design +[`provider_counter`]: ./provider_counter +[`provider_shopper`]: ./provider_shopper +[`simple_shader`]: ./simple_shader +[`simplistic_calculator`]: ./simplistic_calculator +[`simplistic_editor`]: ./simplistic_editor +[`testing_app`]: ./testing_app +[`web_embedding`]: ./web_embedding +[`element_embedding_demo`]: ./web_embedding/element_embedding_demo +[`ng-flutter`]: ./web_embedding/ng-flutter +[`add-to-app`]: ./add_to_app +[`fullscreen`]: ./add_to_app/fullscreen +[`prebuilt_module`]: ./add_to_app/prebuilt_module +[`plugin`]: ./add_to_app/plugin +[`books`]: ./add_to_app/books +[`multiple_flutters`]: ./add_to_app/multiple_flutters +[`android_view`]: ./add_to_app/android_view +[`android_splash_screen`]: ./android_splash_screen +[`ios_app_clip`]: ./ios_app_clip +[`platform_channels`]: ./platform_channels +[`platform_view_swift`]: ./platform_view_swift +[`animations`]: ./animations +[`material_3_demo`]: ./material_3_demo +[`compass_app`]: ./compass_app +[`deeplink_store_example`]: ./deeplink_store_example +[`veggie_seasons`]: ./veggieseasons + +[Flutter]: https://flutter.dev +[getting started guide]: https://docs.flutter.dev/get-started/install +[add-to-app documentation]: https://docs.flutter.dev/add-to-app +[isolates]: https://api.dart.dev/dart-isolate/Isolate-class.html +[Material 3]: https://m3.material.io +[go_router]: https://pub.dev/packages/go_router +[google_maps_flutter plugin]: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter +[package:provider]: https://pub.dev/packages/provider +[Flutter fragment shaders]: https://docs.flutter.dev/development/ui/advanced/shaders +[TextEditingDeltas]: https://api.flutter.dev/flutter/services/TextEditingDelta-class.html +[Pigeon]: https://pub.dev/packages/pigeon +[`package:shelf`]: https://pub.dev/packages/shelf +[svn]: https://subversion.apache.org/ +[partial clone]: https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/ +[contributor's guide]: CONTRIBUTING.md +[The FlutterDev Discord]: https://discord.gg/rflutterdev +[The Flutter Community forum]: https://forum.itsallwidgets.com/latest +[`flutter/samples` issue tracker]: https://github.com/flutter/samples/issues diff --git a/add_to_app/README.md b/add_to_app/README.md index 9e5c613fe13..1109a13218b 100644 --- a/add_to_app/README.md +++ b/add_to_app/README.md @@ -1,20 +1,42 @@ -# Add-to-App Sample - -This directory contains a bunch of Android and iOS projects that each import a -standalone Flutter module. - -## Goals for this sample +# Add-to-App Samples + +This directory contains Android and iOS projects that import and use a Flutter +module. They're designed to show recommended approaches for [adding Flutter to +existing Android and iOS apps](https://docs.flutter.dev/add-to-app). + +## Samples Listing + +* [`fullscreen`](./fullscreen) — Embeds a full screen instance of + Flutter into an existing iOS or Android app. +* [`prebuilt_module`](./prebuilt_module) — Embeds a full screen + instance of Flutter as a prebuilt library that can be loaded into an existing + iOS or Android app. +* [`plugin`](./plugin) — Embeds a full screen Flutter instance that + is using plugins into an existing iOS or Android app. +* [`books`](./books) — Mimics a real world use-case of embedding Flutter into an + existing Android app and demonstrates using + [Pigeon](https://pub.dev/packages/pigeon) to communicate between Flutter and + the host application. +* [`multiple_flutters`](./multiple_flutters) — Shows the usage of the Flutter + Engine Group APIs to embed multiple instances of Flutter into an existing app + with low memory cost. +* [`android_view`](./android_view) — Shows how to integrate a Flutter + add-to-app module at a view level for Android. + +## Goals for these samples * Show developers how to add Flutter to their existing applications. * Show the following options: - - Whether to build the Flutter module from source each time the app builds or + * Whether to build the Flutter module from source each time the app builds or rely on a separately pre-built module. - - Whether plugins are needed by the Flutter module used in the app. + * Whether plugins are needed by the Flutter module used in the app. +* Show Flutter being integrated ergonomically with applications with existing + middleware and business logic data classes. ## Installing Cocoapods -The iOS samples in this repo require the latest version of Cocoapods. To install -it, run the following command on a MacOS machine: +The iOS samples in this repo require the latest version of Cocoapods. To make +sure you've got it, run the following command on a macOS machine: ```bash sudo gem install cocoapods @@ -22,131 +44,36 @@ sudo gem install cocoapods See https://guides.cocoapods.org/using/getting-started.html for more details. -## The important bits - -### Flutter modules - -There are two Flutter modules included in the codebase: - -* `flutter_module` displays the dimensions of the screen, a button that - increments a simple counter, and an optional exit button. -* `flutter_module_using_plugin` does everything `flutter_module` does and adds - another button that will open the Flutter documentation in a browser using the - [`url_launcher`](https://pub.dev/packages/url_launcher) Flutter plugin. - -Before using them, you need to resolve the Flutter modules' dependencies. Do so -by running this command from within the `flutter_module` and -`flutter_module_using_plugin` directories: - -```bash -flutter packages get -``` - -### Android and iOS applications - -In addition to the Flutter modules, this repo also includes a number of -Android and iOS applications that demonstrate different ways of importing -them. - -With the exception of `android_using_prebuilt_module`, the Android apps are -ready to run once you've completed the `flutter packages get` commands listed -above. Two of the iOS apps (`ios_fullscreen` and `ios_using_plugin`) use -Cocoapods, though, so you need to run this command within their project -directories to install their dependencies: - -```bash -pod install -``` - -Once that command is complete, you'll find an `xcworkspace` file in the project -directories with the correct Flutter module (and any other dependencies) -included. Open that workspace file, and the app is ready to build and run. - -### `android_fullscreen` and `ios_fullscreen` - -These apps showcase a relatively straightforward integration of -`flutter_module`: - -* The Flutter module is built along with the app when the app is built. -* The Flutter engine is warmed up at app launch. -* The Flutter view is presented with a full-screen Activity or - UIViewController. -* The Flutter view is a navigational leaf node; it does not launch any new, - native Activities or UIViewControllers in response to user actions. +## Debugging -If you are new to Flutter's add-to-app APIs, these projects are a great place -to begin learning how to use them. +You can `flutter attach` to the running host application to [debug the Flutter +module](https://docs.flutter.dev/add-to-app/debugging). This will +allow you to hot reload, set breakpoints, and use DevTools and other debugging +functionality, similar to a full Flutter app. -### `android_using_plugin` and `ios_plugin` +## Issues -These apps are similar to `android_fullscreen` and `ios_fullscreen`, with the -following differences: - -* Rather than importing `flutter_module`, they import - `flutter_module_using_plugin`. -* They include the native code (Kotlin or Swift) required to initialize plugins - at Flutter engine creation time. -* Their Flutter view includes an additional button that opens the Flutter docs - in the mobile device's browser. - -If you're interested in learning what additional steps an app needs to take in -order to use a Flutter module that relies on plugins, these projects can help. - -### `android_using_prebuilt_module` and `ios_using_prebuilt_module` - -These apps are essentially identical to `android_fullscreen` and -`ios_fullscreen`, respectively, with one key difference. Rather than being set -up to compile the `flutter_module` from source each time the app is built, they -import a the module as a prebuilt `aar` (Android) or framework (iOS). This can -be useful for teams that don't want to require every developer working on the -app to have the Flutter toolchain installed on their local machines. - -Prior to building either project for the first time, the `flutter_module` needs -to be built. - -**Building for `android_using_prebuilt_module`** - -To build `flutter_module` as an aar, run this command from the `flutter_module` -directory: - -```bash -flutter build aar -``` - -It will produce `aar` files for debug, profile, and release mode. The Android -app is configured to import the appropriate `aar` based on its own build -configuration, so if you build a debug version of the app, it will look -for the debug `aar`, and so on. - -If the `flutter_module` project is updated, the `aar` files must be rebuilt via -one of the commands above in order for those changes to appear in the app. - -**Building for `ios_using_prebuilt_module`** - -To build `flutter_module` as a set of frameworks, run this command from the -`flutter_module` directory: - -```bash -flutter build ios-framework --output=../ios_using_prebuilt_module/Flutter -``` +If you run into an issue with the sample itself, please file an issue +in the [Flutter samples repo](https://github.com/flutter/samples/issues). -This will output frameworks for debug, profile, and release modes into -`ios_using_prebuilt_module/Flutter`. The project file for -`ios_using_prebuilt_module` has been configured to find the frameworks there. -For more information on how to modify an existing iOS app to reference prebuilt -Flutter frameworks, see this article in the Flutter GitHub wiki: +## Updating Android samples and its dependencies -https://flutter.dev/docs/development/add-to-app/ios/project-setup +1. Open the top level build.gradle file in Android Studio +2. Open “Upgrade Assistant” and click upgrade -## Questions/issues +### Troubleshooting Android updates -If you have a general question about incorporating Flutter into an existing -iOS or Android app, the best places to go are: +* If after upgrading it fails to build, try upgrading to a slightly less new version +* If there's an "Unknown class version exception " try setting the version of Java used by modifying JAVA_HOME +* If it still fails to build, check that the Flutter code referenced in the build is up-to-date and doesn't use discontinued plugins. (Common cases include “namespace”) +* The 'project structure' -> 'modules' view can be helpful in understanding the dependency tree. +* Once the app builds with the latest gradle/agp, update any deprecated usages in app/build.gradle -* [The FlutterDev Google Group](https://groups.google.com/forum/#!forum/flutter-dev) -* [The Flutter Gitter channel](https://gitter.im/flutter/flutter) -* [StackOverflow](https://stackoverflow.com/questions/tagged/flutter) +* compileSdkVersion -> sdkVersion +* Update the target sdk version and read through each target sdk update +* Export broadcast receivers +* Update the way flutter is imported to use flutter gradle plugin +* https://flutter.dev/go/flutter-gradle-plugin-apply -If you run into an issue with the sample itself, please file an issue -in the [main Flutter repo](https://github.com/flutter/flutter/issues). +* **When updating an app that uses AAR as a Flutter module** -- In android studio update any android dependencies that are indicated as in yellow as old. Keep `androidx.test:runner`, `androidx.test.espresso:espresso-core`, and `androidx.test:core`, as defined in https://github.com/flutter/packages/tree/main/packages/espresso diff --git a/add_to_app/android_fullscreen/app/build.gradle b/add_to_app/android_fullscreen/app/build.gradle deleted file mode 100644 index 0d068520fd2..00000000000 --- a/add_to_app/android_fullscreen/app/build.gradle +++ /dev/null @@ -1,39 +0,0 @@ -apply plugin: 'com.android.application' - -apply plugin: 'kotlin-android' - -apply plugin: 'kotlin-android-extensions' - -android { - compileSdkVersion 28 - buildToolsVersion "29.0.2" - defaultConfig { - applicationId "dev.flutter.example.androidfullscreen" - minSdkVersion 19 - targetSdkVersion 28 - versionCode 1 - versionName "1.0" - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - buildTypes { - release { - minifyEnabled false - } - } - compileOptions { - sourceCompatibility 1.8 - targetCompatibility 1.8 - } -} - -dependencies { - implementation project(':flutter') - implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'androidx.appcompat:appcompat:1.1.0' - implementation 'androidx.core:core-ktx:1.1.0' - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' - testImplementation 'junit:junit:4.12' - androidTestImplementation 'androidx.test:runner:1.2.0' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' -} diff --git a/add_to_app/android_fullscreen/app/src/androidTest/java/dev/flutter/example/androidfullscreen/ExampleInstrumentedTest.kt b/add_to_app/android_fullscreen/app/src/androidTest/java/dev/flutter/example/androidfullscreen/ExampleInstrumentedTest.kt deleted file mode 100644 index 49be549e831..00000000000 --- a/add_to_app/android_fullscreen/app/src/androidTest/java/dev/flutter/example/androidfullscreen/ExampleInstrumentedTest.kt +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2019 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package dev.flutter.example.androidfullscreen - -import androidx.test.platform.app.InstrumentationRegistry -import androidx.test.ext.junit.runners.AndroidJUnit4 - -import org.junit.Test -import org.junit.runner.RunWith - -import org.junit.Assert.* - -/** - * Instrumented test, which will execute on an Android device. - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -@RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { - @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("dev.flutter.example.androidfullscreen", appContext.packageName) - } -} diff --git a/add_to_app/android_fullscreen/app/src/main/AndroidManifest.xml b/add_to_app/android_fullscreen/app/src/main/AndroidManifest.xml deleted file mode 100644 index bd2b7ff9eb6..00000000000 --- a/add_to_app/android_fullscreen/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/add_to_app/android_fullscreen/app/src/main/java/dev/flutter/example/androidfullscreen/MyApplication.kt b/add_to_app/android_fullscreen/app/src/main/java/dev/flutter/example/androidfullscreen/MyApplication.kt deleted file mode 100644 index bf65b3f68eb..00000000000 --- a/add_to_app/android_fullscreen/app/src/main/java/dev/flutter/example/androidfullscreen/MyApplication.kt +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2019 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package dev.flutter.example.androidfullscreen - -import android.app.Application -import io.flutter.embedding.engine.FlutterEngine -import io.flutter.embedding.engine.FlutterEngineCache -import io.flutter.embedding.engine.dart.DartExecutor -import io.flutter.plugin.common.MethodChannel - -const val ENGINE_ID = "1" - -class MyApplication : Application() { - var count = 0 - - private lateinit var channel: MethodChannel - - override fun onCreate() { - super.onCreate() - - val flutterEngine = FlutterEngine(this) - flutterEngine - .dartExecutor - .executeDartEntrypoint( - DartExecutor.DartEntrypoint.createDefault() - ) - - FlutterEngineCache.getInstance().put(ENGINE_ID, flutterEngine) - - channel = MethodChannel(flutterEngine.dartExecutor, "dev.flutter.example/counter") - - channel.setMethodCallHandler { call, _ -> - when (call.method) { - "incrementCounter" -> { - count++ - reportCounter() - } - "requestCounter" -> { - reportCounter() - } - } - } - } - - private fun reportCounter() { - channel.invokeMethod("reportCounter", count) - } -} diff --git a/add_to_app/android_fullscreen/build.gradle b/add_to_app/android_fullscreen/build.gradle deleted file mode 100644 index e796b11e6ce..00000000000 --- a/add_to_app/android_fullscreen/build.gradle +++ /dev/null @@ -1,26 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - -buildscript { - ext.kotlin_version = '1.3.50' - repositories { - google() - jcenter() - } - dependencies { - classpath 'com.android.tools.build:gradle:3.5.1' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - repositories { - google() - jcenter() - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} diff --git a/add_to_app/android_fullscreen/gradle/wrapper/gradle-wrapper.jar b/add_to_app/android_fullscreen/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index f6b961fd5a8..00000000000 Binary files a/add_to_app/android_fullscreen/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/add_to_app/android_fullscreen/gradle/wrapper/gradle-wrapper.properties b/add_to_app/android_fullscreen/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ec11f69a236..00000000000 --- a/add_to_app/android_fullscreen/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Tue Sep 17 09:33:13 PDT 2019 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip diff --git a/add_to_app/android_fullscreen/gradlew.bat b/add_to_app/android_fullscreen/gradlew.bat deleted file mode 100644 index e95643d6a2c..00000000000 --- a/add_to_app/android_fullscreen/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/add_to_app/android_using_plugin/app/build.gradle b/add_to_app/android_using_plugin/app/build.gradle deleted file mode 100644 index 246d692e084..00000000000 --- a/add_to_app/android_using_plugin/app/build.gradle +++ /dev/null @@ -1,39 +0,0 @@ -apply plugin: 'com.android.application' - -apply plugin: 'kotlin-android' - -apply plugin: 'kotlin-android-extensions' - -android { - compileSdkVersion 28 - buildToolsVersion "29.0.2" - defaultConfig { - applicationId "dev.flutter.example.androidusingplugin" - minSdkVersion 19 - targetSdkVersion 28 - versionCode 1 - versionName "1.0" - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - buildTypes { - release { - minifyEnabled false - } - } - compileOptions { - sourceCompatibility 1.8 - targetCompatibility 1.8 - } -} - -dependencies { - implementation project(':flutter') - implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'androidx.appcompat:appcompat:1.1.0' - implementation 'androidx.core:core-ktx:1.1.0' - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' - testImplementation 'junit:junit:4.12' - androidTestImplementation 'androidx.test.ext:junit:1.1.0' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' -} diff --git a/add_to_app/android_using_plugin/app/src/main/AndroidManifest.xml b/add_to_app/android_using_plugin/app/src/main/AndroidManifest.xml deleted file mode 100644 index 023a4a5bfe3..00000000000 --- a/add_to_app/android_using_plugin/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/add_to_app/android_using_plugin/build.gradle b/add_to_app/android_using_plugin/build.gradle deleted file mode 100644 index e796b11e6ce..00000000000 --- a/add_to_app/android_using_plugin/build.gradle +++ /dev/null @@ -1,26 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - -buildscript { - ext.kotlin_version = '1.3.50' - repositories { - google() - jcenter() - } - dependencies { - classpath 'com.android.tools.build:gradle:3.5.1' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - repositories { - google() - jcenter() - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} diff --git a/add_to_app/android_using_plugin/gradle.properties b/add_to_app/android_using_plugin/gradle.properties deleted file mode 100644 index 23339e0df69..00000000000 --- a/add_to_app/android_using_plugin/gradle.properties +++ /dev/null @@ -1,21 +0,0 @@ -# Project-wide Gradle settings. -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx1536m -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true -# AndroidX package structure to make it clearer which packages are bundled with the -# Android operating system, and which are packaged with your app's APK -# https://developer.android.com/topic/libraries/support-library/androidx-rn -android.useAndroidX=true -# Automatically convert third-party libraries to use AndroidX -android.enableJetifier=true -# Kotlin code style for this project: "official" or "obsolete": -kotlin.code.style=official diff --git a/add_to_app/android_using_plugin/gradle/wrapper/gradle-wrapper.jar b/add_to_app/android_using_plugin/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index f6b961fd5a8..00000000000 Binary files a/add_to_app/android_using_plugin/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/add_to_app/android_using_plugin/gradle/wrapper/gradle-wrapper.properties b/add_to_app/android_using_plugin/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 83e0f19b134..00000000000 --- a/add_to_app/android_using_plugin/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Sun Oct 13 15:03:51 PDT 2019 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip diff --git a/add_to_app/android_using_plugin/gradlew b/add_to_app/android_using_plugin/gradlew deleted file mode 100755 index cccdd3d517f..00000000000 --- a/add_to_app/android_using_plugin/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/add_to_app/android_using_plugin/gradlew.bat b/add_to_app/android_using_plugin/gradlew.bat deleted file mode 100644 index e95643d6a2c..00000000000 --- a/add_to_app/android_using_plugin/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/add_to_app/android_using_prebuilt_module/app/build.gradle b/add_to_app/android_using_prebuilt_module/app/build.gradle deleted file mode 100644 index 45ab34657ac..00000000000 --- a/add_to_app/android_using_prebuilt_module/app/build.gradle +++ /dev/null @@ -1,58 +0,0 @@ -apply plugin: 'com.android.application' - -apply plugin: 'kotlin-android' - -apply plugin: 'kotlin-android-extensions' - -android { - compileSdkVersion 28 - buildToolsVersion "29.0.2" - defaultConfig { - applicationId "dev.flutter.example.androidusingprebuiltmodule" - minSdkVersion 19 - targetSdkVersion 28 - versionCode 1 - versionName "1.0" - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - buildTypes { - release { - minifyEnabled false - } - } - compileOptions { - sourceCompatibility 1.8 - targetCompatibility 1.8 - } -} - -repositories { - maven { - // This maven repo is created when you run `flutter build aar`. It contains compiled code - // and resources for flutter_module itself. - url '../../flutter_module/build/host/outputs/repo' - } - maven { - // This maven repo contains artifacts for Flutter's Android embedding. - url 'http://download.flutter.io/' - } -} - -dependencies { - releaseImplementation ('dev.flutter.example.flutter_module:flutter_release:1.0@aar') { - transitive = true - } - - debugImplementation ('dev.flutter.example.flutter_module:flutter_debug:1.0@aar') { - transitive = true - } - - implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'androidx.appcompat:appcompat:1.1.0' - implementation 'androidx.core:core-ktx:1.1.0' - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' - testImplementation 'junit:junit:4.12' - androidTestImplementation 'androidx.test.ext:junit:1.1.1' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' -} diff --git a/add_to_app/android_using_prebuilt_module/app/src/main/AndroidManifest.xml b/add_to_app/android_using_prebuilt_module/app/src/main/AndroidManifest.xml deleted file mode 100644 index a91118488da..00000000000 --- a/add_to_app/android_using_prebuilt_module/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/add_to_app/android_using_prebuilt_module/app/src/main/java/dev/flutter/example/androidusingprebuiltmodule/MainActivity.kt b/add_to_app/android_using_prebuilt_module/app/src/main/java/dev/flutter/example/androidusingprebuiltmodule/MainActivity.kt deleted file mode 100644 index 30d56992e3f..00000000000 --- a/add_to_app/android_using_prebuilt_module/app/src/main/java/dev/flutter/example/androidusingprebuiltmodule/MainActivity.kt +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2019 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package dev.flutter.example.androidusingprebuiltmodule - -import android.os.Bundle -import android.widget.Button -import android.widget.TextView -import androidx.appcompat.app.AppCompatActivity -import io.flutter.embedding.android.FlutterActivity - -class MainActivity : AppCompatActivity() { - private lateinit var counterLabel: TextView - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) - - counterLabel = findViewById(R.id.counter_label) - - val button = findViewById