Skip to content

Instantly share code, notes, and snippets.

@escamoteur
escamoteur / proposal.md
Last active January 12, 2021 11:56
language proposal

Enable functions to store data between calls / know from where they were called

Hi, this title might sound quite strange but during the development of functional_listeners and get_it_mixin I found that the reactive nature of flutter creates some new challenges. Specifically I mean that build functions are getting called on any data change which makes patterns that I used in the past suddenly difficult. Let's take the following class as an example:

class Model {
  ValueNotifier<String> _notifier;
@escamoteur
escamoteur / antenna.dart
Created December 24, 2020 08:40
AntennaWidget
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:vector_math/vector_math_64.dart' show radians;
/// Used to display Antennas on the Map as well as
/// the compass in aiming mode
class AntennaWidget extends StatelessWidget {
const AntennaWidget({
Key key,
@escamoteur
escamoteur / changenotifier.dart
Created December 16, 2020 17:55
instrumented changenotifier
// 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:io';
import 'package:meta/meta.dart';
import 'assertions.dart';
@escamoteur
escamoteur / change_notifier_manual.dart
Last active November 16, 2020 22:58
change_notifier_manual.dart
// 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:collection';
import 'dart:developer';
import 'package:meta/meta.dart';
import 'assertions.dart';
@escamoteur
escamoteur / settings.json
Last active October 5, 2020 11:26
VS code settings
{
"breadcrumbs.enabled": true,
"editor.fontLigatures": true,
"editor.fontFamily": "Dank Mono",
"editor.fontSize": 18,
"workbench.iconTheme": "eq-material-theme-icons",
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": [
@escamoteur
escamoteur / get_it_mixin.md
Last active September 21, 2020 22:15
Proposal for a new mixin that allows to connect Objects inside GetIt to connect to the UI

Proposal for the coming get_it mixin for Widgets as I was asked by users to help binding the UI to the objects in GetIt. Highly inspired by @remi_rousselet 's Hooks and provider in this aspect. For people using Hooks I plan a similar GetItHook. Please tell me what you think

  /// all the following functions can be called inside the build function but also
  /// in e.g. in `initState` of a `StatefulWidget`.
  /// The mixin takes care that everything is correctly disposed.

  /// retrieves or creates an instance of a registered type [T] depending on the registration
@escamoteur
escamoteur / main.dart
Created September 9, 2020 11:28
type problem in lists
import 'dart:async';
class A<T>{
A(this.val,this.dispose);
T val;
FutureOr Function(T) dispose;
}
List<A> allA = <A>[];
open System
open MailKit.Net.Imap
open MailKit
open MimeKit
type FolderInfo = {
name : string
size : uint64
}
let withdrawWithAudit = withdraw |> auditAs "withdraw" Auditing.fileSystem
let depositWithAudit = deposit |> auditAs "deposit" Auditing.fileSystem
while true do
let action =
Console.WriteLine()
printfn "Current balance is £%M" account.Balance
Console.Write "(d)eposit, (w)ithdraw or e(x)it: "
Console.ReadLine()
// return Column(
// mainAxisSize: MainAxisSize.min,
// children: <Widget>[
// Container(
// height: 50.0,
// color: Colors.red,
// ),
// Row(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: <Widget>[