mirror of
https://github.com/PranshulGG/WeatherMaster.git
synced 2026-10-21 18:43:03 -05:00
21 lines
472 B
Dart
21 lines
472 B
Dart
import 'dart:convert';
|
|
import 'package:hive/hive.dart';
|
|
|
|
class WeatherCacheRenderer {
|
|
static const String _boxName = 'weatherMasterCache';
|
|
|
|
static Future<Map<String, dynamic>?> renderData(String locationName) async {
|
|
if (!Hive.isBoxOpen(_boxName)) {
|
|
await Hive.openBox(_boxName);
|
|
}
|
|
|
|
final box = Hive.box(_boxName);
|
|
final jsonStr = box.get(locationName);
|
|
|
|
if (jsonStr != null) {
|
|
return json.decode(jsonStr);
|
|
}
|
|
return null;
|
|
}
|
|
}
|