emulateNetworkConditionsByRule method

Future<List<String>> emulateNetworkConditionsByRule(
  1. bool offline,
  2. List<NetworkConditions> matchedNetworkConditions
)

Activates emulation of network conditions for individual requests using URL match patterns. Unlike the deprecated Network.emulateNetworkConditions this method does not affect navigator state. Use Network.overrideNetworkState to explicitly modify navigator behavior. offline True to emulate internet disconnection. matchedNetworkConditions Configure conditions for matching requests. If multiple entries match a request, the first entry wins. Global conditions can be configured by leaving the urlPattern for the conditions empty. These global conditions are also applied for throttling of p2p connections. Returns: An id for each entry in matchedNetworkConditions. The id will be included in the requestWillBeSentExtraInfo for requests affected by a rule.

Implementation

Future<List<String>> emulateNetworkConditionsByRule(
  bool offline,
  List<NetworkConditions> matchedNetworkConditions,
) async {
  var result = await _client.send('Network.emulateNetworkConditionsByRule', {
    'offline': offline,
    'matchedNetworkConditions': [...matchedNetworkConditions],
  });
  return (result['ruleIds'] as List).map((e) => e as String).toList();
}