Skip to content

Commit ab119b8

Browse files
feat: introduce comprehensive network information features in NetworkInfoHelper, including WiFi details, connectivity checks, and Cloudflare trace integration; enhance MasterApp with new network initialization options and update documentation for version 0.0.15
1 parent a436c01 commit ab119b8

File tree

3 files changed

+165
-6
lines changed

3 files changed

+165
-6
lines changed

CHANGELOG.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,82 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.0.15] - 2026-02-09
9+
10+
### Added
11+
12+
#### NetworkInfoHelper - Comprehensive Network Information
13+
- **NetworkInfoHelper** - Singleton helper for WiFi, connectivity, public IP, DNS, reachability, speed, and interface information
14+
- WiFi details via `network_info_plus`: `getWifiName()`, `getWifiBSSID()`, `getWifiIP()`, `getWifiIPv6()`, `getWifiSubmask()`, `getWifiBroadcast()`, `getWifiGatewayIP()`, `getAllWifiInfo()`
15+
- Connectivity via `connectivity_plus`: `getConnectionType()`, `isConnected()`, `isWifi()`, `isMobile()`, `onConnectivityChanged` stream
16+
- Public IP via ipify API: `getPublicIP()`
17+
- DNS lookup via `dart:io`: `dnsLookup(host)`
18+
- Host reachability via TCP socket: `isHostReachable(host)`
19+
- Download speed estimation: `estimateDownloadSpeed()`
20+
- Network interface listing: `getNetworkInterfaces()`
21+
- Platform-safe: all methods return safe defaults on web
22+
- **Models**: `WifiInfo`, `NetworkConnectionType`, `ReachabilityResult`, `NetworkSpeedResult`, `NetworkInterfaceInfo`
23+
24+
#### Cloudflare Trace Integration
25+
- **CloudflareTraceInfo** model - Parsed response from `https://cloudflare.com/cdn-cgi/trace`
26+
- Fields: `ip`, `loc` (country code), `colo` (datacenter), `tls`, `http`, `warp`, `gateway`, `visitScheme`, `uag`, `fl`, `sni`, `kex`, `ts`
27+
- Factory constructor `CloudflareTraceInfo.fromMap()` for key=value parsing
28+
- Full `raw` map for any additional fields
29+
- **`getCloudflareTrace()`** method on `NetworkInfoHelper` - Fetches and parses Cloudflare trace endpoint
30+
31+
#### NetworkInitFeature Enum
32+
- **NetworkInitFeature** - Enum for controlling which network features run during `MasterApp.runBefore()`
33+
- `cloudflareTrace` - Fetch IP, location, datacenter via Cloudflare trace (stores `osmea_cf_ip`, `osmea_cf_location`, `osmea_cf_colo`, `osmea_cf_tls`, `osmea_cf_http`, `osmea_cf_warp`)
34+
- `publicIP` - Fetch public IP via ipify (stores `osmea_public_ip`)
35+
- `connectivity` - Check connectivity status (stores `osmea_connection_type`, `osmea_is_connected`)
36+
- `wifiInfo` - Gather WiFi details (stores `osmea_wifi_name`, `osmea_wifi_ip`, `osmea_wifi_gateway`)
37+
38+
#### MasterApp.runBefore Enhancement
39+
- **`networkFeatures` parameter** - Added `Set<NetworkInitFeature>` to `MasterApp.runBefore()`
40+
- Defaults to empty set (backward compatible)
41+
- Each feature fetches data and persists to `LocalStorageHelper`
42+
- Formatted debug console output for each feature
43+
44+
### Changed
45+
46+
#### Example App - Network Info View Redesign
47+
- Redesigned Network Info view with clean white-based, soft UI
48+
- MasterViewCubit super constructor with all spacers/padding disabled for full layout control
49+
- New Cloudflare Trace section at the top showing IP, Location, Datacenter, TLS, HTTP, WARP
50+
- Public IP and Cloudflare Trace now auto-fetched (no manual button)
51+
- All data fetched in parallel via `Future.wait` for faster loading
52+
- Section headers use uppercase labels with muted Lucide icons
53+
- All colors from `ThemeCubit` via `ThemeHelper` extension (configurable from Settings)
54+
- Connected/Reachable values use color-coded success/error indicators
55+
56+
### Dependencies
57+
- Added `network_info_plus: ^7.0.0` for WiFi information
58+
- Added `connectivity_plus: ^6.1.4` for connectivity status
59+
60+
### Usage Example
61+
```dart
62+
// In main.dart - enable network features at startup
63+
await MasterApp.runBefore(
64+
assetConfigPath: 'assets/app_config.json',
65+
hydrated: true,
66+
requestTrackingTransparency: true,
67+
networkFeatures: {
68+
NetworkInitFeature.cloudflareTrace,
69+
NetworkInitFeature.connectivity,
70+
},
71+
);
72+
73+
// Or use NetworkInfoHelper directly
74+
final trace = await NetworkInfoHelper.instance.getCloudflareTrace();
75+
print('IP: ${trace?.ip}, Location: ${trace?.loc}');
76+
77+
final wifi = await NetworkInfoHelper.instance.getAllWifiInfo();
78+
final connected = await NetworkInfoHelper.instance.isConnected();
79+
final publicIP = await NetworkInfoHelper.instance.getPublicIP();
80+
```
81+
82+
[0.0.15]: https://github.com/gurkanfikretgunak/masterfabric_core/releases/tag/v0.0.15
83+
884
## [0.0.14] - 2026-02-07
985

1086
### Added

README.md

Lines changed: 88 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,21 @@ A comprehensive Flutter package providing core utilities, base classes, and shar
7878
- Check current tracking status without prompting
7979
- Platform-safe: automatically returns `true` on non-iOS platforms
8080
- Integrated into `MasterApp.runBefore()` for easy initialization
81+
- **NetworkInfoHelper**: Comprehensive network information helper
82+
- WiFi details: SSID, BSSID, IP, IPv6, submask, broadcast, gateway via `network_info_plus`
83+
- Connectivity: connection type, connected status, WiFi/mobile checks via `connectivity_plus`
84+
- Cloudflare Trace: public IP, country location, datacenter, TLS, HTTP, WARP via `cloudflare.com/cdn-cgi/trace`
85+
- Public IP lookup via ipify API
86+
- DNS resolution via `dart:io`
87+
- Host reachability check via TCP socket
88+
- Download speed estimation
89+
- Network interface listing
90+
- Platform-safe: all methods return safe defaults on web
91+
- **NetworkInitFeature**: Enum-based network initialization for `MasterApp.runBefore()`
92+
- `cloudflareTrace` - IP, location, datacenter persisted to local storage
93+
- `publicIP` - External IP persisted to local storage
94+
- `connectivity` - Connection type and status persisted to local storage
95+
- `wifiInfo` - WiFi details persisted to local storage
8196

8297
### 📐 Layout System
8398
- **Grid**: Responsive grid layout system
@@ -99,7 +114,7 @@ Add this to your package's `pubspec.yaml` file:
99114

100115
```yaml
101116
dependencies:
102-
masterfabric_core: ^0.0.14
117+
masterfabric_core: ^0.0.15
103118
```
104119
105120
Then run:
@@ -143,6 +158,10 @@ void main() async {
143158
assetConfigPath: 'assets/app_config.json',
144159
hydrated: true, // Enable state persistence
145160
requestTrackingTransparency: true, // Request iOS ATT authorization (iOS 14+)
161+
networkFeatures: {
162+
NetworkInitFeature.cloudflareTrace, // IP, location, datacenter
163+
NetworkInitFeature.connectivity, // WiFi/mobile/none status
164+
},
146165
);
147166
148167
// Create your router
@@ -277,7 +296,35 @@ The authorization result is automatically stored in `LocalStorageHelper` as `osm
277296

278297
**Note**: The ATT dialog only appears on real iOS devices (iOS 14+). On simulators, it will return `false` by default. On Android and other platforms, the helper automatically returns `true` since ATT is iOS-only.
279298

280-
### 4c. Configure Force Update
299+
### 4c. Network Features at Startup
300+
301+
Use `NetworkInitFeature` enum to pre-fetch and persist network data during initialization:
302+
303+
```dart
304+
await MasterApp.runBefore(
305+
assetConfigPath: 'assets/app_config.json',
306+
hydrated: true,
307+
networkFeatures: {
308+
NetworkInitFeature.cloudflareTrace, // IP, location, datacenter via Cloudflare
309+
NetworkInitFeature.publicIP, // External IP via ipify
310+
NetworkInitFeature.connectivity, // WiFi/mobile/none status
311+
NetworkInitFeature.wifiInfo, // WiFi SSID, IP, gateway
312+
},
313+
);
314+
```
315+
316+
Each feature stores its result in `LocalStorageHelper` with `osmea_` prefix keys:
317+
318+
| Feature | Storage Keys |
319+
|---------|-------------|
320+
| `cloudflareTrace` | `osmea_cf_ip`, `osmea_cf_location`, `osmea_cf_colo`, `osmea_cf_tls`, `osmea_cf_http`, `osmea_cf_warp` |
321+
| `publicIP` | `osmea_public_ip` |
322+
| `connectivity` | `osmea_connection_type`, `osmea_is_connected` |
323+
| `wifiInfo` | `osmea_wifi_name`, `osmea_wifi_ip`, `osmea_wifi_gateway` |
324+
325+
**Note**: Network features are platform-safe. On web, methods return safe defaults. WiFi details require platform permissions on some devices.
326+
327+
### 4d. Configure Force Update
281328

282329
Force update configuration in `app_config.json`:
283330

@@ -403,6 +450,40 @@ final TrackingStatus status = await AppTrackingTransparencyHelper.instance
403450
404451
// Result is automatically stored in LocalStorageHelper when used via MasterApp.runBefore()
405452
final storedResult = await LocalStorageHelper.getItem('osmea_tracking_authorized');
453+
454+
// Network Info Helper
455+
// Cloudflare Trace (IP, location, datacenter, TLS)
456+
final trace = await NetworkInfoHelper.instance.getCloudflareTrace();
457+
print('IP: ${trace?.ip}, Country: ${trace?.loc}, DC: ${trace?.colo}');
458+
459+
// WiFi information
460+
final wifi = await NetworkInfoHelper.instance.getAllWifiInfo();
461+
print('WiFi: ${wifi.wifiName}, IP: ${wifi.wifiIP}');
462+
463+
// Connectivity
464+
final connected = await NetworkInfoHelper.instance.isConnected();
465+
final type = await NetworkInfoHelper.instance.getConnectionType();
466+
467+
// Public IP
468+
final publicIP = await NetworkInfoHelper.instance.getPublicIP();
469+
470+
// DNS Lookup
471+
final ips = await NetworkInfoHelper.instance.dnsLookup('google.com');
472+
473+
// Host Reachability
474+
final result = await NetworkInfoHelper.instance.isHostReachable('google.com');
475+
print('Reachable: ${result.isReachable}, Latency: ${result.latencyMs}ms');
476+
477+
// Download Speed Estimation
478+
final speed = await NetworkInfoHelper.instance.estimateDownloadSpeed();
479+
print('Speed: ${speed.downloadSpeedMbps.toStringAsFixed(2)} Mbps');
480+
481+
// Network Interfaces
482+
final interfaces = await NetworkInfoHelper.instance.getNetworkInterfaces();
483+
484+
// Network features are persisted to local storage when using MasterApp.runBefore()
485+
final cfIP = await LocalStorageHelper.getItem('osmea_cf_ip');
486+
final cfLocation = await LocalStorageHelper.getItem('osmea_cf_location');
406487
```
407488

408489
## Package Structure
@@ -415,7 +496,7 @@ lib/
415496
│ ├── base_view_*.dart # Base view classes
416497
│ ├── master_view/ # Master view system
417498
│ └── widgets/ # Base widgets
418-
├── helper/ # Utility helpers
499+
├── helper/ # Utility helpers (incl. NetworkInfoHelper, NetworkInitFeature)
419500
├── views/ # Pre-built views
420501
├── models/ # Data models
421502
├── layout/ # Layout utilities
@@ -442,6 +523,8 @@ ios/
442523
- `slang: ^4.11.1` - Localization
443524
- `hive_ce: ^2.16.0` - High-performance NoSQL database (optional storage backend)
444525
- `flutter_svg: ^2.2.3` - SVG rendering support
526+
- `network_info_plus: ^7.0.0` - WiFi network information
527+
- `connectivity_plus: ^6.1.4` - Network connectivity status
445528

446529
### See `pubspec.yaml` for complete dependency list
447530

@@ -455,7 +538,7 @@ For detailed documentation, see:
455538

456539
- **Pub.dev**: [https://pub.dev/packages/masterfabric_core](https://pub.dev/packages/masterfabric_core)
457540
- **GitHub**: [https://github.com/gurkanfikretgunak/masterfabric_core](https://github.com/gurkanfikretgunak/masterfabric_core)
458-
- **Version**: 0.0.14
541+
- **Version**: 0.0.15
459542
- **License**: AGPL-3.0
460543

461544
## Contributing
@@ -486,7 +569,7 @@ Or add it manually to your `pubspec.yaml`:
486569

487570
```yaml
488571
dependencies:
489-
masterfabric_core: ^0.0.14
572+
masterfabric_core: ^0.0.15
490573
```
491574
492575
---

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: masterfabric_core
22
description: "Core utilities, base classes, and shared logic for the MasterFabric Flutter project."
3-
version: 0.0.14
3+
version: 0.0.15
44
homepage: https://github.com/gurkanfikretgunak/masterfabric_core
55
repository: https://github.com/gurkanfikretgunak/masterfabric_core
66

0 commit comments

Comments
 (0)