Skip to content

Instantly share code, notes, and snippets.

void main() {
Integer a = 125;
Integer b = 125;
print(a == b);
// true
Integer a1 = 128;
Integer b2 = 128;
print(a == b);
// false
void main() {
Integer a = 125;
Integer b = 125;
print(a == b);
// true
Integer a1 = 128;
Integer b2 = 128;
print(a == b);
// false
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
@featzima
featzima / Bloc.kt
Created October 17, 2019 09:51
The BLoC implementation with Kotlin
abstract class Bloc<State, Event> : ViewModel() {
private val timber by lazy { Timber.tag(javaClass.simpleName) }
private val events = Channel<Event>(Channel.UNLIMITED)
private var _currentState = ConflatedBroadcastChannel(initialState)
protected val currentState: ReceiveChannel<State>
get() = _currentState.openSubscription()
class Setter<T> {
final T value;
Setter(this.value);
}
Setter<T> set<T>(T value) {
return Setter<T>(value);
}
@featzima
featzima / data_class.dart
Last active April 28, 2019 21:06
Live Templete of the IDEA (the Android Studio) for creating data classes for Dart Built Value plugin.
import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart';
part '$name$.g.dart';
abstract class $Name$ implements Built<$Name$, $Name$Builder> {
static Serializer<$Name$> get serializer => _$$$name$Serializer;
// String get id;$END$
class MainActivity : AppCompatActivity() {
private val userAge by sharedPreference(this, -1)
}
class CounterThread : Thread() {
private lateinit var handler: Handler
override fun run() {
Looper.prepare()
handler = object: Handler() {
private var counter = 100
@featzima
featzima / FragmentSoftInputCorrector.kt
Created April 4, 2019 14:22
FragmentSoftInputCorrector changes a soft input type of activity for a single fragment that requires SOFT_INPUT_ADJUST_RESIZE during it is attached to this activity
/**
* FragmentSoftInputCorrector changes a soft input type of activity
* for a single fragment that requires SOFT_INPUT_ADJUST_RESIZE
* during it is attached to this activity
*
* Usage inside a fragment:
*
* override fun onAttach(context: Context) {
* super.onAttach(context)
* FragmentSoftInputCorrector(activity!!, this)
inline fun <R> Cursor.map(transform: (Cursor) -> R): List<R> {
val result = ArrayList<R>(count)
while (moveToNext()) {
result.add(transform(this))
}
return result
}