Skip to content

Instantly share code, notes, and snippets.

View hawkkiller's full-sized avatar
🎯
Focusing

Michael Lazebny hawkkiller

🎯
Focusing
View GitHub Profile
@hawkkiller
hawkkiller / sharded_test_run.dart
Created December 20, 2025 11:53
A simple Dart program for sharded test running
import 'dart:async';
import 'dart:collection';
import 'dart:io';
import 'dart:math';
import 'package:args/args.dart';
import 'package:path/path.dart' as path;
ArgParser buildParser() => ArgParser()
..addOption('current-shard', abbr: 'c', mandatory: true)
@hawkkiller
hawkkiller / press_scale_transition.dart
Last active December 14, 2025 20:04
A widget that slightly scales down the pressed widget. Useful for tappable elements, such as buttons to make them feel more alive.
/// Notification sent when a [PressScaleTransition] handles a press.
/// Used to prevent ancestor [PressScaleTransition]s from animating.
class _PressScaleNotification extends Notification {
const _PressScaleNotification();
}
/// A widget that adds a subtle scale down effect when pressed.
///
/// When nested, only the innermost [PressScaleTransition] will animate,
/// preventing unwanted visual effects on parent buttons.
@hawkkiller
hawkkiller / heavy_card.dart
Created December 4, 2025 08:34
A heavy card to simulate performance problems
class _SomeHeavyCard extends StatelessWidget {
const _SomeHeavyCard({required this.index});
final int index;
@override
Widget build(BuildContext context) {
return Card(
elevation: 10,
margin: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
@hawkkiller
hawkkiller / cool_animated_switcher.dart
Last active December 12, 2025 19:40
This is a cool sliding transition for widgets. It's inspired by the wolt_modal_sheet package, which has the same animation but is coupled with the Bottom Sheet/Pages API. This implementation should be also more performant and less fragile.
import 'package:flutter/material.dart';
/// A widget that transitions between two children using a fade and slide animation.
class PageTransitionSwitcher extends StatelessWidget {
const PageTransitionSwitcher({
required this.child,
this.isForwardMove = true,
super.key,
});
@hawkkiller
hawkkiller / shimmer.dart
Created September 9, 2025 14:30
Shimmer implemented with linear gradient and a shimmer implemented with custom shader.
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
class Shimmer extends StatefulWidget {
const Shimmer({super.key, this.size, this.child});
/// The size of the shimmer effect.
///
/// Either this or [child] must be provided.
/// If both are provided, [child] takes precedence.
@hawkkiller
hawkkiller / button.dart
Created January 24, 2025 10:51
Different buttons for design system
import 'package:ui/ui.dart';
sealed class UiButton extends StatelessWidget {
const UiButton({super.key});
const factory UiButton.primary({
required String label,
required VoidCallback? onPressed,
Widget? icon,
bool isEnabled,
@hawkkiller
hawkkiller / sticky_headers.dart
Created November 23, 2024 12:00
Simple and efficient sticky headers
import 'package:flutter/material.dart';
void main() {
runApp(const MainApp());
}
class MainApp extends StatelessWidget {
const MainApp({super.key});
@override
@hawkkiller
hawkkiller / bloc.dart
Last active March 31, 2025 13:01
A good looking BLoC that conforms to design principles and manages the state correctly.
import 'package:bloc/bloc.dart';
class UserProfile {
UserProfile({
required this.name,
this.age,
});
final String name;
final int? age;
@hawkkiller
hawkkiller / scope.dart
Created September 21, 2024 12:51
Scope used for lazy initialization
import 'package:flutter/material.dart';
class SettingsBloc {
void close() {}
}
/// {@template settings_scope}
/// SettingsScope widget.
/// {@endtemplate}
class SettingsScope extends StatefulWidget {
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
class AnimatedEdgeSlide extends SingleChildRenderObjectWidget {
const AnimatedEdgeSlide({
required Widget super.child,
required this.positionAnimation,
super.key,
});