B
B
beduin012019-05-06 16:36:02
Dart
beduin01, 2019-05-06 16:36:02

Where are callable classes useful?

Who can explain in what situations callable-classes are useful ? Why is this better than calling methods?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
KnightForce, 2020-01-22
@KnightForce

You write a class.
It has a lot of internal logic, mb parsers.
It can contain streams, etc.
Normal reference to an instance is like a class.
But if you need to call it as a function, this is where it comes in handy.
A very contrived example:

class Counter {
    int _count = 0;
    call() => _count++;
}
var counter = Counter();
Button(onTap: counter)

You can get by with the method.
This is necessary for the convenience of solving problems, like almost everything in any programming language.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question