Skip to content

Commit

Permalink
feat: add send to clip board string extension
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandrogiubel committed Feb 5, 2024
1 parent 7a49eec commit acf024e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 1.1.0
* Add sendToClipBoard on String extension

* Breaking change
- inCapFirst => capFirst
- inCapsAll => capAll
- capitalizeFirstOfEach => capFirstOfEach

## 1.0.0

* Add expanded and flexible
Expand Down
14 changes: 10 additions & 4 deletions lib/extensions/string_extension.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import 'dart:developer' as dev;

import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';

extension StringExtension on String {
///Capitalize first letter
String get inCapFirst =>
String get capFirst =>
isNotEmpty ? '${this[0].toUpperCase()}${substring(1)}' : '';

///Capitalize all letters
String get allInCaps => toUpperCase();
String get capAll => toUpperCase();

///Capitalize first letter of each word
String get capitalizeFirstOfEach =>
split(' ').map<dynamic>((str) => str.inCapFirst).join(' ');
String get capFirstOfEach =>
split(' ').map<dynamic>((str) => str.capFirst).join(' ');

///True if is a valid email
bool get isEmail => RegExp(
Expand All @@ -35,4 +36,9 @@ extension StringExtension on String {
}
return this;
}

/// Copies the string to the clipboard.
Future<void> get sendToClipBoard async {
await Clipboard.setData(ClipboardData(text: this));
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: power_ups
description: Different utilities to power ups your development.
version: 1.0.0
version: 1.1.0
repository: https://github.com/alejandrogiubel/power_ups
homepage: https://github.com/alejandrogiubel/power_ups

Expand Down

0 comments on commit acf024e

Please sign in to comment.