Skip to content

Instantly share code, notes, and snippets.

class MyAnimatedCrossFade extends StatelessWidget {
const MyAnimatedCrossFade({
super.key,
required this.duration,
required this.index,
required this.children,
}) : assert(index >= 0 && index < children.length);
final Duration duration;
final int index;
class AnimatedValueBuilder<T> extends StatefulWidget {
const AnimatedValueBuilder({
super.key,
required this.duration,
required this.tween,
required this.progress,
required this.builder,
this.child,
}) : assert(progress >= 0 && progress <= 1);
analyzer:
exclude:
- "**.g.dart"
- "**.chopper.dart"
- "**.freezed.dart"
language:
strict-casts: true
strict-inference: true
strict-raw-types: true
errors:
@urusaich
urusaich / tap_gesture_detector.dart
Created November 3, 2024 07:46
Conditionally Tap Gesture Detector
import 'package:flutter/gestures.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
typedef WhenCallback = bool Function(Offset position);
class ConditionallyTapGestureDetector extends SingleChildRenderObjectWidget {
const ConditionallyTapGestureDetector({
super.key,
this.behavior = HitTestBehavior.deferToChild,
@urusaich
urusaich / colors.dart
Last active January 12, 2025 19:58
ColorTween and AnimatedColor widget
import 'dart:ui';
import 'package:flutter/widgets.dart';
class MyColorTween extends Tween<Color> {
MyColorTween({
required Color super.begin,
required Color super.end,
});
@urusaich
urusaich / remains.dart
Created October 16, 2024 20:57
Time remains
String remainsText(
Duration? remains, {
String leading = ' (',
String trailing = ')',
bool padMinutes = true,
bool padSeconds = true,
}) {
if (remains == null) {
return '';
}
import 'dart:async';
import 'package:flutter/widgets.dart';
import 'resume_lock_action.dart';
import 'resume_lock_delegate.dart';
export 'resume_lock_action.dart';
export 'resume_lock_delegate.dart';