This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PackageMetrics | |
// AutoDispose/Family版のAsyncNotifier | |
extends AutoDisposeFamilyAsyncNotifier<PackageMetricsScore, String> { | |
late String _packageName; | |
@override | |
Future<PackageMetricsScore> build(String arg) { | |
_packageName = arg; | |
return ref | |
.watch(pubRepositoryProvider) | |
.getPackageMetrics(packageName: _packageName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:flutter_riverpod/flutter_riverpod.dart'; | |
import 'package:go_router/go_router.dart'; | |
void main() { | |
runApp( | |
const ProviderScope( | |
child: App(), | |
), | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:quiver/collection.dart'; | |
void main() { | |
// maximumSizeのデフォルトは100 | |
final cache = LruMap<String, int>(maximumSize: 3); | |
cache['a'] = 1; | |
print(cache['a']); // 1 | |
cache['b'] = 2; | |
print(cache['a']); // 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- json['foo'] as Map<String, dynamic>), | |
+ Map<String, dynamic>.from(json['foo'] as Map)), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ignore_for_file: omit_local_variable_types, prefer_final_locals, equal_elements_in_set | |
import 'dart:collection'; | |
void main() { | |
// Setのデフォルト実装は、順番が保たれる LinkedHashSet | |
Set<String> animals = {'dog', 'dog', 'cat'}; | |
// 常に[dog, cat] | |
print(animals.toList()); | |
Set<String> animals2 = HashSet.of(['dog', 'dog', 'cat']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:firebase_crashlytics/firebase_crashlytics.dart'; | |
import 'package:flutter/foundation.dart'; | |
import 'package:flutter/widgets.dart'; | |
void main() { | |
final crashlytics = FirebaseCrashlytics.instance; | |
// いずれも未キャッチ例外なので `fatal: true`(ネイティブのクラッシュと同等の扱い)が適切 | |
// (例外処理であまり想定してないException受け取った時などは `fatal: false` でも良い感) | |
// オリジナルの`FlutterError.presentError`は呼ばずともログは充分そう | |
FlutterError.onError = crashlytics.recordFlutterFatalError; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@freezed | |
class User with _$User { | |
@JsonSerializable() | |
const factory User( | |
@JsonKey() String? displayName, | |
) = _User; | |
const User._(); | |
factory User.fromJson(JsonMap json) => _$UserFromJson(json); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
targets: | |
$default: | |
builders: | |
source_gen|combining_builder: | |
options: | |
ignore_for_file: | |
- type=lint | |
- implicit_dynamic_parameter | |
- implicit_dynamic_type | |
- implicit_dynamic_method |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"explorer.fileNesting.enabled": true, | |
"explorer.fileNesting.expand": false, | |
"explorer.fileNesting.patterns": { | |
"pubspec.yaml": ".flutter-plugins, .packages, .dart_tool, .flutter-plugins-dependencies, .metadata, .packages, pubspec.lock, build.yaml, analysis_options.yaml, all_lint_rules.yaml, pubspec_overrides.yaml, flutter_launcher_icons*.yaml", | |
".gitignore": ".gitattributes, .gitmodules, .gitmessage, .mailmap, .git-blame*", | |
"readme.*": "authors, backers.md, changelog*, citation*, code_of_conduct.md, codeowners, contributing.md, contributors, copying, credits, governance.md, history.md, license*, maintainers, readme*, security.md, sponsors.md", | |
"*.dart": "$(capture).g.dart, $(capture).freezed.dart" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
targets: | |
$default: | |
builders: | |
source_gen|combining_builder: | |
options: | |
build_extensions: | |
'^lib/{{}}.dart': 'lib/generated/{{}}.g.dart' | |
freezed: | |
options: | |
build_extensions: |