emulateNetworkConditionsByRule method
- List<
NetworkConditions> matchedNetworkConditions, { - @Deprecated('use the offline property in matchedNetworkConditions\nor emulateOfflineServiceWorker instead.') bool? offline,
- bool? emulateOfflineServiceWorker,
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.
emulateOfflineServiceWorker True to emulate offline service worker.
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(
List<NetworkConditions> matchedNetworkConditions, {
@Deprecated(
'use the offline property in matchedNetworkConditions\nor emulateOfflineServiceWorker instead.',
)
bool? offline,
bool? emulateOfflineServiceWorker,
}) async {
var result = await _client.send('Network.emulateNetworkConditionsByRule', {
'matchedNetworkConditions': [...matchedNetworkConditions],
if (offline != null) 'offline': offline,
if (emulateOfflineServiceWorker != null)
'emulateOfflineServiceWorker': emulateOfflineServiceWorker,
});
return (result['ruleIds'] as List).map((e) => e as String).toList();
}