removeLastElement method
Removes the last element in the list and returns a new list.
Example:
Iterable<int>? numbers = [1, 2, 3];
List<int> result = numbers.removeLastElement(); // [1, 2]
Implementation
List<T> removeLastElement() {
List<T> list = [];
if (isNullOrEmpty) return list;
var thisList = this!.toList();
return thisList..removeAt(thisList.length - 1);
}