Skip to content

Instantly share code, notes, and snippets.

@dnfield
dnfield / benchmark.dart
Created March 29, 2018 03:51
parseSvgPath vs precompiled
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'PathTest',
theme: new ThemeData(
@dnfield
dnfield / README.md
Last active September 20, 2018 20:31
Gets the versions of Flutter from GitHub

Flutter Version Check

This will print out the versions of the three major Flutter branches on GitHub.

$ dart flutter_version.dart
Flutter beta is at v0.4.4
Flutter dev is at v0.5.4
Flutter master is at <NO TAG>
@dnfield
dnfield / image_diff.dart
Created August 6, 2018 14:45
Image diffing code
import 'dart:math' as Math;
import 'dart:typed_data' show Uint8List;
int pixelmatch(
Uint8List img1, Uint8List img2, Uint8List output, int width, int height,
{double threshold = 0.1, bool includeAA = true}) {
if (img1.length != img2.length) {
throw new FormatException('Cannot compare images of differing sizes.');
}
/// A push based XmlReader interface, intended to be similar to .NET's XmlReader.
class XmlTextReader {
/// Creates a new reader for `input`.
///
/// Setting `ignoreWhitespace` to false will cause text nodes
XmlTextReader(String input, {this.ignoreWhitespace = true}) {
_result = Success(input, 0, null);
_depth = 0;
_eof = false;
}
@dnfield
dnfield / rect_largest.dart
Created August 27, 2018 21:26
Rect.largest bug android
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
@dnfield
dnfield / to_string_null.dart
Created August 30, 2018 17:13
Interpolate issue
class Foo {
String toString() {
return null;
}
}
void main() {
var foo = new Foo();
print('$foo'); // throws ArgumentException
}
@dnfield
dnfield / example.dart
Last active September 13, 2018 20:46
Get `PictureInfo` from SVG
import 'dart:ui' show Picture;
import 'package:flutter_svg/svg.dart';
...
PictureInfo info = svg.svgPictureStringDecoder(
'<svg />',
false, // don't allow drawing outside of the viewbox
null, // don't apply any ColorFilter
// import 'package:bottom_sheet/viewport_scroll_controller.dart';
import 'package:flutter/material.dart';
import 'bottom_material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
@dnfield
dnfield / main.dart
Created February 11, 2019 00:28
Wrapper for flutter test
import 'dart:convert';
import 'dart:io';
import 'package:meta/meta.dart';
final Stopwatch _stopwatch = Stopwatch();
final bool useColor = stdout.supportsAnsiEscapes;
/// The terminal escape for green text, or the empty string if this is Windows
/// or not outputting to a terminal.
import 'dart:ui';
import 'package:flutter/widgets.dart';
SizedBox box;
class Lottie extends AnimatedWidget {
const Lottie({
Key key,
@required this.lottieAnimation,