Here's my code

version: 2.1

orbs:
  flutter: circleci/[email protected]

jobs:
  build:
    working_directory: ~/project
    docker:
      - image: "cirrusci/flutter"
    steps:
      - checkout
      - run: flutter main.dart
  test:
    working_directory: ~/project
    docker:
      - image: "cirrusci/flutter"
    steps:
      - checkout
      - run: flutter widget_test.dart
workflows:
  build_and_test:
    jobs:
      - build
      - test:
          requires:
            - build

I got this error from the CircleCI:

Unable to parse YAML # mapping values are not allowed here # in 'string', line 3, column 5

1

There are 1 best solutions below

0
On

You can use this YAML script to achieve your workflow:

# Use the latest 2.1 version of CircleCI pipeline process engine.
# See: https://circleci.com/docs/2.0/configuration-reference
version: 2.1

# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
jobs:
  build:
    description: App Bundle Build
    docker: 
      - image: cirrusci/flutter
    steps:
      - checkout
      - run: 
          name: Build Flutter (Android)
          command: |
            flutter pub get
            flutter clean
            flutter build apk --release
      - store_artifacts:
            path: build/app/outputs/flutter-apk/app-release.apk

  test:
    description: Flutter App Test
    docker:
      - image: cirrusci/flutter 
    steps:
      - checkout
      - run:
          name: Run Flutter Test and Analyze
          command: |
            flutter doctor
            flutter pub get
            flutter analyze
            flutter test

workflows:
  build_and_test:
    jobs:
    - build
    - test:
        requires:
          - build