Skip to content

Instantly share code, notes, and snippets.

View xvrh's full-sized avatar

Xavier H. xvrh

  • Freelance
  • Belgium
View GitHub Profile
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:math' as math;
import 'dart:ui' show window;
import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
@xvrh
xvrh / main.dart
Last active June 10, 2020 21:01
Try to use firstWhere with dart null safety
void main() {
var list = ['a', 'b', 'c'];
String? d = list.firstWhere((e) => e == 'd', orElse: () => null);
}
@xvrh
xvrh / main.dart
Created January 12, 2021 09:18
qr_code_scanner iOS 14 green dot
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:qr_code_scanner/qr_code_scanner.dart';
void main() => runApp(MaterialApp(home: Home()));
class Home extends StatelessWidget {
@override
@xvrh
xvrh / hot_reload.dart
Created March 25, 2021 08:44
Shelf hot reload
import 'dart:io';
import 'dart:developer' as dev;
import 'package:shelf/shelf_io.dart' as io;
import 'package:shelf/shelf.dart' as shelf;
import 'package:vm_service/utils.dart';
import 'package:vm_service/vm_service.dart';
import 'package:vm_service/vm_service_io.dart';
import 'package:watcher/watcher.dart';
import 'package:stream_transform/stream_transform.dart';