Csp constructor
Csp({
- List<
String> ? connectSrc, - List<
String> ? defaultSrc, - List<
String> ? fontSrc, - List<
String> ? frameAncestors, - List<
String> ? imgSrc, - List<
String> ? manifestSrc, - List<
String> ? mediaSrc, - List<
String> ? scriptSrc, - List<
String> ? styleSrc, - String? reportTo,
- String? reportUri,
- bool upgradeInsecureRequests = false,
Implementation
factory Csp({
List<String>? connectSrc,
List<String>? defaultSrc,
List<String>? fontSrc,
List<String>? frameAncestors,
List<String>? imgSrc,
List<String>? manifestSrc,
List<String>? mediaSrc,
List<String>? scriptSrc,
List<String>? styleSrc,
List<String>? navigateTo,
String? reportTo,
String? reportUri,
bool upgradeInsecureRequests = false,
}) {
final map = <String, List<String>>{};
if (connectSrc != null) {
map['connect-src'] = connectSrc;
}
if (defaultSrc != null) {
map['default-src'] = defaultSrc;
}
if (fontSrc != null) {
map['font-src'] = fontSrc;
}
if (imgSrc != null) {
map['img-src'] = imgSrc;
}
if (manifestSrc != null) {
map['manifest-src'] = manifestSrc;
}
if (mediaSrc != null) {
map['media-src'] = mediaSrc;
}
if (scriptSrc != null) {
map['script-src'] = scriptSrc;
}
if (styleSrc != null) {
map['style-src'] = styleSrc;
}
if (frameAncestors != null) {
map['frame-ancestors'] = frameAncestors;
}
if (navigateTo != null) {
map['navigate-to'] = navigateTo;
}
if (reportTo != null) {
map['report-to'] = [reportTo];
}
if (reportUri != null) {
map['report-uri'] = [reportUri];
}
if (upgradeInsecureRequests) {
map['upgrade-insecure-requests'] = [];
}
if (upgradeInsecureRequests) {
map['upgrade-insecure-requests'] = [];
}
return Csp.fromMap(map);
}