This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int dateToValue(DateTime date) { | |
assert(date.isUtc, 'DateTime must be in UTC'); | |
return (date.year << 9) | (date.month << 5) | date.day; | |
} | |
DateTime valueToDate(int value) => | |
DateTime.utc(value >> 9, (value >> 5) & 0xF, value & 0x1F); | |
int dateTimeToValue(DateTime dateTime) { | |
assert(dateTime.isUtc, 'DateTime must be in UTC'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// {@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({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async' show Future, Zone, scheduleMicrotask; | |
final Object _deferredPushKey = Object(); | |
/// Defers the given [callback] function to be executed after the current zone. | |
/// The callback will be executed in the reverse order of their registration. | |
void defer(void Function() callback) { | |
final push = Zone.current[_deferredPushKey]; | |
if (push is void Function(void Function() callback)) { | |
push(callback); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"status": "ok", | |
"data": { | |
"from": "2025-02-17T15:51:19.647Z", | |
"to": "2025-02-24T15:51:19.647Z", | |
"active": [ | |
{ | |
"cid": -1001782660763, | |
"users": [ | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension type const Date.of(DateTime _date) implements DateTime { | |
Date(int year, int month, int day) : _date = DateTime(year, month, day); | |
Date.now() : _date = DateTime.now(); | |
Date.value(int value) : _date = DateTime((value >> 9), (value >> 5) & 0xF, value & 0x1F); | |
int get value => (_date.year << 9) | (_date.month << 5) | _date.day; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Format numbers | |
// https://dartpad.dev/?id=22aa280ffe2d847ca8c074b7eebca969 | |
import 'dart:math' as math; | |
String formatNumber$1(int number) => number.toString().replaceAllMapped( | |
RegExp(r'(\d)(?=(\d{3})+(?!\d))'), | |
(match) => '${match[1]} ', | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:isolate'; | |
import 'dart:math' as math; | |
import 'dart:typed_data'; | |
import 'package:benchmark_harness/benchmark_harness.dart'; | |
// $ dart run bin/nums.dart | |
// | |
// $ dart compile exe bin/nums.dart -o out/nums.exe | |
// $ ./out/nums.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:math' as math; | |
import 'dart:ui'; | |
import 'package:flutter/foundation.dart'; | |
import 'package:flutter/gestures.dart'; | |
import 'package:flutter/rendering.dart'; | |
import 'package:flutter/scheduler.dart'; | |
import 'package:flutter/services.dart'; | |
class _Binding = BindingBase |
NewerOlder