Skip to content

Instantly share code, notes, and snippets.

@escamoteur
escamoteur / proposal.md
Last active Jan 12, 2021
language proposal
View proposal.md

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;
View antenna.dart
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 Dec 16, 2020
instrumented changenotifier
View changenotifier.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:io';
import 'package:meta/meta.dart';
import 'assertions.dart';
@escamoteur
escamoteur / change_notifier_manual.dart
Last active Nov 16, 2020
change_notifier_manual.dart
View 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 Oct 5, 2020
VS code settings
View settings.json
{
"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 Sep 21, 2020
Proposal for a new mixin that allows to connect Objects inside GetIt to connect to the UI
View get_it_mixin.md

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 Sep 9, 2020
type problem in lists
View main.dart
import 'dart:async';
class A<T>{
A(this.val,this.dispose);
T val;
FutureOr Function(T) dispose;
}
List<A> allA = <A>[];
View fsharp_imap_scanner.fs
open System
open MailKit.Net.Imap
open MailKit
open MimeKit
type FolderInfo = {
name : string
size : uint64
}
View currying.fs
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()
View Layout-Resize-Problem.dart
// return Column(
// mainAxisSize: MainAxisSize.min,
// children: <Widget>[
// Container(
// height: 50.0,
// color: Colors.red,
// ),
// Row(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: <Widget>[