1
0
mirror of https://github.com/git-touch/git-touch synced 2024-12-22 13:25:13 +01:00
git-touch-android-ios-app/lib/utils/extensions.dart

22 lines
641 B
Dart
Raw Normal View History

2020-01-31 07:31:24 +01:00
import 'dart:convert';
2020-01-31 07:54:46 +01:00
import 'package:path/path.dart' as p;
2019-12-12 14:06:12 +01:00
2020-01-31 07:31:24 +01:00
extension MyString<T extends String> on String {
int get toInt => int.parse(this);
String get urlencode => Uri.encodeComponent(this);
String get urldecode => Uri.decodeComponent(this);
String get dropLineBreak => this.replaceAll('\n', '');
String get base64ToUtf8 => utf8.decode(base64.decode(this));
2020-01-31 07:54:46 +01:00
/// Get extension by file name/path, returns `null` instead of empty string
///
/// 1.dart -> 'dart'
///
/// license -> null
String get ext {
final dotext = p.extension(this);
if (dotext.isEmpty) return null;
return dotext.substring(1);
}
2019-12-12 14:06:12 +01:00
}