flutter_initials 1.0.3
flutter_initials: ^1.0.3 copied to clipboard
A lightweight Dart utility for extracting initials from a full name, designed for use in Flutter apps. Perfect for generating avatars, short representations of names, or tags.
Here's a clean and professional README.md file for your flutter_initials package:
# flutter_initials
A lightweight Dart utility for extracting initials from a full name, designed for use in Flutter apps. Perfect for generating avatars, short representations of names, or tags.
## Features
- Extracts the first letter of each word in a name
- Converts to uppercase
- Preserves numbers if found in words
- Trims special characters
- Limits output to 4 characters max
## Installation
Add the following to your `pubspec.yaml`:
```yaml
dependencies:
flutter_initials: ^1.0.3
```
Then run:
flutter pub get
Usage #
Import the package:
import 'package:flutter_initials/flutter_initials.dart';
Use the utility:
String initials = FlutterInitials.getInitials("John Doe" , 4);
print(initials); // Output: JD
Examples #
| Input | Output | Explanation |
|---|---|---|
"John Doe" |
JD |
First letters of first and last name |
"Mary-Kate Olsen" |
MK |
Hyphen removed, initials from both words |
"Élodie Yung" |
EY |
Special characters removed |
"Agent 47" |
A47 |
Numbers preserved |
"Albus Percival Wulfric Brian Dumbledore" |
APWB |
Max 4 initials |
" jack o'neill " |
JO |
Extra spaces and special characters cleaned |
Use Cases #
Use the utility:
String initials = FlutterInitials.toCamelCase("John Doe");
print(initials); // Output: johnDoe
| Input | Output | Explanation |
|---|---|---|
"John Doe" |
johnDoe |
Camel case |
"Mary-Kate Olsen" |
maryKateOlsen |
Camel case, hyphen removed |
"Mary-Kate Olsen" |
MaryKateOlsen |
Pascal case, hyphen removed |
"Mary-Kate Olsen" |
mary_kate_olsen |
Snake case, hyphen removed |
Contributing #
Feel free to open issues or submit pull requests for improvements or new features.
License #
---
Let me know if you'd like help publishing to pub.dev or adding additional badges (e.g. build status, version, likes).