safe_browsing

Creator: coderz1093

Last updated:

0 purchases

safe_browsing Image
safe_browsing Images
Add to Cart

Description:

safe browsing

Safe Browsing #
Using google safe browsing API to detect whether the URL is safe.
Required #
Make sure that you're enabled the SafeBrowsing API in your google cloud console:

STEP 1: Go to https://console.cloud.google.com/apis/library/safebrowsing.googleapis.com
STEP 2: Choose your current project
STEP 3: Press Enable

Usage #
This plugin requires you to use flutterfire_cli to create the DefaultFirebaseOptions for your project. Read more.
Create the instance #
/// Create the instance from the `DefaultFirebaseOptions`
/// This class is created by `flutterfire_cli`
final safeBrowsing = SafeBrowsing(
options: DefaultFirebaseOptions.currentPlatform,
isDebug: !kReleaseMode,
);

/// The URL you want to check
final url = 'https://example.com';

/// Check whether the URL is safe and return `SafeBrowsingState`
final state = await safeBrowsing.checkUrl(url);

/// Check whether the URL is safe and return `bool`
final isSafe = await safeBrowsing.isUrlSafe(url);
copied to clipboard
Result state of the checking #
state.isSafe // Means the result is safe
state.isNotSafe // Means the result is not safe. Different with `!state.isSafe`
state.isError // Means there is issue with the request
copied to clipboard
Please notice that the !state.isSafe is different from state.isNotSafe because the state.isError maybe occured.
More specific result by using state.type #
/// Safe
SafeBrowsingStateType.safe

/// Not safe. See `state.matches` for the details.
SafeBrowsingStateType.notSafe

/// Empty input
SafeBrowsingStateType.empty

/// Error with the request
SafeBrowsingStateType.requestError

/// Unknow error
SafeBrowsingStateType.unknown
copied to clipboard
Get the list of TheatMatchs when the state.isNotSafe #
final listThreatMatches = state.matches;
copied to clipboard
Advanced #
/// Check the entries
final state = safeBrowsing.check{
[ThreatEntry(url: 'url')],

threatTypes: [
ThreatType.MALWARE,
ThreatType.SOCIAL_ENGINEERING,
ThreatType.UNWANTED_SOFTWARE,
ThreatType.POTENTIALLY_HARMFUL_APPLICATION,
],

platformTypes: [
PlatformType.ALL_PLATFORMS,
],

threatEntryTypes: [
ThreatEntryType.URL,
],
}
copied to clipboard
Additional #
Use this method to validate the URL
SafeBrowsing.validateUrl(url);
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.

Related Products

More From This Creator