Skip to content

Instantly share code, notes, and snippets.

@escamoteur
Created September 9, 2020 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save escamoteur/5c48d5e267b48b7103d65639f931e337 to your computer and use it in GitHub Desktop.
Save escamoteur/5c48d5e267b48b7103d65639f931e337 to your computer and use it in GitHub Desktop.
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>[];
void main() {
var instance = A<int>(42,(_){print('disposed int');});
var instance2 = A<String>('42',(_){print('disposed string');});
allA.add(instance);
allA.add(instance2);
for(final a in allA){
a.dispose(a.val);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment