ip2region_plus

Last updated:

0 purchases

ip2region_plus Image
ip2region_plus Images
Add to Cart

Description:

ip2region plus

Ip2region_plus #
ip2region_plus - is a dart language implementation. It can be used in dart or flutter。
ip2region - is a offline IP address location library and IP location data management framework, 10 microsecond level query efficiency, provides a variety of mainstream programming language xdb data generation and query client implementation. Other language versions please see lionsoul2014/ip2region
English | 中文
Install #
This extension does not provide ip2region.xdb file, please download it from ip2region.xdb here. How to update also refer to this library readme.
Useage #
File-based querying #
import 'package:ip2region_plus/ip2region_plus.dart';

void main() {
String dbFile = "ip2region.xdb";
IP2RegionPlus searcher;
try {
searcher = IP2RegionPlus.newWithFileOnly(dbFile);
Map region = searcher.search('8.8.8.8');
print(region);
} catch (e) {
print("failed to create searcher with '$dbFile': $e");
return;
}
}
copied to clipboard
Cache VectorIndex index #
import 'package:ip2region_plus/ip2region_plus.dart';

void main() {
String dbFile = "ip2region.xdb";
IP2RegionPlus searcher;
try {
var vIndex = IP2RegionPlus.loadVectorIndexFromFile(dbFile);
searcher = IP2RegionPlus.newWithVectorIndex(dbFile, vIndex);
Map region = searcher.search('8.8.8.132');
print(region);
} catch (e) {
print("failed to create searcher with '$dbFile': $e");
return;
}
}

copied to clipboard
Cache the entire xdb data #
import 'package:ip2region_plus/ip2region_plus.dart';

void main() {
String dbFile = "ip2region.xdb";
IP2RegionPlus searcher;
var cBuff = IP2RegionPlus.loadContentFromFile(dbFile);
if (cBuff == null) {
print("failed to load content buffer from $dbFile");
return;
}
try {
searcher = IP2RegionPlus.newWithBuffer(cBuff);
Map region = searcher.search('8.8.8.132');
print(region);
} catch (e) {
print(e);
return;
}
}
copied to clipboard
Example #
dart run example/main.dart
#{region: 美国|0|0|0|Level3, ioCount: 8, took: 2392}
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.