Repository: flutter
Issue: Descriptive log on Flutter build when `FLUTTER_BUILD_DIR` environment variable isn't configured.
Labels: tool,c: proposal,a: build,P2,team-tool,triaged-tool

### Steps to reproduce

1. Install `flutter` using `git`.
2. Use the `3.16` stable version.
3. Go to your Flutter project.
4. Run `flutter build`.

### Expected results

Inform to us using `flutter doctor` or a simple log that we haven't configured the `FLUTTER_BUILD_DIR` environment variable.

### Actual results

An error is throw because we don't have an environment variabl called `FLUTTER_BUILD_DIR` defined.

```console
Null check operator used on a null value
    #0      Context.embedFlutterFrameworks (file:///Users/felipebonezi/flutter/packages/flutter_tools/bin/xcode_backend.dart:235:68)
    #1      Context.run (file:///Users/felipebonezi/flutter/packages/flutter_tools/bin/xcode_backend.dart:59:9)
    #2      main (file:///Users/felipebonezi/flutter/packages/flutter_tools/bin/xcode_backend.dart:17:5)
    #3      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:33)
    #4      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
```

### Code sample

<details open><summary>Code sample</summary>

Any flutter project.

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

<img width="742" alt="Screenshot 2024-01-02 at 23 44 44" src="https://github.com/flutter/flutter/assets/1410319/f9f44c2e-f03f-4d15-a94d-80aac50163b8">

<img width="971" alt="Screenshot 2024-01-02 at 23 53 08" src="https://github.com/flutter/flutter/assets/1410319/e889b322-3602-424a-8f21-7dfaad9afe8c">

</details>


### Logs

<details open><summary>Logs</summary>

```console
Unhandled exception:
    Null check operator used on a null value
    #0      Context.embedFlutterFrameworks (file:///Users/felipebonezi/flutter/packages/flutter_tools/bin/xcode_backend.dart:235:68)
    #1      Context.run (file:///Users/felipebonezi/flutter/packages/flutter_tools/bin/xcode_backend.dart:59:9)
    #2      main (file:///Users/felipebonezi/flutter/packages/flutter_tools/bin/xcode_backend.dart:17:5)
    #3      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:33)
    #4      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
    Command PhaseScriptExecution failed with a nonzero exit code
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.16.5, on macOS 14.1.2 23B92 darwin-arm64, locale en-BR)
    • Flutter version 3.16.5 on channel stable at /Users/felipebonezi/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 78666c8dc5 (2 weeks ago), 2023-12-19 16:14:14 -0800
    • Engine revision 3f3e560236
    • Dart version 3.2.3
    • DevTools version 2.28.4
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/felipebonezi/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/felipebonezi/Library/Android/sdk
    • Java binary at: /Users/felipebonezi/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15C65
    • CocoaPods version 1.14.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.1)
    • Android Studio at /Users/felipebonezi/Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] IntelliJ IDEA Ultimate Edition (version 2023.3.1)
    • IntelliJ at /Users/felipebonezi/Applications/IntelliJ IDEA Ultimate.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.85.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.42.0

[✓] Connected device (4 available)
    • iPhone de FB (mobile)      • XXXXX-XXXXXX            • ios            • iOS 17.2.1 21C66
    • iPhone 15 Pro Max (mobile) • XXXXX-XXXXXX.           • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
    • macOS (desktop)            • macos                                • darwin-arm64   • macOS 14.1.2 23B92 darwin-arm64
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 120.0.6099.129

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>