# Install lego\_cli

Please enter the following command in the terminal for install cli

```
flutter pub global activate lego_cli    
```

{% hint style="info" %}
If this is your first time with pub global, please refer this [document](/etc/install-pub-global)
{% endhint %}


# Install Pub Global

When you use the `pub global` command, it's necessary to have Dart's `pub` tool installed and the PATH environment variable updated to include the location of the `pub` command. This allows you to execute the `pub` command from anywhere in your system, which is especially important for running globally activated packages.

## Setting up PATH on Windows

1. Use the search function to find 'Edit the system environment variables'.
2. In the System Properties dialog, click on 'Environment Variables'.
3. Under 'System Variables', find and select 'Path', then click 'Edit'.
4. Click 'New' and add the path to the `.pub-cache/bin` directory, for example, `C:\Users<username>\AppData\Local\Pub\Cache\bin`.
5. Click 'OK' to apply the changes.\\

## Setting up PATH on macOS/Linux

1. Open a terminal.
2. Edit the profile file for your shell, such as `.bash_profile`, `.bashrc`, `.zshrc`, etc.
3. Add the following line to the file: `export PATH="$PATH":"$HOME/.pub-cache/bin"`.
4. To apply the changes, either restart your terminal session or source the profile file, e.g., `source ~/.zshrc`.


# Environment

## Android Studio

You can find detailed installation instructions [here](https://developer.android.com/studio).

After installation android Studio, add the following emulator. At this time, set it to cold start, allocate more than 4GB of RAM, and provide ample storage space of more than 10GB.

* DeviceManager → Create Device → New Hardware Profile
  1. Samsung Galaxy S10 → `3040 x 1440`
  2. nexus\_9 → `2048 x 1536`
  3. Nexus\_5X → `1920 x 1080`

## Xcode

You can find detailed installation instructions [here](https://developer.apple.com/xcode/).

After installation, add the following simulator.

1. xcode → Help → Device and Simulator
   1. iPhone 8 Plus → os version → Download more simulator runtime.. → ios 16 download
   2. iPhone 15 Pro Max
   3. iPad Pro (12.9-inch) (6th generation)

## java

To obtain the SHA1/SHA256 values, you must first have Java installed.

1. Download and install the Java machine from the following [link](https://www.oracle.com/java/technologies/downloads/#jdk17-mac) on Oracle's website.

## other

Open the terminal and enter the following.

1. To authorize a test drive later, proceed with the following installation.

```bash
arch -arm64 brew tap wix/brew
arch -arm64 brew install applesimutils
```

2. For asset generation, enter the following:

```bash
arch -arm64 brew install FlutterGen/tap/fluttergen
dart pub global activate flutter_gen
```


# Create New Widget

1. install lego CLI by this [guide](/)
2. create new widget template

   1. run the following command in the terminal:

   ```bash
   lego create
   ```

   2. select the widget type(select 3\~6 for the widget type)
   3. enter the widget name
3. write the widget code in the generated file(lib/widget\_book/\[widget]/*/*.dart)

### Add Assets

add any assets to the `assets/lego/_new/` folder

* note: always use relative paths for imports

### Add Libraries

1. add any libraries to this terminal command:

```bash
flutter pub add [library_name]
```

2. add `#@add` to the library without a version number in the pubspec.yaml file.

```yaml
# example
dependencies:
  ...
  cupertino_icons: #@add
```

* this will automatically add your project's dependencies to the pubspec.yaml file when you add a new widget.
* do not add the library that need initialization in the main.dart file.

###


