Skip to content

Instantly share code, notes, and snippets.

View javaherisaber's full-sized avatar

Mahdi Javaheri javaherisaber

View GitHub Profile
apgapg / logging_interceptor.dart
Created April 9, 2020 05:37
Logging interceptor for dio, flutter
import 'dart:async';
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
/// [LoggingInterceptor] is used to print logs during network requests.
/// It's better to add [LoggingInterceptor] to the tail of the interceptor queue,
/// otherwise the changes made in the interceptor behind A will not be printed out.
/// This is because the execution of interceptors is in the order of addition.
class LoggingInterceptor extends Interceptor {
tarek360 / CurvedShape.dart
Last active February 8, 2023 00:54
Draw a curved shape in Flutter
import "package:flutter/material.dart";
import 'package:flutter/services.dart';
import 'dart:math';
const CURVE_HEIGHT = 160.0;
void main() => runApp(new MyApp());
simonesestito / layout_with_fab.xml
Created August 5, 2018 16:22
Extended FAB using Material Components on Android
<?xml version="1.0" encoding="utf-8"?><!--
~ Use Extended FAB on Android even if Material Components doesn't support it yet
~ See
~ Created by Simone Sestito
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android=""
JoseAlcerreca / EventObserver.kt
Created April 26, 2018 12:14
An Observer for Events, simplifying the pattern of checking if the Event's content has already been handled.
* An [Observer] for [Event]s, simplifying the pattern of checking if the [Event]'s content has
* already been handled.
* [onEventUnhandledContent] is *only* called if the [Event]'s contents has not been handled.
class EventObserver<T>(private val onEventUnhandledContent: (T) -> Unit) : Observer<Event<T>> {
override fun onChanged(event: Event<T>?) {
event?.getContentIfNotHandled()?.let { value ->
JoseAlcerreca / Event.kt
Created April 26, 2018 10:25
An event wrapper for data that is exposed via a LiveData that represents an event.
* Used as a wrapper for data that is exposed via a LiveData that represents an event.
open class Event<out T>(private val content: T) {
var hasBeenHandled = false
private set // Allow external read but not write
* Returns the content and prevents its use again.
keima / HowToUseActivity.kt
Last active March 31, 2024 21:58
LifecycleOwner implemented RecyclerView ViewHolder & Adapter (concept design)
import android.os.Bundle
import android.util.Log
import android.view.ViewGroup
import android.widget.TextView
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent
vestrel00 /
Last active October 7, 2021 19:59
A: 2.11 simple example with support for Singleton, PerActivity, PerFragment, and PerChildFragment scopes
// This is a super simplified example of how to use the new framework
// introduced in Dagger 2.10. For a more complete, in-depth guide to
// read
// For a complete codebase using 2.11-2.17, butterknife 8.7-8.8, and MVP,
// see
// This example works with Dagger 2.11-2.17. Starting with Dagger 2.11,
// @ContributesAndroidInjector was introduced removing the need to define @Subcomponent classes.