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 'package:boxy/flex.dart'; | |
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(const MyApp()); | |
} | |
class MyApp extends StatefulWidget { | |
const MyApp({Key? key}) : super(key: key); |
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'; | |
extension<T> on Stream<T> { | |
Stream<T> regulate(Duration rateLimit) { | |
final controller = StreamController<T>(); | |
Timer? timer; | |
DateTime? lastTime; | |
T? lastMessage; | |
listen( | |
(message) { |
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
void _paintArrow( | |
Canvas canvas, { | |
required Color color, | |
required Offset offset, | |
required double angle, | |
double length = 12.0, | |
}) { | |
final height = length * (sqrt(3) / 2); | |
final top = Offset(0, -height / 2); | |
final left = Offset(-length / 2, height / 2); |
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:convert'; | |
import 'dart:math'; | |
String charToHex(int c) => c.toRadixString(16).padLeft(2, '0'); | |
String charListToHex(List<int> s) => s.map(charToHex).join(' '); | |
String shortToHex(int c) => c.toRadixString(16).padLeft(4, '0'); | |
String shortListToHex(List<int> s) => s.map(shortToHex).join(' '); |
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 'package:flutter/material.dart'; | |
const Color darkBlue = Color.fromARGB(255, 18, 32, 47); | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override |
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'; | |
import 'package:flutter/material.dart'; | |
const Color darkBlue = Color.fromARGB(255, 18, 32, 47); | |
void main() { | |
runApp(MyApp()); | |
} |
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 'package:async/async.dart'; | |
import 'package:chopper/chopper.dart' as chopper; | |
import 'package:freezed_annotation/freezed_annotation.dart'; | |
import 'package:http/http.dart'; | |
abstract class RequestCopier { | |
const RequestCopier._(); | |
factory RequestCopier({ | |
required BaseRequest original, |
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 'package:flutter/cupertino.dart'; | |
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(const MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
const MyApp({Key? key}) : super(key: key); |
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
String format(String formatString, Map<String, dynamic> vars) { | |
return formatString.replaceAllMapped( | |
RegExp(r'\$(\w+)'), | |
(name) => '${vars[name.group(1)]}', | |
); | |
} | |
void main() { | |
print(format(r'There are $count players', {'count': 123})); | |
print(format(r'$x + $y = $z', {'x': 9, 'y': 10, 'z': 21})); |