Skip to content

Instantly share code, notes, and snippets.

@nmaruy27
nmaruy27 / database.dart
Last active February 6, 2023 13:57
driftで実行されるSQLを確認する方法
final stmt = select(tables);
stmt.where((t) => t.ticnameker.equals(name));
stmt.where((t) => t.updated.year.equals(date.year));
stmt.orderBy([(t) => OrderingTerm(expression: t.updated, mode: OrderingMode.desc)]);
// この2行で、実行SQLと条件に入る値の両方を出力できる
print('Query : ${stmt.constructQuery().sql}');
print('Variables : ${stmt.constructQuery().boundVariables}');
@nmaruy27
nmaruy27 / pubspec.yaml
Last active November 22, 2022 14:45
rpsパッケージのサンプル
name: sample
scripts:
gen: flutter pub run build_runner build -d
prod:
build:
before-ios: flutterfire configure -y -o lib/generated/flutterfire/firebase_options_production.dart -p sample-prj -i com.example.sample -a com.example.sample
ios: flutter build ipa --release --flavor production -t lib/main_production.dart
before-android: flutterfire configure -y -o lib/generated/flutterfire/firebase_options_production.dart -p sample-prj -i com.example.sample -a com.example.sample
android: flutter build appbundle --release --flavor production -t lib/main_production.dart
@nmaruy27
nmaruy27 / code.ts
Last active November 16, 2022 12:15
ルートフォルダ直下に作成し、その後に指定フォルダへ移動させる
// ルートフォルダ直下にスプレッドシートを作成
const fileId = SpreadsheetApp.create(spreadsheetName).getId();
// 移動先フォルダの取得
const folder = DriveApp.getFolderById(dataFolder.getId());
// スプレッドシートを移動
DriveApp.getFileById(fileId).moveTo(folder);
@nmaruy27
nmaruy27 / code.ts
Last active November 16, 2022 12:12
フォルダを作成し、その配下にスプレッドシートを作成するGoogle Apps Script
function createSpreadSheetInSpecificFolder(): SpreadSheet {
// 作成するフォルダを格納するフォルダ(ややこしい…)のIDは事前に取得し、CURRENT_FOLDER_IDとして定義しておく
// 【フォルダIDの取得方法】
// Googleドライブの対象フォルダをブラウザで開き、URLの最後のランダム文字列を取得する
// 例) https://drive.google.com/drive/folders/1G99xxx_J9a2QOWgspkDWPjxDdAxxxjyf
//        このURLの場合「1G99xxx_J9a2QOWgspkDWPjxDdAxxxjyf」がIDになる
const currentFolder = DriveApp.getFolderById(CURRENT_FOLDER_ID);
// 作成したいフォルダが既に存在している場合は、ゴミ箱に移動する
const folders = currentFolder.getFoldersByName(DATA_FOLDER_NAME);
@nmaruy27
nmaruy27 / lint_error.txt
Last active July 28, 2022 06:01
lint_error
┌─ Flutter Fix ───────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ This issue appears to be https://github.com/flutter/flutter/issues/58247. │
│ Fix this issue by adding the following to the file /Users/hoge/app_name/android/app/build.gradle: q│
│ android { │
│ lintOptions { │
│ checkReleaseBuilds false │
│ } │
│ } │
@nmaruy27
nmaruy27 / build.gradle
Last active July 28, 2022 05:12
build.gradle
android {
// 省略
defaultConfig {
applicationId "com.example.app_name"
minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
@nmaruy27
nmaruy27 / local.properties
Last active July 28, 2022 03:08
local.properties
sdk.dir=/Users/hoge/Library/Android/sdk
flutter.sdk=/opt/homebrew/Caskroom/flutter/3.0.4/flutter
flutter.buildMode=release
flutter.versionName=1.0.0
flutter.versionCode=1
flutter.minSdkVersion=21 # ←これを追加しても反映されない
@nmaruy27
nmaruy27 / build.gradle
Last active July 28, 2022 02:51
build.gradle
android {
// 省略
defaultConfig {
applicationId "com.example.app_name"
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
@nmaruy27
nmaruy27 / flutter_minSdkVersion_error_message.txt
Last active July 28, 2022 02:39
flutter minSdkVersion error message
┌─ Flutter Fix ───────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ The plugin google_mobile_ads requires a higher Android SDK version. │
│ Fix this issue by adding the following to the file /Users/hoge/app_name/android/app/build.gradle: │
│ android { │
│ defaultConfig { │
│ minSdkVersion 19 │
│ } │
│ } │
@nmaruy27
nmaruy27 / form.dart
Last active June 20, 2022 15:23
useMemorizedを使ったGlobalKeyの生成
class HogeWidget extends HookConsumerWidget {
// 略
@override
Widget build(BuildContext context, WidgetRef ref {
// 略
final formKey = useMemorized(() => GlobalKey<FormBuilderState>());
// 略
return FormBuilder(