getPathAndRenameFile method

String? getPathAndRenameFile({
  1. String? newName,
})

Implementation

String? getPathAndRenameFile({String? newName}) {
  if (this == null) return null;
  final directoryPath = this!.substring(0, this!.lastIndexOf('/'));
  final extension = this!.split('.').last;

  if (newName != null) {
    return '$directoryPath/$newName.$extension';
  } else {
    return '$directoryPath/${DateTime.now().millisecondsSinceEpoch}.$extension';
  }
}