Skip to content

Instantly share code, notes, and snippets.

Avatar
🐶
( ´・‿・`)

Masayuki Ono (mono) mono0926

🐶
( ´・‿・`)
View GitHub Profile
View index.html
<style>
@media (prefers-color-scheme: dark) {
body {
background-color: black;
}
}
</style>
@mono0926
mono0926 / pubspec.yaml
Created May 18, 2022
json_serializableのJsonConverterをnullable/非nullableのフィールドに共用する版の指定
View pubspec.yaml
dependency_overrides:
json_serializable:
git:
url: https://github.com/google/json_serializable.dart
ref: 09cca32f7548fe8a31b5db0941ca142a13f0ed6e
path: json_serializable
@mono0926
mono0926 / dart.json
Created May 17, 2022
ThemeExtensionのUser Snippet
View dart.json
"Theme Extension": {
"prefix": "thmex",
"description": "Insert a Theme Extension class",
"body": [
"@immutable",
"class $1 extends ThemeExtension<$1> {",
" const $1({",
" required this.$3,",
" });",
"",
View main.dart
import 'package:test/test.dart';
import 'package:lexicographical_order/lexicographical_order.dart';
void main() {
test('Output', () {
final first = generateOrderKeys(1).first;
print('first: $first'); // a
final previous = between(next: first);
print('previous: $previous'); // N
final next = between(prev: first); // n
View main.dart
import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
Future<void> main() async {
GoRouter.setUrlPathStrategy(UrlPathStrategy.path);
runApp(const App());
}
final router = GoRouter(
View main.dart
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for ThemeExtension
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:intl/intl.dart';
View main.dart
const condition = false;
void main() {
// {} 省略はミスの元なので一般的に良くないと言われているけどdart format前提ならミスしなさそうで、ありな気もする🤔
// https://dart-lang.github.io/linter/lints/always_put_control_body_on_new_line.html
if (condition) throw Exception('hello');
// `throw`の前で改行してFix Allすると自動的に {} 付けてくれて便利
if (condition) {
throw Exception('hello');
@mono0926
mono0926 / settings.json
Last active Mar 9, 2022 — forked from gaetschwartz/settings.json
Nest files in Flutter projects on VSCode, inspired from https://github.com/antfu/vscode-file-nesting-config
View settings.json
"explorer.experimental.fileNesting.enabled": true,
"explorer.experimental.fileNesting.expand": false,
"explorer.experimental.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, l10n.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",
},
View count_state.dart
import 'package:flutter/foundation.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'count_state.freezed.dart';
@freezed
class CountState with _$CountState {
const factory CountState({
@Default(0) int count,
}) = _CountState;
View count_controller.dart
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'count_state.dart';
final countProvider = StateNotifierProvider<CountController, CountState>(
(ref) => CountController(ref.read),
);
class CountController extends StateNotifier<CountState> {
CountController(this._read) : super(const CountState());