I need to simulate slow/no network for Dart/Flutter's HttpClient and Socket. However, I cannot find any guides on the network.
My naive idea is as follows. We can create class SlowSocket implements Socket
, and use the delegate/decorator design pattern. For example, the SlowSocket.add
method will be implemented as Future.delayed(...).then(() => realSocket.add())
. I wonder whether this is ok? Or is there a simpler/better approach?
Thanks for any suggestions!