Skip to content

Instantly share code, notes, and snippets.

View s0nerik's full-sized avatar
🎯
Building stuff

Sasha Isaienko s0nerik

🎯
Building stuff
View GitHub Profile
@s0nerik
s0nerik / main.dart
Created September 21, 2022 10:27
amber-fauna-4028
void main() {
print(DateTime.now());
print(DateTime.now().toUtc());
print(DateTime.now().difference(DateTime.now().toUtc()));
}
@s0nerik
s0nerik / main.dart
Last active September 27, 2023 09:07
(Dart) FutureOr handling differences
import 'dart:async';
/// Produces the following output (since [futureOrResult] value is available synchronously):
/// ```
/// process: 0
/// result: 0
/// process: 1
/// ```
Future<void> main() async {
unawaited(process());
@s0nerik
s0nerik / main.dart
Created October 25, 2023 12:26
Counter example
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
import 'dart:async';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@s0nerik
s0nerik / main.dart
Created March 20, 2025 23:53
Flutter widget rebuilds: const vs cached instance vs no caching
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {