Skip to content

Instantly share code, notes, and snippets.

Antti Ahti apaatsio

Block or report user

Report or block apaatsio

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
apaatsio / main.dart
Last active May 18, 2019
Flutter: Simple counter using ChangeNotifierProvider
View main.dart
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class Counter extends ChangeNotifier {
Counter(int initialValue) : _value = initialValue;
int _value;
set value(int newValue) {
_value = newValue;
apaatsio / build_mode.dart
Created Mar 19, 2019
Helper utility to detect build mode (debug, profile, and release) in a Flutter app.
View build_mode.dart
abstract class BuildMode {
static final BuildModeType buildMode = () {
if (const bool.fromEnvironment('dart.vm.product')) {
return BuildModeType.release;
var result = BuildModeType.profile;
assert(() {
result = BuildModeType.debug;
return true;
apaatsio /
Created Mar 16, 2019
How to debug Crashlytics on Flutter
adb shell setprop log.tag.Fabric DEBUG
adb shell setprop log.tag.CrashlyticsCore DEBUG
adb logcat -s flutter Fabric CrashlyticsCore FirebaseApp libcrashlytics FlutterCrashlytics
apaatsio /
Created Mar 4, 2019
Change any git commit date
# STEP 1
# To change non-root commit
git rebase -i f154548^
# Alternatively, to change the root commit
git rebase -i --root
# STEP 2
# edit the commit you want to change by changing the line
pick f154548 This is a commit message
apaatsio /
Last active Feb 23, 2019
Project size evaluator for Flutter Create contest 2019. More info:
# Project size evaluator for Flutter Create contest 2019.
# More info:
SIZE=`find . -name "*.dart" | xargs cat | wc -c`
if [ $SIZE -gt $MAX_SIZE ];
View flutter_doctor.log
[✓] Flutter (Channel master, v0.10.2-pre.25, on Linux, locale en_US.UTF-8)
• Flutter version 0.10.2-pre.25 at /home/antti/tools/flutter
• Framework revision 0edbe726a1 (3 hours ago), 2018-10-22 10:29:00 -0700
• Engine revision 58cdd53f90
• Dart version 2.1.0-dev.7.1.flutter-b99bcfd309
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
• Android SDK at /home/antti/Android/Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
apaatsio / coverage.dart
Last active Oct 1, 2018
Calculate total test coverage from file generated by `flutter test --coverage`
View coverage.dart
// NOTE: The preferred way is to install lcov and use command `lcov --summary path/to/`
// Use this script only if you can't install lcov on your platform.
// Usage: dart coverage.dart path/to/
import 'dart:io';
void main(List<String> args) async {
final lcovFile = args[0];
final lines = await File(lcovFile).readAsLines();
apaatsio / assert.dart
Last active Oct 1, 2018
lcov report shows coverage only for some asserts in Flutter 0.8.2;
View assert.dart
void successfulAsserts(int x) {
assert(x != null);
assert(x == 1);
int foo = 1;
assert(foo == 1);
void failingAssert() {
View clone-config.json
"sourceSpace": "XXX",
"destinationSpace": "YYY",
"sourceDeliveryToken": "AAA",
"managementToken": "ZZZ",
"syncTokenDir": "/tmp/contentful-sync",
"rateLimit": 1,
"rateLimitPeriod": 5000
apaatsio / kitten_in_console.js
Created Oct 31, 2016
JavaScript snippet to show random kitten image in console
View kitten_in_console.js
(function(url) {
// Create a new `Image` instance
var image = new Image();
image.onload = function() {
// Inside here we already have the dimensions of the loaded image
var style = [
// Hacky way of forcing image's viewport using `font-size` and `line-height`
'font-size: 1px;',
'line-height: ' + this.height + 'px;',
You can’t perform that action at this time.