Skip to content

Instantly share code, notes, and snippets.

View hnvn's full-sized avatar

HungHD hnvn

View GitHub Profile
import 'package:flutter/material.dart';
class Shimmer extends StatefulWidget {
final Widget child;
final Duration period;
final Gradient gradient;
Shimmer({Key key, this.child, this.period, this.gradient}): super(key: key);
@override
import 'package:flutter/rendering.dart';
class _Shimmer extends SingleChildRenderObjectWidget {
final Gradient gradient;
_Shimmer({Widget child, this.gradient})
: super(child: child);
@override
_ShimmerFilter createRenderObject(BuildContext context) {
class FlipWidget extends StatelessWidget {
Widget child;
FlipWidget({Key key, this.child}) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Transform(
transform: Matrix4.rotationX(pi / 4),
alignment: Alignment.bottomCenter,
child: ClipRect(
child: Align(
...
Transform(
transform: Matrix4.identity()..setEntry(3, 2, 0.006)..rotateX(pi / 4),
alignment: Alignment.bottomCenter,
child: ClipRect(
child: Align(
alignment: Alignment.topCenter,
heightFactor: 0.5,
child: child,
)),
import 'package:flutter/material.dart';
import 'dart:math';
class DotsIndicator extends AnimatedWidget {
DotsIndicator({
Key key,
this.controller,
this.itemCount,
this.onPageSelected,
this.color: Colors.white,
class _ShimmerState extends State<Shimmer> with TickerProviderStateMixin {
AnimationController controller;
@override
void initState() {
super.initState();
controller = AnimationController(vsync: this, duration: widget.period)
..addListener(() {
setState(() {});
})
@hnvn
hnvn / single_top.dart
Created October 13, 2019 09:30 — forked from slightfoot/single_top.dart
Recreating Android Single-Top Activity behaviour with Flutter Route's - by Simon Lightfoot
// MIT License
//
// Copyright (c) 2019 Simon Lightfoot
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@hnvn
hnvn / tap_long_press_gesture.dart
Last active February 5, 2022 14:25
A simple GestureRecognizer that combines TapGestureRecognizer and LongPressGestureRecognizer
import 'package:flutter/gestures.dart';
///
/// A simple [GestureRecognizer] that combines [TapGestureRecognizer] and [LongPressGestureRecognizer]
/// It only supports two simple callbacks [onTap] and [onLongPress]
///
class TapAndLongPressGestureRecognizer extends PrimaryPointerGestureRecognizer {
/// Creates a gesture recognizer.
TapAndLongPressGestureRecognizer({
Duration? duration,