You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
928 B
Dart
33 lines
928 B
Dart
import 'dart:io';
|
|
|
|
class ReadData {
|
|
static Future<List<String>> readFileString(String classString) async {
|
|
var fileName = 'lib/model/' + classString.toLowerCase() + '.data';
|
|
var file = File(fileName);
|
|
var contents = <String>[];
|
|
|
|
print('open file "$fileName"');
|
|
if (await file.exists()) {
|
|
contents = await File(fileName).readAsLines();
|
|
} else {
|
|
print('File "$fileName" not found.');
|
|
}
|
|
return contents;
|
|
}
|
|
|
|
static Future<List<num>> readFileNum(String classString) async {
|
|
var fileName = 'lib/model/' + classString.toLowerCase() + '.data';
|
|
var file = File(fileName);
|
|
var contents = <num>[];
|
|
|
|
print('open file "$fileName"');
|
|
if (await file.exists()) {
|
|
var contentStrings = await File(fileName).readAsLines();
|
|
contents = contentStrings.map(num.parse).toList();
|
|
} else {
|
|
print('File "$fileName" not found.');
|
|
}
|
|
return contents;
|
|
}
|
|
}
|