Skip to content

Instantly share code, notes, and snippets.

View Hexer10's full-sized avatar
🏠
Working from home

Mattia Hexer10

🏠
Working from home
View GitHub Profile
import 'package:benchmark_harness/benchmark_harness.dart';
final list = List.generate(100000, (index) => index);
class CollectionForBenchmark extends BenchmarkBase {
const CollectionForBenchmark() : super('CollectionFor');
static void main() {
CollectionForBenchmark().report();
}
String prettyHex(List<int> bytes, int length) {
final buffer = StringBuffer();
for (var i = 0; i < bytes.length; i += length) {
final list = bytes.sublist(i, min(i + length, bytes.length));
final l1 = list.map((e) => e.toRadixString(16).padLeft(2, '0')).toList();
final l2 = list.map((e) {
if (e > 0 && e < 128) {
return ascii.decode([e]);
}
return '.';
@Hexer10
Hexer10 / main.dart
Last active February 20, 2024 18:31
Flutter Web Camera
import 'dart:html';
import 'package:camera/camera.dart';
import 'package:flutter/material.dart';
Future<void> main() async {
runApp(CameraApp());
}
class CameraApp extends StatefulWidget {
import 'dart:async';
import 'dart:html';
import 'dart:typed_data';
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
void main() {
ui.platformViewRegistry.registerViewFactory(
'video-view',
message("Found Arduino SDK: ${ARDUINO_SDK_PATH}")
## Uncomment if Arduino SDK Path is wrong
# set(ARDUINO_SDK_PATH <custom path>)
### Edit here
set(CLI_PATH <path to arduino-cli.exe)
set(FQBN <your fully qualified board name>)
set(PORT <your port>
import 'dart:async';
import 'dart:convert';
import 'dart:ffi';
import 'dart:io';
import 'package:ffi/ffi.dart';
import 'package:win32/win32.dart';
const healthOffset = 0x12FC58;
class Singleton {
static final _instance = Singleton._internal();
factory Singleton() => _instance;
Singleton._internal();
}
try {
await someFuture();
} catch (e) {
print("called when there is an error catches error: $e");
try {
print("called with value = null");
} finally {
print("called when future completes");
}
}
try {
await someFuture();
} catch (e) {
print("called when there is an error catches error: $e");
try {
print("called with value = null");
} finally {
print("called when future completes");
}
}
.parseint : Parse a String to an Integer
ANY → int.parse($expr$)
.tryparseint : Try to parse a String to an Integer
ANY → int.tryParse($expr$)