Skip to content

Instantly share code, notes, and snippets.

import 'package:flutter/material.dart';
/*This must be added to your MaterialApp`s navigatorObservers, like:
* navigatorObservers: [routeObserver]
*/
final routeObserver = RouteObserver<PageRoute>();
abstract class VisibilityAwareState<T extends StatefulWidget>
extends State<T> with WidgetsBindingObserver, RouteAware {
bool _isOnScreen = true;
#This Github Action builds the Dart 'bin' folder on every push commited to GitHub
name: Build on push
on: [push]
jobs:
build:
runs-on: ${{ matrix.os }}
@shinayser
shinayser / download_file.dart
Last active June 21, 2020 12:50 — forked from ajmaln/downloadFile.dart
Download file with progress in Dart/Flutter using 'http' package
import 'dart:async';
import 'dart:io';
import 'package:http/http.dart' as http;
///Returns the file as a stream of bytes
Future<Stream<List<int>>> downloadAsStream(String url) async {
var result = await Client().send(
Request(
"get",
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
const kAmountOfSentences = 8;
const kSentences = [
"Já defendeu o TCC?",
"Quantos artigos esse ano?",
"E as namoradinhas?",
@shinayser
shinayser / value_listenable_stream.dart
Created August 9, 2019 20:34
A function that converts a ValueListenable to a Stream
Stream<T> valueListenableToStreamAdapter<T>(ValueListenable<T> listenable) {
StreamController<T> controller;
void listener() {
controller.add(listenable.value);
}
void start() {
listenable.addListener(listener);
}
@shinayser
shinayser / servers_test.dart
Last active July 29, 2019 22:08
Just playing with Dart's server capabilities
import 'dart:async';
import 'dart:io';
import 'dart:isolate';
import 'package:http/http.dart' as http;
// ignore_for_file: unawaited_futures
void main([List<String> args]) {
// prefix0.main(["15900152"]);
_buildServers();
@shinayser
shinayser / isolate_compute.dart
Created July 29, 2019 22:00
Easy access to Isolate's computing function.
// Copyright 2015 The Chromium 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:async';
import 'dart:developer';
import 'dart:isolate';
import 'package:meta/meta.dart';
const bool kReleaseMode =