'How to simulate slow/no network for Dart/Flutter's WebSocket, HttpClient and Socket?
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!
Solution 1:[1]
One way would be to setup a virtual machine like the Android Emulator which has this built-in. Otherwise depending on which platform you're doing your development you could use tools that simulate slow/no network (example for Windows).
Chrome also offer this if you open the developer tools (Ctrl-Shift-I).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ajaysinghdav10d |
