Skip to content

Instantly share code, notes, and snippets.

View RecyclerSticktHeader.kt
import android.graphics.Canvas
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.ItemDecoration
class StickHeaderItemDecoration(private val adapter: StickyAdapter) : ItemDecoration() {
private var stickyHeaderHeight = 0
private var currentTopChildPosition: Int? = null
private var currentTopChildHeaderPosition: Int? = null
View RectFrameLayout.java
import android.content.Context;
import android.support.annotation.AttrRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.widget.FrameLayout;
/**
* Created by florentchampigny on 20/07/2017.
*/
View TapScaleAnimated.dart
import 'package:flutter/material.dart';
class TapScaleAnimated extends StatefulWidget {
final Widget child;
final Function onTap;
final double scale;
TapScaleAnimated({this.child, @required this.onTap, this.scale = 0.9});
View BlurredBackground.dart
import 'dart:ui';
import 'package:flutter/material.dart';
class BlurredBackground extends StatelessWidget {
final Widget child;
final Image image;
final double blurSize;
final Color maskColor;
View lottie_sample_stars.json
{"v":"5.2.1","fr":25,"ip":0,"op":125,"w":1920,"h":1080,"nm":"Comp 1","ddd":0,"assets":[{"id":"comp_0","layers":[{"ddd":0,"ind":1,"ty":0,"nm":"small stars","refId":"comp_1","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.167],"y":[0]},"n":["0p667_1_0p167_0"],"t":77,"s":[85],"e":[4]},{"t":106}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[1832,244,0],"ix":2},"a":{"a":0,"k":[960,540,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"w":1920,"h":1080,"ip":0,"op":250,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":0,"nm":"small stars","refId":"comp_1","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"n":["0p667_1_0p333_0"],"t":89,"s":[100],"e":[4]},{"t":97}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[1824,684,0],"ix":2},"a":{"a":0,"k":[960,540,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"w":1920,"h":1080,"ip":0,"op":250,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":0,"nm":"small stars","refId":"comp_1","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"
View sample_lottie.json
{"v":"5.4.4","fr":24,"ip":0,"op":144,"w":850,"h":850,"nm":"delivery","ddd":0,"assets":[{"id":"comp_0","layers":[{"ddd":0,"ind":1,"ty":4,"nm":"grass Outlines","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":0,"s":[33,425,0],"e":[-2114,425,0],"to":[-357.833,0,0],"ti":[357.833,0,0]},{"t":143}],"ix":2},"a":{"a":0,"k":[3000.065,425,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[9.29,4.795],[0,0],[11.893,6.223],[0,0.948],[20.327,7.74],[9.478,-6.635],[0,0],[7.185,0],[0,0],[0,0],[0,0]],"o":[[-11.02,-5.687],[0,0],[-17.891,-9.36],[0,-0.947],[-28.318,-10.782],[-13.456,9.42],[0,0],[-22.901,0],[0,0],[0,0],[0.473,0]],"v":[[103.264,27.903],[84.307,28.495],[67.601,4.68],[37.861,2.903],[8.241,-30.035],[-50.763,-25.177],[-69.482,3.378],[-80.501,-0.059],[-114.874,40.817],[-88.914,40.817],[114.4,40.817]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector S
View json_api_sample.json
{
"data": {
"type": "articles",
"id": "id",
"attributes": {
"title": "title"
},
"relationships": {
"author": {
"data": {
View flutter_crashlytics.dart
void main() async {
bool isInDebugMode = false;
FlutterError.onError = (FlutterErrorDetails details) {
if (isInDebugMode) {
// In development mode simply print to console.
FlutterError.dumpErrorToConsole(details);
} else {
// In production mode report to the application zone to report to
// Crashlytics.
View MyWidget.dart
//a statefull widget receive it values directly from the constructor,
//from doc : A widget that does not require mutable state.
class MyWidget extends StateFullWidget {
//final == val (kotlin)
//underscore _ means private in dart
final _myText = "";
//default constructor, braces {} means the arguments can be provided in any order
//_myText = text means _myText is initialised with the `text` value automatically
View flutter_custom_painter.dart
class MyPainter extends CustomPainter {
...
@override
void paint(Canvas canvas, Size size) {
final line = Paint()
..color = lineColor
..strokeCap = StrokeCap.round
..style = PaintingStyle.stroke
..strokeWidth = width;