## Flutter Packages

Packages are reusable libraries of code in dart.
Anyone can create a package and upload it to [pub.dev](https://pub.dev).
We use several packages of our own creation, as well as others.

There is lots of good documentation on [pub.dev](https://pub.dev) for each package.
You can usually also browse the API reference from a link on the pub.dev page.

## Usage

To use a package add a line to your `pubspec.yaml` in the root of the flutter project.
This line contains the package name followed by a colon and a version number.
The `^` means any package that is compatible with that version.
Since we are usually pretty flexible with the version and are constantly updating our code,
sometimes you'll see the key `any` which specifies that we are okay with any version.
This will fetch the latest version from [pub.dev](https://pub.dev)

```yaml
dependencies:
  your_package_name: ^0.0.1
  another_package: any
```

Quick packages:
TODO: Add in common_widgets and common_utils
```yaml
dependencies:
  flutter:
    sdk: flutter
  riverpod: any
  flutter_hooks: any
  dartx: any
  async: any
  dartos: any
  json_annotation: any
  freezed_annotation: any

dev_dependencies:
  flutter_test:
    sdk: flutter
  json_serializable: any
  build_runner: any
  freezed: any

scripts:
  recreate:
    - flutter create .
    - rm -r android
    - rm -r ios
  macos:
    - flutter run -d macos
  linux:
    - flutter run -d Linux
  windows:
    - flutter run -d Windows
  web:
    - flutter run -d chrome --web-port=8080 --web-hostname=localhost
  gen:
    - flutter pub run build_runner build --delete-conflicting-outputs
  genw:
    - flutter pub run build_runner watch --delete-conflicting-outputs
```

## Common Packages Recommended for use in all new projects, and integration into old projects

- [dartros](https://pub.dev/packages/dartros)

## New Packages To Start Using

Currently we aren't using everywhere, but probably should use (in order of usefulness in day-to-day work):

- [dartx](https://pub.dev/packages/dartx)
- [flutter_hooks](https://pub.dev/packages/flutter_hooks)
- [basics](https://pub.dev/packages/basics)
- [derry](https://pub.dev/packages/derry)
- [freezed](https://pub.dev/packages/freezed)
- [breakpoint](https://pub.dev/packages/breakpoint)
- [flutter_launcher_icons](https://pub.dev/packages/flutter_launcher_icons) -- however, this [fork](https://github.com/personalizedrefrigerator/flutter_launcher_icons) is currently needed to generate icons for web

## Packages to explore

- [fluttercommunity packages](https://pub.dev/publishers/fluttercommunity.dev/packages)
- [textstyle_extensions](https://pub.dev/packages/textstyle_extensions)
- [rnd](https://pub.dev/packages/rnd)

## Custom Packages

- [dartros](https://pub.dev/packages/dartros) Tim created this package to bring ROS to dart
- [dart_statistics](https://pub.dev/packages/dart_statistics) Used in the proficiency assessment work, with the mouse-cheese world flutter application

## Sawyer Faces

- [flare_flutter](https://pub.dev/packages/flare_flutter) (Animation framework)
Need to move faces and the runtime to the rive runtime (which is version 2.0 of flare)
- [rive](https://pub.dev/packages/rive)
- [Rive Web App](https://rive.app) (for creating the animations)

## Speech App

- [googleapis](https://pub.dev/packages/googleapis)

## State Management Recommendations

Immutable states are highly recommended to avoid two mutations that cause inconsistent state.
See the [freezed package](https://pub.dev/packages/freezed) for my recommendation on making states immutable.
Also, recommended to design with the goal in mind of making illegal states unrepresentable.
See [this](https://www.youtube.com/watch?v=RMiN59x3uH0&list=PLB6lc7nQ1n4iS5p-IezFFgqP6YvAJy84U) tutorial series for more info.
(It shows very good clean architecture principles)

For UI related state, (animations / text controllers, etc) please use [flutter_hooks](https://pub.dev/packages/flutter_hooks)

- [StateNotifier](https://pub.dev/packages/state_notifier) along with [riverpod](https://pub.dev/packages/riverpod)
