Created
September 9, 2020 11:28
-
-
Save escamoteur/5c48d5e267b48b7103d65639f931e337 to your computer and use it in GitHub Desktop.
type problem in lists
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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