mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-16 13:23:41 +00:00
feat: Implemented History Panel for reusing previously used Magnet & Torrent Links (#245)
This commit is contained in:
1 parent
39202b44a1
commit
32e3620f5e
6 files changed
+594
-376
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class HistoryController {
|
||||
// Get History in List<String>
|
||||
Future<List<String>> getAllHistory() async {
|
||||
SharedPreferences preferences = await SharedPreferences.getInstance();
|
||||
List<String>? historyList = preferences.getStringList('history');
|
||||
if(historyList == null) {
|
||||
return [];
|
||||
}
|
||||
return historyList;
|
||||
}
|
||||
|
||||
// Get Existing History & Add New History
|
||||
void addHistory(String historyText) async {
|
||||
SharedPreferences preferences = await SharedPreferences.getInstance();
|
||||
List<String> existingHistoryData = await getAllHistory();
|
||||
existingHistoryData.add(historyText);
|
||||
preferences.setStringList('history', existingHistoryData);
|
||||
}
|
||||
|
||||
void clearHistory() async {
|
||||
SharedPreferences preferences = await SharedPreferences.getInstance();
|
||||
preferences.remove('history');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user