├── .github └── workflows │ └── major-dependency-upgrades.yaml ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── bin └── flutter_m1_patcher.dart ├── example └── example.md ├── pubspec.lock └── pubspec.yaml /.github/workflows/major-dependency-upgrades.yaml: -------------------------------------------------------------------------------- 1 | name: Major Dependency Upgrades 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: "0 0 * * 0" 7 | 8 | jobs: 9 | upgrade-dependencies: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v3 13 | - uses: subosito/flutter-action@v2 14 | with: 15 | cache: true 16 | 17 | - name: Pub cache 18 | uses: actions/cache@v3 19 | env: 20 | cache-name: pub-cache 21 | with: 22 | path: ${{ env.PUB_CACHE }} 23 | key: ${{ env.cache-name }}-${{ hashFiles('**/pubspec.lock') }} 24 | restore-keys: ${{ env.cache-name }}- 25 | 26 | - name: Activate puby 27 | run: dart pub global activate puby 28 | 29 | - name: Upgrade dependencies 30 | run: puby upgrade --major-versions 31 | 32 | - name: Check pubspec diff 33 | id: pubspec_check 34 | run: | 35 | if [[ `git status --porcelain **\pubspec.yaml` ]]; then 36 | echo "::set-output name=changed::true" 37 | fi 38 | 39 | - name: Create Pull Request 40 | if: steps.pubspec_check.outputs.changed 41 | uses: peter-evans/create-pull-request@v4 42 | with: 43 | branch: dependencies/major-upgrades 44 | commit-message: "Upgraded dependency major versions" 45 | title: "[CI] Major Dependency Upgrades" 46 | body: "Upgraded dependency major versions" 47 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Files and directories created by pub. 2 | .dart_tool/ 3 | .packages 4 | 5 | # Conventional directory for build output. 6 | build/ 7 | 8 | # macOS 9 | .DS_Store -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.6.1 2 | - Updated readme 3 | 4 | ## 1.6.0 5 | - Update checking 6 | - Colored output 7 | 8 | ## 1.5.0 9 | - Added option to specify the Flutter root path 10 | 11 | ## 1.4.0 12 | - Don't execute if the script is running with Flutter's bundled Dart SDK 13 | - Support all Dart release channels 14 | - Fail gracefully if the Dart SDK download fails 15 | 16 | ## 1.3.0 17 | - Reordered installation steps to prevent issues 18 | - Updated readme 19 | 20 | ## 1.2.0 21 | - Updated readme to indicate that Dart must be installed from homebrew first 22 | - Print the original and new Dart SDK versions to the console 23 | 24 | ## 1.1.1 25 | - Lowered Dart dependency constraint 26 | 27 | ## 1.1.0 28 | - I learned how exposed executables work 29 | 30 | ## 1.0.0 31 | - Initial version. -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2021 Aaron DeLory 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | NOTE: Flutter 3.0.0 includes the arm64 dart sdk by default. This package is no longer needed unless you are using older versions of Flutter. 2 | 3 | ___ 4 | 5 | This script replaces Flutter's bundled Dart SDK with the macOS arm64 version 6 | 7 | ## Getting Started 8 | Set up Flutter as normal and run `flutter doctor` 9 | 10 | Install Dart form homebrew: 11 | ```console 12 | $ brew tap dart-lang/dart 13 | $ brew install dart 14 | ``` 15 | This script nukes Flutter's bundled Dart SDK, so trying to run this script with Flutter's bundled Dart SDK will fail 16 | 17 | ## Use as an executable 18 | 19 | ### Installation 20 | ```console 21 | $ dart pub global activate flutter_m1_patcher 22 | ``` 23 | 24 | ### Usage 25 | Run `flutterpatch` in a terminal 26 | 27 | Run with `-p` to specify the Flutter root path 28 | 29 | ## Additional Information 30 | If things go bad, delete `flutter/bin/cache` and run `flutter doctor`. This will reset the bundled Dart SDK to the one shipped with Flutter. 31 | 32 | You will need to run `flutterpatch` after every `flutter upgrade` -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:rexios_lints/dart/package.yaml -------------------------------------------------------------------------------- /bin/flutter_m1_patcher.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:ansicolor/ansicolor.dart'; 4 | import 'package:args/args.dart'; 5 | import 'package:pub_update_checker/pub_update_checker.dart'; 6 | 7 | const optionFlutterPath = 'flutter-path'; 8 | 9 | final parser = ArgParser() 10 | ..addOption( 11 | optionFlutterPath, 12 | abbr: 'p', 13 | help: 'Flutter root path (determined automatically if not specified)', 14 | valueHelp: 'path', 15 | ); 16 | 17 | final magentaPen = AnsiPen()..magenta(); 18 | final greenPen = AnsiPen()..green(); 19 | final yellowPen = AnsiPen()..yellow(); 20 | final redPen = AnsiPen()..red(); 21 | 22 | void main(List arguments) async { 23 | final newVersion = await PubUpdateChecker.check(); 24 | if (newVersion != null) { 25 | print( 26 | yellowPen( 27 | 'There is an update available: $newVersion. Run `dart pub global activate flutter_m1_patcher` to update.', 28 | ), 29 | ); 30 | } 31 | 32 | final ArgResults args; 33 | try { 34 | args = parser.parse(arguments); 35 | } catch (_) { 36 | print(magentaPen(parser.usage)); 37 | exit(1); 38 | } 39 | 40 | // Get the path to Flutter 41 | final String flutterBinPath; 42 | if (args[optionFlutterPath] != null) { 43 | final flutterRootPath = args[optionFlutterPath]; 44 | flutterBinPath = '$flutterRootPath/bin'; 45 | } else { 46 | final whichFlutterResult = await Process.run('which', ['flutter']); 47 | final flutterPath = whichFlutterResult.stdout as String; 48 | flutterBinPath = File(flutterPath.trim()).parent.path; 49 | } 50 | 51 | // Get the path to Dart 52 | final whichDartResult = await Process.run('which', ['dart']); 53 | final dartPath = whichDartResult.stdout as String; 54 | 55 | // Get Flutter's bundled Dart SDK version 56 | final flutterBinCachePath = '$flutterBinPath/cache'; 57 | final dartSdkVersionFile = File('$flutterBinCachePath/dart-sdk/version'); 58 | final dartSdkVersion = dartSdkVersionFile.readAsStringSync().trim(); 59 | 60 | // Exit if Flutter and Dart are in the same location 61 | // This means the user is running the script with the bundled Dart SDK 62 | if (dartPath.contains(flutterBinPath)) { 63 | print( 64 | redPen( 65 | 'This script is running with Flutter\'s bundled Dart SDK.' 66 | ' Install Dart with homebrew first.', 67 | ), 68 | ); 69 | exit(1); 70 | } 71 | 72 | print('Flutter found at $flutterBinPath/flutter'); 73 | 74 | // Print the original bundled Dart SDK version 75 | print('Original bundled Dart SDK version:'); 76 | final dartVersionOldResult = 77 | await Process.run('$flutterBinPath/dart', ['--version']); 78 | stdout.write(dartVersionOldResult.stdout); 79 | 80 | // Ask the user for confirmation 81 | stdout.write(yellowPen('Continue? (y/n) ')); 82 | final confirmation = stdin.readLineSync(); 83 | if (confirmation != 'y') { 84 | print(redPen('Aborting')); 85 | exit(1); 86 | } 87 | 88 | // Determine the release channel of the bundled Dart SDK 89 | final String releaseChannel; 90 | if (dartSdkVersion.contains('beta')) { 91 | releaseChannel = 'beta'; 92 | } else if (dartSdkVersion.contains('dev')) { 93 | releaseChannel = 'dev'; 94 | } else { 95 | releaseChannel = 'stable'; 96 | } 97 | 98 | // Download the Dart SDK 99 | print('Downloading Dart SDK $dartSdkVersion for macos_arm64...'); 100 | final request = await HttpClient().getUrl( 101 | Uri.parse( 102 | 'https://storage.googleapis.com/dart-archive/channels/$releaseChannel/release/$dartSdkVersion/sdk/dartsdk-macos-arm64-release.zip', 103 | ), 104 | ); 105 | final response = await request.close(); 106 | if (response.statusCode != 200) { 107 | print( 108 | redPen( 109 | 'Failed to download Dart SDK.' 110 | ' This might mean Flutter is using a Dart SDK version that is not available on the Dart website.', 111 | ), 112 | ); 113 | exit(1); 114 | } 115 | await response.pipe(File('$flutterBinCachePath/dart-sdk.zip').openWrite()); 116 | 117 | // Delete the existing dart-sdk folder 118 | print('Deleting bundled Dart SDK...'); 119 | Directory('$flutterBinCachePath/dart-sdk').deleteSync(recursive: true); 120 | 121 | // Unzip the Dart SDK 122 | print('Unzipping Dart SDK...'); 123 | await Process.run( 124 | 'unzip', 125 | ['-o', '$flutterBinCachePath/dart-sdk.zip', '-d', flutterBinCachePath], 126 | ); 127 | 128 | // Delete the zip file 129 | print('Deleting zip file...'); 130 | File('$flutterBinCachePath/dart-sdk.zip').deleteSync(); 131 | 132 | // Delete the existing engine frontend_server.dart.snapshot file 133 | print('Deleting engine frontend_server.dart.snapshot file...'); 134 | File('$flutterBinCachePath/artifacts/engine/darwin-x64/frontend_server.dart.snapshot') 135 | .deleteSync(); 136 | 137 | // Copy the dart-sdk frontend_server.dart.snapshot file to the engine folder 138 | print('Copying Dart SDK frontend_server.dart.snapshot file to engine...'); 139 | File('$flutterBinCachePath/dart-sdk/bin/snapshots/frontend_server.dart.snapshot') 140 | .copySync( 141 | '$flutterBinCachePath/artifacts/engine/darwin-x64/frontend_server.dart.snapshot', 142 | ); 143 | 144 | // Print the new bundled Dart SDK version 145 | print('New bundled Dart SDK version:'); 146 | final dartVersionNewResult = 147 | await Process.run('$flutterBinPath/dart', ['--version']); 148 | stdout.write(dartVersionNewResult.stdout); 149 | 150 | print(greenPen('Done!')); 151 | 152 | exit(0); 153 | } 154 | -------------------------------------------------------------------------------- /example/example.md: -------------------------------------------------------------------------------- 1 | I really hope you don't need an example for this -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | ansicolor: 5 | dependency: "direct main" 6 | description: 7 | name: ansicolor 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "2.0.1" 11 | args: 12 | dependency: "direct main" 13 | description: 14 | name: args 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "2.3.1" 18 | async: 19 | dependency: transitive 20 | description: 21 | name: async 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "2.9.0" 25 | collection: 26 | dependency: transitive 27 | description: 28 | name: collection 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "1.16.0" 32 | crypto: 33 | dependency: transitive 34 | description: 35 | name: crypto 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "3.0.2" 39 | flutter_lints: 40 | dependency: transitive 41 | description: 42 | name: flutter_lints 43 | url: "https://pub.dartlang.org" 44 | source: hosted 45 | version: "2.0.1" 46 | freezed_annotation: 47 | dependency: transitive 48 | description: 49 | name: freezed_annotation 50 | url: "https://pub.dartlang.org" 51 | source: hosted 52 | version: "1.1.0" 53 | http: 54 | dependency: transitive 55 | description: 56 | name: http 57 | url: "https://pub.dartlang.org" 58 | source: hosted 59 | version: "0.13.4" 60 | http_parser: 61 | dependency: transitive 62 | description: 63 | name: http_parser 64 | url: "https://pub.dartlang.org" 65 | source: hosted 66 | version: "4.0.1" 67 | json_annotation: 68 | dependency: transitive 69 | description: 70 | name: json_annotation 71 | url: "https://pub.dartlang.org" 72 | source: hosted 73 | version: "4.6.0" 74 | lints: 75 | dependency: transitive 76 | description: 77 | name: lints 78 | url: "https://pub.dartlang.org" 79 | source: hosted 80 | version: "2.0.0" 81 | matcher: 82 | dependency: transitive 83 | description: 84 | name: matcher 85 | url: "https://pub.dartlang.org" 86 | source: hosted 87 | version: "0.12.12" 88 | meta: 89 | dependency: transitive 90 | description: 91 | name: meta 92 | url: "https://pub.dartlang.org" 93 | source: hosted 94 | version: "1.8.0" 95 | oauth2: 96 | dependency: transitive 97 | description: 98 | name: oauth2 99 | url: "https://pub.dartlang.org" 100 | source: hosted 101 | version: "2.0.0" 102 | path: 103 | dependency: transitive 104 | description: 105 | name: path 106 | url: "https://pub.dartlang.org" 107 | source: hosted 108 | version: "1.8.2" 109 | pub_api_client: 110 | dependency: transitive 111 | description: 112 | name: pub_api_client 113 | url: "https://pub.dartlang.org" 114 | source: hosted 115 | version: "2.2.1" 116 | pub_semver: 117 | dependency: transitive 118 | description: 119 | name: pub_semver 120 | url: "https://pub.dartlang.org" 121 | source: hosted 122 | version: "2.1.1" 123 | pub_update_checker: 124 | dependency: "direct main" 125 | description: 126 | name: pub_update_checker 127 | url: "https://pub.dartlang.org" 128 | source: hosted 129 | version: "1.2.0" 130 | pubspec: 131 | dependency: transitive 132 | description: 133 | name: pubspec 134 | url: "https://pub.dartlang.org" 135 | source: hosted 136 | version: "2.3.0" 137 | quiver: 138 | dependency: transitive 139 | description: 140 | name: quiver 141 | url: "https://pub.dartlang.org" 142 | source: hosted 143 | version: "3.1.0" 144 | rexios_lints: 145 | dependency: "direct dev" 146 | description: 147 | name: rexios_lints 148 | url: "https://pub.dartlang.org" 149 | source: hosted 150 | version: "5.0.0" 151 | source_span: 152 | dependency: transitive 153 | description: 154 | name: source_span 155 | url: "https://pub.dartlang.org" 156 | source: hosted 157 | version: "1.9.0" 158 | stack_trace: 159 | dependency: transitive 160 | description: 161 | name: stack_trace 162 | url: "https://pub.dartlang.org" 163 | source: hosted 164 | version: "1.10.0" 165 | string_scanner: 166 | dependency: transitive 167 | description: 168 | name: string_scanner 169 | url: "https://pub.dartlang.org" 170 | source: hosted 171 | version: "1.1.1" 172 | term_glyph: 173 | dependency: transitive 174 | description: 175 | name: term_glyph 176 | url: "https://pub.dartlang.org" 177 | source: hosted 178 | version: "1.2.1" 179 | typed_data: 180 | dependency: transitive 181 | description: 182 | name: typed_data 183 | url: "https://pub.dartlang.org" 184 | source: hosted 185 | version: "1.3.1" 186 | uri: 187 | dependency: transitive 188 | description: 189 | name: uri 190 | url: "https://pub.dartlang.org" 191 | source: hosted 192 | version: "1.0.0" 193 | yaml: 194 | dependency: transitive 195 | description: 196 | name: yaml 197 | url: "https://pub.dartlang.org" 198 | source: hosted 199 | version: "3.1.1" 200 | sdks: 201 | dart: ">=2.17.0 <3.0.0" 202 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_m1_patcher 2 | description: Replaces Flutter's bundled Dart SDK with the macOS arm64 version 3 | version: 1.6.1 4 | homepage: https://github.com/Rexios80/flutter_m1_patcher 5 | 6 | environment: 7 | sdk: '>=2.15.0 <3.0.0' 8 | 9 | dependencies: 10 | args: ^2.3.0 11 | ansicolor: ^2.0.1 12 | pub_update_checker: ^1.2.0 13 | 14 | dev_dependencies: 15 | rexios_lints: ^5.0.0 16 | 17 | executables: 18 | flutterpatch: flutter_m1_patcher --------------------------------------------------------------------------------