https://flutter.dev/docs/development/tools/sdk/releases?tab=macos #change withyour os version
flutter version $version
| class RepoTest(private val testDao:TestDao){ //inject dao using Koin | |
| fun insertTest(test:Test) : Single<Resource<String>> = testDao.insertTest(test) | |
| . .subscribeOn(Schedulers.io()) | |
| .map<Resource<String>> { t -> Resource.Success(t.toString()) } // convert primary key value to String | |
| .onErrorReturn { Resource.Failure(it) } | |
| .observeOn(AndroidSchedulers.mainThread()) | |
| } |
| /** | |
| * This sample count down timer | |
| * for auction app when bid start and end | |
| */ | |
| private lateinit var countDownTimer: CountDownTimer | |
| private var difference = 0L | |
| private var isStart = false | |
| private var startTime = "" // you can chage it with Date | |
| private var endTime = "" |
| //save object as json | |
| val adapter = Moshi.Builder().build().adapter(SavedObject::class.java) | |
| val json = adapter.toJson(it.data?.body()?.result) | |
| prefManager.saveString("Saved Object", json) | |
| //load object | |
| val objectJson = prefManager.getString("Saved Object") | |
| val adapter = Moshi.Builder().build().adapter(SavedObject::class.java) | |
| val result = adapter.fromJson(objectJson) |
| //date format for timestampz | |
| val formatInput = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" | |
| val formatOutput = "dd MMMM yyyy HH:mm:ss" | |
| val sdfInput = SimpleDateFormat(formatInput, Locale("id", "ID")) | |
| val sdfOutput = SimpleDateFormat(formatOutput, Locale("id", "ID")) | |
| val date = sdfInput.parse(dataHome.apraisTime) | |
| val newOutput = sdfOutput.format(date) |
| startActivity(Intent(applicationContext, NextActivity::class.java).apply { | |
| flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP | |
| }) |
| [ | |
| [ | |
| "Esc", | |
| "!\n1", | |
| "@\n2", | |
| "#\n3", | |
| "$\n4", | |
| "%\n5", | |
| "^\n6", | |
| "&\n7", |
| [ | |
| [ | |
| "app", | |
| "F1", | |
| "F2", | |
| "F3", | |
| "F4", | |
| "F5", | |
| "F6", | |
| "F7", |
https://flutter.dev/docs/development/tools/sdk/releases?tab=macos #change withyour os version
flutter version $version
https://flutter.dev/docs/development/tools/sdk/releases?tab=macos #change with your os version
flutter version $version
#example : flutter version 1.21.0-1.0.pre
| import 'package:flutter/material.dart'; | |
| import 'package:flutter/scheduler.dart'; | |
| typedef void OnWidgetSizeChange(Size size); | |
| class MeasureSize extends StatefulWidget { | |
| final Widget child; | |
| final OnWidgetSizeChange onChange; | |
| const MeasureSize({ |