Skip to content

Instantly share code, notes, and snippets.

@magillus
magillus / dart-parsing-helper.dart
Created January 9, 2019 22:36
Dart useful methods for parsing Json/map to object
bool whenNull(dynamic value) {
return value == null;
}
bool whenNotNull(dynamic value) {
return value != null;
}
bool whenNullMap(String key, value) {
@magillus
magillus / example.dart
Last active March 19, 2019 03:22
StreamBuilderFiltered - For filtered and cast streams.
abstract class MyBlocState{}
class Step1State extends MyBlocState{
String title;
}
class Step2State extends MyBlocState{
int progress;
}
class Step3State extends MyBlocState{
}
@magillus
magillus / anywhere.dart
Last active March 21, 2019 22:05
Dart Unit tests - expectException method.
import 'package:test/test.dart';
main() {
test("throw excpetion test",() {
expectException(()=>throw Exception("sample error"), Exception);
});
}
@magillus
magillus / example.kt
Created April 11, 2019 14:11
Koin helper methods for module definition with Generic types - here StateMachine is generic
///define in module
val stateMachineModule = module {
stateFactory{ TestImplStateMachine() } bind StateMachine::class
}
/// inject or get
val stateMachineTest:StateMachine<MyState> = getSm()
///class of state machine
class TestImplStateMachine : StateMachine<MyState> {
@magillus
magillus / main.dart
Created December 6, 2019 14:27
Flutter form test
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override