Skip to content

Instantly share code, notes, and snippets.

View PlugFox's full-sized avatar
🦊
🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊

Plague Fox PlugFox

🦊
🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊🦊
View GitHub Profile
@PlugFox
PlugFox / main.dart
Last active June 3, 2025 00:23
Mutex in Dart
// ignore_for_file: avoid_print, unawaited_futures, curly_braces_in_flow_control_structures
/*
* Mutex in Dart
* https://gist.github.com/PlugFox/a923f32c9301a653116590da7cc18674
* https://dartpad.dev?id=a923f32c9301a653116590da7cc18674
* Mike Matiunin <[email protected]>, 02 June 2025
*/
import 'dart:async';
@PlugFox
PlugFox / bytes_util.dart
Last active May 9, 2025 09:51
Flutter file picker
import 'dart:typed_data';
import 'package:crypto/crypto.dart' as crypto;
import 'package:meta/meta.dart';
@internal
abstract final class BytesUtil {
/// Extract hash from a [Uint8List] and convert it to a hex string.
static String sha256(Uint8List bytes) {
if (bytes.isEmpty) return 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855';
@PlugFox
PlugFox / main.dart
Created April 22, 2025 10:24
Dart Utf8Decoder example
/*
* Dart Utf8Decoder example
* https://gist.github.com/PlugFox/c82c6147ccac451faa55efa8b55c80ae
* https://dartpad.dev?id=c82c6147ccac451faa55efa8b55c80ae
* Mike Matiunin <[email protected]>, 22 April 2025
*/
// ignore_for_file: avoid_print
import 'dart:async';
@PlugFox
PlugFox / sse_stream.dart
Last active April 18, 2025 19:38
Dart SSE stream with HTTP Client
import 'dart:async';
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:l/l.dart';
/// Creates a stream of server-sent events (SSE) from the given URL.
/// The stream will emit events as a tuple of event name and data.
Stream<({String event, Map<String, Object?> data})> sse(
String url, {
@PlugFox
PlugFox / sse.dart
Created April 18, 2025 13:41
Dart SSE with Dio
import 'dart:async';
import 'dart:convert';
import 'dart:math' as math;
import 'package:dio/dio.dart';
import 'package:l/l.dart';
/// A type alias for a server sent event (SSE) pair.
/// This is a tuple that contains the event name and the data associated with it.
typedef SSEPair = ({String event, Map<String, Object?> data});
@PlugFox
PlugFox / main.dart
Last active April 2, 2025 09:26
Chat bubbles with input field V2
/*
* Chat bubbles with input field V2
* https://gist.github.com/PlugFox/30097d608f08dfd97e8dc7589bda4f07
* https://dartpad.dev?id=30097d608f08dfd97e8dc7589bda4f07
* Mike Matiunin <[email protected]>, 02 April 2025
*/
import 'dart:async';
import 'package:flutter/foundation.dart';
@PlugFox
PlugFox / main.dart
Last active May 30, 2025 02:19
A simple declarative navigation system for Flutter.
/*
* Declarative Navigation
* A simple declarative navigation system for Flutter.
* https://gist.github.com/PlugFox/aaa2a1ab4ab71b483b736530ebb03894
* https://dartpad.dev?id=aaa2a1ab4ab71b483b736530ebb03894
* Mike Matiunin <[email protected]>, 14 March 2025
*/
import 'dart:async';
import 'dart:collection';
@PlugFox
PlugFox / main.dart
Last active March 20, 2025 15:54
DateTime to int, Date and Time extension
// ignore_for_file: avoid_print
/*
* Date <==> Int conversion
* https://gist.github.com/PlugFox/a94be8655b2adb91336f03bc77513d76
* https://dartpad.dev?id=a94be8655b2adb91336f03bc77513d76
* Mike Matiunin <[email protected]>, 20 March 2025
*/
/// Date extension type
@PlugFox
PlugFox / main.dart
Last active March 9, 2025 15:30
Property widget with dots / bulets for Flutter
/// {@template property_widget}
/// Widget to display a property with a label and a value.
/// [label] β€’ β€’ β€’ β€’ β€’ [value]
///
/// Tip: Use `DefaultTextStyle` to customize the underlying text style.
/// Tip: User `FittedBox` to downscale the size of form at limited space.
/// {@endtemplate}
class PropertyWidget extends StatelessWidget {
/// {@macro property_widget}
const PropertyWidget({
@PlugFox
PlugFox / main.dart
Last active February 27, 2025 20:58
CustomClipper with MultiChildLayoutDelegate
/*
* CustomClipper with MultiChildLayoutDelegate
* https://gist.github.com/PlugFox/d9e36528326d59f3429d131e610bf315
* https://dartpad.dev?id=d9e36528326d59f3429d131e610bf315
* Mike Matiunin <[email protected]>, 27 February 2025
*/
import 'dart:async';
import 'dart:math' as math;