You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- import 'package:flutter/material.dart';
-
- class Helpers {
- static void hideKeyboard(BuildContext context) {
- var currentFocus = FocusScope.of(context);
- if (!currentFocus.hasPrimaryFocus) {
- currentFocus.unfocus();
- }
- }
-
- static String getLetterInitial(String name) {
- try {
- var wordList = name.trim().split(' ');
- var letters = '';
- if (wordList.isEmpty) {
- letters = '';
- } else if (wordList.length == 1) {
- var firstWord = wordList[0];
- if (firstWord.characters.length > 1) {
- letters = wordList[0][0] + wordList[0][1];
- } else {
- letters = wordList[0][0];
- }
- } else {
- letters = wordList[0][0] + wordList[wordList.length - 1][0];
- }
- return letters.toUpperCase();
- } catch (_) {
- return '';
- }
- }
- }
|