Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void uploadFile() async {
- submitButton.attributes.addAll({'disabled': ''});
- progress.value = 0;
- FileList files = input.files;
- if(files.isEmpty){
- _handleError("No file selected");
- //handle error, probably a banner
- return;
- }
- File file = files.item(0);
- FileReader reader = new FileReader();
- //reader.result
- reader.onLoadEnd.listen((e) async {
- Map map = json.decode(reader.result);
- var combinations = map['combinations'];
- progress.max = combinations.length;
- int loopCount = 0;
- combinations.forEach((e) async {
- await _service.create(VJCombination.fromJSON(e)).then((_) {
- combinationCount++;
- progress.value ++;
- loopCount++;
- if(loopCount == combinations.length){
- submitButton.attributes.remove('disabled');
- }
- });
- });
- isLoadSuccessful = true;
- });
- reader.onError.listen((evt) => print(evt));
- reader.readAsText(file);
- progress.value = 10;
- }
- @ViewChild('progress')
- ProgressElement progress;
- @ViewChild('submit')
- ButtonElement submitButton;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement