개발/Flutter
typedef 에서 generic function 사용하기
dev_caleb
2022. 12. 8. 09:45
728x90
typedef 는 callback 받을 때 도움이 되는 연산자? 같은 것이다.
Generic으로 받으면 여러가지 class를 넣지 않고 필요할 때 class 형태를 넣을 수 있을 것 같아서 자료를 찾아보았다.
https://stackoverflow.com/questions/51092028/how-to-typedef-a-generic-function
How to typedef a generic function?
I have a generic static method that looks like this: static build<K>() { return (GenericClass<K> param) => MyClass<K>(param); } So far I have tried: typedef F = MyClass&...
stackoverflow.com
typedef F<T> = T Function(T);
이걸 이런 식으로 바꿔봤다.
typedef OnClickItem<T> = T Function(T);
final OnClickItem<MatjipModel> onClickItem;
이런 식으로 쓰면 됨!,
728x90