Skip to content

Commit

Permalink
Fixed array editing not working in text displays
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold872 committed Dec 21, 2023
1 parent e83d30c commit 96e81d2
Showing 1 changed file with 14 additions and 22 deletions.
36 changes: 14 additions & 22 deletions lib/widgets/nt_widgets/single_topic/text_display.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:convert';

import 'package:flutter/material.dart';

import 'package:dot_cast/dot_cast.dart';
Expand Down Expand Up @@ -83,34 +85,24 @@ class TextDisplay extends NTWidget {
break;
case NT4TypeStr.kFloat32Arr:
case NT4TypeStr.kFloat64Arr:
formattedData = List<double>.of(value
.substring(1)
.substring(value.length - 1)
.split(',')
.map((e) => double.tryParse(e.trim()) ?? 0.0));
formattedData = tryCast<List<dynamic>>(jsonDecode(value))
?.whereType<num>()
.toList();
break;
case NT4TypeStr.kIntArr:
formattedData = List<int>.of(value
.substring(1)
.substring(1)
.substring(value.length - 1)
.split(',')
.map((e) => int.tryParse(e.trim()) ?? 0));
formattedData = tryCast<List<dynamic>>(jsonDecode(value))
?.whereType<int>()
.toList();
break;
case NT4TypeStr.kBoolArr:
formattedData = List<bool>.of(value
.substring(1)
.substring(1)
.substring(value.length - 1)
.split(',')
.map((e) => bool.tryParse(e.trim()) ?? false));
formattedData = tryCast<List<dynamic>>(jsonDecode(value))
?.whereType<bool>()
.toList();
break;
case NT4TypeStr.kStringArr:
formattedData = List<String>.of(value
.substring(1)
.substring(value.length - 1)
.split(',')
.map((e) => e.replaceAll(']', '').trim()));
formattedData = tryCast<List<dynamic>>(jsonDecode(value))
?.whereType<String>()
.toList();
break;
default:
break;
Expand Down

0 comments on commit 96e81d2

Please sign in to comment.