Skip to content

Instantly share code, notes, and snippets.

name: canvas_clock
description: creativecreatorormaybenot's entry to the Flutter clock challenge.
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
@override
void visitChildrenForSemantics(visitor) {
final toBeVisited = <ClockComponent, RenderBox>{};
...
for (final component in paintOrder) {
if (toBeVisited.containsKey(component)) visitor(toBeVisited[component]);
}
}
@override
void describeSemanticsConfiguration(SemanticsConfiguration config) {
super.describeSemanticsConfiguration(config);
config
..label =
'Analog clock showing hour $hour${_use24HourFormat ? ' (and ${hour + 12})' : ''}, '
'minute $minute, and second $second'
..isReadOnly = true
..textDirection = TextDirection.ltr;
final paint = Paint()
..color = _sunColor
..strokeWidth = radius / 124;
canvas.drawOval(Rect.fromCircle(center: Offset.zero, radius: radius / 9), paint);
for (var i = 0; i < _sunRays; i++) {
final direction = pi * 2 / _sunRays * i;
canvas.drawLine(
Offset.fromDirection(direction, radius / 8),
final analogTime = layoutChildren[ClockComponent.analogTime],
analogTimeData =
layoutParentData[ClockComponent.analogTime] as AnalogTimeParentData,
analogTimeSize =
Size.fromRadius(size.height / 2.9 + 55) * spinUpAnimation.value;
@creativecreatorormaybenot
creativecreatorormaybenot / main.dart
Last active December 24, 2019 14:30
Dart Modulo
void main() {
print(-7 % 6); // 5
}
@creativecreatorormaybenot
creativecreatorormaybenot / main.dart
Last active December 18, 2019 15:23
Project Euler Problem 18 & Problem 67
/// This is my first Project Euler problem I attempt to solve in Dart.
/// It has been quite a few years since I solved the last problem and
/// I did not even know about Dart when I did it.
/// I think that Dart is not best suited for these kinds of problems because it is not performant
/// and also object-oriented instead of functional (which I would suppose works better for math problems)
/// or maybe Python because the syntax is better to solve math problems, but I have solved these problems in
/// Go, Kotlin, JavaScript, and other similar languages in the past and thus I see this as an opportunity to learn even more about Dart :)
import 'dart:math' as math;
void main() {
errors.dart:147 Uncaught (in promise) Error: EncodingError: The source image cannot be decoded.
at Object.throw_ [as throw] (errors.dart:196)
at async._AsyncCallbackEntry.new.callback (zone.dart:1114)
at Object._microtaskLoop (schedule_microtask.dart:43)
at _startMicrotaskLoop (schedule_microtask.dart:52)
at async_patch.dart:168
DartError @ errors.dart:147
throw_ @ errors.dart:196
(anonymous) @ zone.dart:1114
_microtaskLoop @ schedule_microtask.dart:43
[ +12 ms] Compiling lib\main.dart for the Web... (completed in 6.7s)
[ +11 ms] Building application for the web... (completed in 7.0s)
[ +281 ms] Warning: Flutter's support for web development is not stable yet and hasn't
[ +1 ms] been thoroughly tested in production environments.
[ ] For more information see https://flutter.dev/web
[ +1 ms] 🔥 To hot restart changes while running, press "r". To hot restart (and refresh the browser), press "R".
[ +15 ms] For a more detailed help message, press "h". To quit, press "q".
[ +325 ms] Failed to load asset at path: packages/build_web_compilers/src/dev_compiler/dart_sdk.js.
Status code: 404
Headers:
{
"date": "Tue, 19 Nov 2019 17:25:39 GMT",
"content-length": "9",
"x-frame-options": "SAMEORIGIN",