-
Notifications
You must be signed in to change notification settings - Fork 41
/
ldi.dart
28 lines (23 loc) · 845 Bytes
/
ldi.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// This source code is a part of Project Violet.
// Copyright (C) 2020-2024. violet-team. Licensed under the Apache-2.0 License.
import 'dart:convert';
import 'dart:io';
import 'package:flutter/services.dart';
import 'package:tuple/tuple.dart';
class LDI {
static List<Tuple2<int, double>>? ldi;
static Future<void> init() async {
String data;
if (Platform.environment.containsKey('FLUTTER_TEST')) {
var file = File('/home/ubuntu/violet/assets/rank/ldi.json');
data = await file.readAsString();
} else {
data = await rootBundle.loadString('assets/rank/ldi.json');
}
Map<String, dynamic> dataLdi = json.decode(data);
ldi = dataLdi.entries
.map((x) => Tuple2<int, double>(int.parse(x.key), x.value as double))
.toList();
ldi!.sort((x, y) => y.item2.compareTo(x.item2));
}
}