Change:
<del> { callPackage, fetchzip, dart }: </del> <ins> { callPackage, fetchzip, dart, lib, stdenv }: </ins> let <del> mkFlutter = { version, engineVersion, patches, dart, src }: callPackage ./flutter.nix { inherit version engineVersion patches dart src; }; </del> <ins> mkCustomFlutter = args: callPackage ./flutter.nix args; </ins> wrapFlutter = flutter: callPackage ./wrapper.nix { inherit flutter; }; getPatches = dir: let files = builtins.attrNames (builtins.readDir dir); in map (f: dir + ("/" + f)) files; <del> flutterDrv = { version, engineVersion, dartVersion, hash, dartHash, patches }: mkFlutter { inherit version engineVersion patches; dart = dart.override { version = dartVersion; sources = { "${dartVersion}-x86_64-linux" = fetchzip { url = "https://storage.googleapis.com/dart-archive/channels/stable/release/${dartVersion}/sdk/dartsdk-linux-x64-release.zip"; sha256 = dartHash.x86_64-linux; }; "${dartVersion}-aarch64-linux" = fetchzip { url = "https://storage.googleapis.com/dart-archive/channels/stable/release/${dartVersion}/sdk/dartsdk-linux-arm64-release.zip"; sha256 = dartHash.aarch64-linux; </del> <ins> mkFlutter = { version, engineVersion, dartVersion, hash, dartHash, patches }: let args = { inherit version engineVersion patches; dart = dart.override { version = dartVersion; sources = { "${dartVersion}-x86_64-linux" = fetchzip { url = "https://storage.googleapis.com/dart-archive/channels/stable/release/${dartVersion}/sdk/dartsdk-linux-x64-release.zip"; sha256 = dartHash.x86_64-linux; }; "${dartVersion}-aarch64-linux" = fetchzip { url = "https://storage.googleapis.com/dart-archive/channels/stable/release/${dartVersion}/sdk/dartsdk-linux-arm64-release.zip"; sha256 = dartHash.aarch64-linux; }; </ins> }; }; <ins> src = fetchzip { url = "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${version}-stable.tar.xz"; sha256 = hash; }; }; in (mkCustomFlutter args).overrideAttrs (prev: next: { passthru = next.passthru // rec { inherit wrapFlutter mkCustomFlutter mkFlutter; buildFlutterApplication = callPackage ../../../build-support/flutter { # Package a minimal version of Flutter that only uses Linux desktop release artifacts. flutter = wrapFlutter (mkCustomFlutter (args // { includedEngineArtifacts = { common = [ "flutter_patched_sdk_product" ]; platform.linux = lib.optionals stdenv.hostPlatform.isLinux (lib.genAttrs ((lib.optional stdenv.hostPlatform.isx86_64 "x64") ++ (lib.optional stdenv.hostPlatform.isAarch64 "arm64")) (architecture: [ "release" ])); }; })); }; </ins> }; <del> src = fetchzip { url = "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${version}-stable.tar.xz"; sha256 = hash; }; }; </del> <ins> }); </ins> flutter2Patches = getPatches ./patches/flutter2; flutter3Patches = getPatches ./patches/flutter3; in { <del> inherit mkFlutter wrapFlutter flutterDrv flutter3Patches flutter2Patches; stable = flutterDrv { </del> <ins> inherit wrapFlutter; stable = mkFlutter { </ins> version = "3.7.12"; engineVersion = "1a65d409c7a1438a34d21b60bf30a6fd5db59314"; dartVersion = "2.19.6";

Discussion:
The provides a function to allow customized Flutter derivations to be made. Internally, however, it uses a function that calls with URLs generated from the given version number. Patches are also used internally, but there is no way (that I know of) to access these externally. I propose that and / attributes get to the attribute set along with , to make it easier to create custom Flutter derivations.
I was actually just about to file a bug about which produces this error instead of building, wonder if it's related, since it's breaking on flutter? cc
Sounds good