Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Laxman Bhattarai erluxman

🏠
Working from home
View GitHub Profile
@erluxman
erluxman / build.gradle
Created May 24, 2017
Kotlin data binding setup of app level build.gradle
View build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.example.adventure.learningbycomparing"
@erluxman
erluxman / build.gradle
Created May 24, 2017
Project level Build.gradle
View build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven { url 'https://maven.google.com' }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha1'
// NOTE: Do not place your application dependencies here; they belong
@erluxman
erluxman / dependencies.gradle
Created Dec 26, 2017
android dependency list
View dependencies.gradle
ext {
versions = [
support : '27.0.1',
constraintLayout: '1.0.2',
firebase : '11.8.0',
kotlin_version : '1.2.10',
moshi : "1.5.0",
okHttp : "3.8.1",
retrofit : '2.3.0',
dagger : '2.11',
@erluxman
erluxman / RestClient.kt
Created May 9, 2018
Rest Client for caching
View RestClient.kt
package com.thorangs.retrofitcachingtest
import android.content.Context
import com.google.gson.GsonBuilder
import okhttp3.Cache
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory
@erluxman
erluxman / ImageView.kt
Last active Sep 25, 2018
extension function for loading image with picasso..
View ImageView.kt
fun ImageView.loadImage(url: String ="", @DrawableRes drawable: Int = R.mipmap.ic_launcher, placeHolderUrl: String = "", @NonNull placeHolderDrawable: Int = R.mipmap.ic_launcher, circular: Boolean = false) {
val defUrl = ""
@DrawableRes
val defDrawable = R.mipmap.ic_launcher
when {
//Displaying image from Url
url.isNotEmpty() && circular -> Picasso.get().load(url).placeholder(placeHolderDrawable).transform(CircleTransform()).into(this);
url.isNotEmpty() && !circular -> Picasso.get().load(url).placeholder(placeHolderDrawable).into(this)
@erluxman
erluxman / CascadeOperator.dart
Last active Apr 8, 2020
Method / variable call chaining in dart.
View CascadeOperator.dart
//Cascade/Chaining/Fluent Operations
//We can chain method/member calls without returning `this` from method/getter/setter
class User {
String name;
int age;
User({this.name = "Foo", this.age = 0});
User withName(String name) {
@erluxman
erluxman / richtextdemo.dart
Created Apr 10, 2020
Richtext demo with different syles
View richtextdemo.dart
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@erluxman
erluxman / SpacerDemo.dart
Last active Apr 11, 2020
Demo of spacer widget
View SpacerDemo.dart
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@erluxman
erluxman / listviewseparated.dart
Created Apr 12, 2020
ListViewbuilder with Separator
View listviewseparated.dart
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@erluxman
erluxman / FunctionAsParameter
Last active Apr 13, 2020
dart functions as parameter
View FunctionAsParameter
void main() {
function2(function1, 3);
function2(function1, 4);
function2(function1, 7);
function2(function1, 9);
}
function1(int evenOrOdd) {
print("$evenOrOdd is ${evenOrOdd % 2 == 0 ? "Even" : "Odd"}");
}