├── .github └── workflows │ ├── flutter.yaml │ └── generate-template.yaml ├── LICENSE ├── README.md ├── analysis_options.yaml └── test └── analysis_options.yaml /.github/workflows/flutter.yaml: -------------------------------------------------------------------------------- 1 | name: Application ON Push & PR DO Code check 2 | on: [push, pull_request] 3 | 4 | jobs: 5 | code-check: 6 | runs-on: ubuntu-latest 7 | 8 | steps: 9 | - uses: actions/checkout@v1 10 | 11 | - name: Check file existence 12 | id: check_files 13 | uses: andstor/file-existence-action@v1 14 | with: 15 | files: "pubspec.yaml" 16 | 17 | - name: Setup flutter 18 | if: steps.check_files.outputs.files_exists == 'true' 19 | uses: subosito/flutter-action@v2 20 | with: 21 | channel: 'stable' 22 | 23 | - name: Check flutter sdk version 24 | if: steps.check_files.outputs.files_exists == 'true' 25 | run: flutter --version 26 | 27 | - name: Get dependencies 28 | if: steps.check_files.outputs.files_exists == 'true' 29 | run: flutter pub get 30 | 31 | - name: Run static code analysis 32 | if: steps.check_files.outputs.files_exists == 'true' 33 | uses: invertase/github-action-dart-analyzer@v1 34 | 35 | - name: Run custom_lint 36 | if: steps.check_files.outputs.files_exists == 'true' 37 | run: dart run custom_lint 38 | 39 | - name: Check formatting 40 | if: steps.check_files.outputs.files_exists == 'true' 41 | run: dart format . --set-exit-if-changed 42 | 43 | - name: Run tests 44 | if: steps.check_files.outputs.files_exists == 'true' 45 | run: | 46 | # run tests if `test` folder exists 47 | if [ -d test ] 48 | then 49 | flutter test -r expanded 50 | else 51 | echo "Tests not found." 52 | fi 53 | -------------------------------------------------------------------------------- /.github/workflows/generate-template.yaml: -------------------------------------------------------------------------------- 1 | name: Generate a Flutter application template 2 | 3 | on: [push] 4 | 5 | permissions: 6 | contents: write 7 | 8 | # if condition must be changed to github.repository != 'solid-software/flutter_project_template' 9 | 10 | jobs: 11 | create-project: 12 | if: ${{ github.repository != 'solid-software/flutter_project_template' }} 13 | runs-on: ubuntu-latest 14 | steps: 15 | 16 | - uses: actions/checkout@v2 17 | with: 18 | # by default, it uses a depth of 1 19 | # this fetches all history so that we can read each commit 20 | fetch-depth: 0 21 | ref: ${{ github.head_ref }} 22 | 23 | - run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}' | tr '-' '_' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV 24 | shell: bash 25 | 26 | - run: echo "REPOSITORY_URLNAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV 27 | shell: bash 28 | 29 | - run: echo "REPOSITORY_OWNER=$(echo '${{ github.repository }}' | awk -F '/' '{print $1}')" >> $GITHUB_ENV 30 | shell: bash 31 | 32 | - run: | 33 | email=$(curl \ 34 | -H "Accept: application/vnd.github.v3+json" \ 35 | https://api.github.com/users/${{ env.REPOSITORY_OWNER }} \ 36 | | jq -r '.email') 37 | 38 | if [ $email == null ]; then 39 | echo "REPO_ORGANIZATION=com.${{ env.REPOSITORY_OWNER }} >> $GITHUB_ENV" 40 | exit 0; 41 | fi 42 | 43 | domain=$(echo $email | rev | cut -d\@ -f1 | rev) 44 | secondlevel_domain=$(echo $domain | cut -d. -f1) 45 | toplevel_domain=$(echo $domain | cut -d. -f2) 46 | 47 | echo "REPO_ORGANIZATION=${toplevel_domain}.${secondlevel_domain}" >> $GITHUB_ENV 48 | 49 | - name: Get Flutter SDK 50 | uses: subosito/flutter-action@v1 51 | with: 52 | channel: 'stable' 53 | 54 | - name: Create the project 55 | run: | 56 | organization="${{ env.REPO_ORGANIZATION }}.${{ env.REPOSITORY_NAME }}" 57 | repo_name="${{ env.REPOSITORY_NAME }}" 58 | 59 | echo "Creating the project with org ${organization} name ${repo_name}" 60 | 61 | flutter create . \ 62 | --org="$organization" \ 63 | --project-name="${repo_name}" 64 | 65 | flutter pub add --dev solid_lints 66 | flutter pub get 67 | 68 | - name: Self-destruct 69 | run: | 70 | rm .github/workflows/generate-template.yaml 71 | 72 | - uses: stefanzweifel/git-auto-commit-action@v4 73 | with: 74 | commit_message: "Ready to clone and code." 75 | # commit_options: '--amend --no-edit' 76 | push_options: --force 77 | 78 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Solid Software LLC 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # flutter_project_template 2 | [![flutter_project_template](https://nokycucwgzweensacwfy.supabase.co/functions/v1/get_project_badge?projectId=149)](https://nokycucwgzweensacwfy.supabase.co/functions/v1/get_project_url?projectId=149) 3 | 4 | 📖 Template for flutter projects using solid_lints, CI for tests and analysis. 5 | 6 | - Uses latest stable flutter 7 | - Repo name as your project name 8 | - Organization from your profile email address or default 9 | 10 | # Usage 11 | 1. Press "Use this template" on the menu. 12 | 2. Fill Github form with your new repo name and press "Create repository from template" 13 | 3. Wait for it to be created and set up action is complete. In a couple of minutes, you'll see the flutter project created in your repo once Github Actions are complete. 14 | 4. Clone and code. 15 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:solid_lints/analysis_options.yaml 2 | -------------------------------------------------------------------------------- /test/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:solid_lints/analysis_options_test.yaml 2 | --------------------------------------------------------------------------------