Closed4

Flutterプロジェクト新規作成時のTODO

イルカイルカ

パッケージを追加

% flutter pub add hooks_riverpod
% flutter pub add flutter_hooks
% flutter pub add freezed_annotation
% flutter pub add go_router
% flutter pub add build_runner --dev
% flutter pub add freezed --dev
% flutter pub add json_serializable --dev
% flutter pub add pedantic_mono --dev

イルカイルカ

build.yaml ファイルを追加

# 自動生成ファイルに ignore_for_file コメントを挿入するための記述
# analysis_options.yaml の analyzer/exclude での、
# lib/**/**.freezed.dart, lib/**/**.g.dart 指定と
# analyzer/errors での、invalid_annotation_target: ignore 設定が不要になる。

targets:
  $default:
    builders:
      source_gen|combining_builder:
        options:
          ignore_for_file:
            - type=lint
            - implicit_dynamic_parameter
            - implicit_dynamic_type
            - implicit_dynamic_method
            - strict_raw_type

参考

https://twitter.com/_mono/status/1536907414490222593?s=20&t=VgPQHwIFksxwkG66TQOnNA

イルカイルカ

runAppするクラスをProviderScopeでラップ

void main() {
  runApp(
    const ProviderScope(child: MyApp()),
  );
}
イルカイルカ

VS codeのショートカットshift + command + Bで実行されるデフォルトのビルドコマンドを設定

{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "flutter",
			"command": "flutter",
			"args": [
				"pub",
				"run",
				"build_runner",
				"build",
				"--delete-conflicting-outputs",
			],
			"problemMatcher": [
				"$dart-build_runner"
			],
			"group": "build",
			"label": "ファイル自動生成&競合ファイルを削除して再生成",
			"detail": "--delete-conflicting-outputs"
		}
	]
}

.vscode/tasks.json

このスクラップは2022/05/17にクローズされました