|
1 | 1 | # Flutter Wrapper |
2 | 2 |
|
3 | | -Similar to the gradle wrapper, an executable shell script in the root of you project, `flutterw` which downloads and runs flutter with the same version, part of your repository, for every user and CI. |
| 3 | +`flutterw` is a tiny, open source shell script which downloads and executes the Flutter SDK with the exact version defined in your project respository. |
| 4 | +It encourages the idea that upgrading Flutter should happen per project, not per developer. |
| 5 | +Thus upgrading Flutter with `flutterw` automatically upgrades Flutter for your co-workers and on the CI servers. |
4 | 6 |
|
5 | | -The flutter wrapper will add flutter as a submodule to your project which pins the version allowing you to upgrade flutter for all developers in you project at the same time. |
| 7 | +The Flutter Wrapper will add the Flutter SDK as a git submodule to your project. |
| 8 | +It pins the version and the channel. |
6 | 9 |
|
7 | | -Read the story on [Medium](https://medium.com/grandcentrix/flutter-wrapper-bind-your-project-to-an-explicit-flutter-release-4062cfe6dcaf) |
| 10 | +This project is inspired by the gradle wrapper. |
8 | 11 |
|
9 | | -## How to use Flutter Wrapper |
| 12 | +Read more on [Medium](https://medium.com/grandcentrix/flutter-wrapper-bind-your-project-to-an-explicit-flutter-release-4062cfe6dcaf) |
10 | 13 |
|
11 | | -### Add the Flutter Wrapper to your project |
12 | 14 |
|
13 | | -Run this command from the root of your flutter project |
| 15 | +# Install flutterw |
14 | 16 |
|
15 | | -> `sh -c "$(curl -fsSL https://raw.githubusercontent.com/passsy/flutter_wrapper/master/install.sh)"` |
16 | | -> |
17 | | -All required files are already added to git. You can commit them now |
| 17 | +```bash |
| 18 | +sh -c "$(curl -fsSL https://raw.githubusercontent.com/passsy/flutter_wrapper/master/install.sh)" |
| 19 | +``` |
| 20 | +_Open the Terminal, navigate to your project root and execute the line above._ |
| 21 | + |
| 22 | +From now on use `./flutterw` instead of `flutter` |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | +## IDE Setup |
| 27 | +### Use with VScode |
| 28 | + |
| 29 | +If you're a VScode user link the new Flutter SDK path in your settings |
| 30 | +`$projectRoot/.vscode/settings.json` (create if it doesn't exists yet) |
| 31 | + |
| 32 | +```json |
| 33 | +{ |
| 34 | + "dart.flutterSdkPath": ".flutter", |
| 35 | +} |
| 36 | +``` |
| 37 | + |
| 38 | +Commit this file to your git repo and your coworkers will automatically use `flutterw` from now on |
| 39 | + |
| 40 | +### Use with IntelliJ / Android Studio |
| 41 | + |
| 42 | +Go to `Preferences > Languages & Frameworks > Flutter` and set the Flutter SDK path to `$projectRoot/.flutter` |
18 | 43 |
|
19 | | -> `git commit -m "Add flutter wrapper"` |
| 44 | +<img width="800" alt="IntelliJ Settings" src="https://user-images.githubusercontent.com/1096485/64658026-3a1fdd00-d436-11e9-9457-556059f68e2c.png"> |
20 | 45 |
|
21 | | -From now on you should always use `./flutterw` instead of `flutter` |
| 46 | +Add this step to the onboarding guidelines of your projects because this has to be done for every developer for every project using `flutterw`. |
22 | 47 |
|
23 | | -### Update Flutter |
| 48 | + |
| 49 | +## Tips and Tricks |
| 50 | +### Upgrading Flutter |
24 | 51 |
|
25 | 52 | Flutter Wrapper doesn't require any special command to update Flutter. |
26 | | -Run `./flutterw channel <stable|beta|master>` to change the channel or update to the lastest version of a given channel. |
| 53 | +Run `./flutterw channel <stable|beta|dev|master>` to change the channel or update to the lastest version of a given channel. |
27 | 54 |
|
28 | | -> `./flutterw channel stable` |
| 55 | +``` |
| 56 | +./flutterw channel beta |
| 57 | +./flutterw upgrade |
| 58 | +``` |
29 | 59 |
|
30 | | -The only change you'll see in git is the changed sha1 of the `.flutter` submodule. |
31 | | -You have to commit it to update flutter for all project members. |
| 60 | +Don't forget to commit the submodule changes. |
32 | 61 |
|
33 | 62 |
|
34 | | -### Update flutter wrapper |
| 63 | +### Updating flutterw |
35 | 64 |
|
36 | 65 | To update the flutter wrapper to the latest version run the install command again: |
37 | 66 |
|
38 | | -> `sh -c "$(curl -fsSL https://raw.githubusercontent.com/passsy/flutter_wrapper/master/install.sh)"` |
| 67 | +```bash |
| 68 | +sh -c "$(curl -fsSL https://raw.githubusercontent.com/passsy/flutter_wrapper/master/install.sh)" |
| 69 | +``` |
39 | 70 |
|
40 | | -To update the flutter wrapper to a specific verssion, use the `-t <tag/branch>` (i.e. `v0.8.0`) |
| 71 | +To update the flutter wrapper to a specific verssion, use the `-t <tag/branch>` (i.e. `v1.0.0`) |
41 | 72 |
|
42 | | -> `sh -c "curl -fsSL https://raw.githubusercontent.com/passsy/flutter_wrapper/master/install.sh" | bash /dev/stdin -t v1.0.0` |
| 73 | +```bash |
| 74 | +sh -c "curl -fsSL https://raw.githubusercontent.com/passsy/flutter_wrapper/master/install.sh" | bash /dev/stdin -t v1.0.0 |
| 75 | +``` |
43 | 76 |
|
44 | | -## Advanced Usage |
45 | 77 |
|
46 | | -### Uninstall flutter wrapper |
| 78 | +### Uninstall flutterw |
47 | 79 |
|
| 80 | +Sorry to let you go! |
48 | 81 | Removing submodules is hard, that's why I did the hard work for you. |
49 | 82 | Simply run this command from the root of your flutter project and the uninstall script will cleanup everything. |
50 | 83 |
|
51 | | -> `sh -c "$(curl -fsSL https://raw.githubusercontent.com/passsy/flutter_wrapper/master/uninstall.sh)"` |
| 84 | +```bash |
| 85 | +sh -c "$(curl -fsSL https://raw.githubusercontent.com/passsy/flutter_wrapper/master/uninstall.sh)" |
| 86 | +``` |
52 | 87 |
|
53 | 88 | Bye :wave: |
54 | 89 |
|
55 | | -### Get started with Flutter without adding flutter to your PATH |
| 90 | +### Create a new project using the flutter wrapper |
56 | 91 |
|
57 | | -The [Flutter install process](https://flutter.io/setup-macos/#get-sdk) is not perfectly automated. |
58 | | -You have to manually download Flutter and add it to your path before you can use the awesome Flutter CLI to create a new project. |
59 | | -With the Flutter Wrapper this becomes easier. |
| 92 | +You can create a new Flutter project without installing Flutter globally on your machine. |
60 | 93 |
|
61 | 94 | ```bash |
| 95 | +# 1. Create an empty git repo |
62 | 96 | mkdir flutter_wrapper_project && cd "$_" |
63 | 97 | git init |
| 98 | + |
| 99 | +# 2. Install flutterw |
64 | 100 | sh -c "$(curl -fsSL https://raw.githubusercontent.com/passsy/flutter_wrapper/master/install.sh)" |
| 101 | + |
| 102 | +# 3. Create Flutter project |
65 | 103 | ./flutterw create . |
66 | 104 | ./flutterw run |
67 | 105 | ``` |
68 | 106 |
|
69 | 107 | ## License |
70 | 108 |
|
71 | 109 | ``` |
72 | | -Copyright 2018 Pascal Welsch |
| 110 | +Copyright 2019 Pascal Welsch |
73 | 111 |
|
74 | 112 | Licensed under the Apache License, Version 2.0 (the "License"); |
75 | 113 | you may not use this file except in compliance with the License. |
|
0 commit comments