dart_std

Creator: coderz1093

Last updated:

Add to Cart

Description:

dart std

Introduction #
Installation #
Add the following to your pubspec.yaml:
dependencies:
dart_std: latest_version
copied to clipboard
After you import the library, you can use the extensions.
import 'package:dart_std/dart_std.dart';

2.toOrdinal(); // 2nd
copied to clipboard
Navigation #
import 'package:dart_std/dart_std.dart';

context.navigateTo(const SecondScreen);

// or

context.navigateToAndRemoveAll(const SecondScreen());

// or

context.navigateToNamed(const SecondScreen.routeName);

// or

context.navigateToNamedAndRemoveAll(const SecondScreen.routeName);

// or

context.navigatePop();

// or

context.navigatePopUntil(const SecondScreen.routeName);
copied to clipboard
Color #
"#00000".toColor(); // Color(0xFF00000)
copied to clipboard
Iterable #
.joinToString() #
Returns elements as String, can add prefix or suffix, separator. Similar to Kotlin joinToString()
final list = [0, 1, 2, 3, 4, 5];
list.joinToString(
String? separator,
String? prefix,
String? postfix,
int? limit,
String? truncated,
Function(D)? transform,
);
copied to clipboard
.toFlatten() #
Combine nested collections to single collections.
final nestedList = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
final flatList = nestedList.toFlatten(); // [1, 2, 3, 4, 5, 6, 7, 8, 9]
copied to clipboard
Number types (int, double, etc) #
toLikes() #
Return K to B, now no need to convert likes or number manually.
10000.toLikes() // 10K
98000.toLikes() // 9.8K
copied to clipboard
.toOrdinal() #
Returns an ordinal number of String type for any integer
2.ordinal(); // 2nd
452.ordinal(); // 452th
copied to clipboard
.plus() or plusOrNull() #
Returns addition of two number
2.plus(8); // 10
10.plusOrNull(20); // 30
copied to clipboard
.minus() or minusOrNull() #
Returns substraction of two number
8.minus(2); // 6
20.minusOrNull(10); // 10
copied to clipboard
.multiply() or multiplyOrNull() #
Returns multiplication of two number
8.multiply(2); // 16
20.multiplyOrNull(10); // 200
copied to clipboard
.divide() #
Returns division of two number
8.divide(2); // 4
20.divide(2.5) // 8
copied to clipboard
String #
.firstLetterCapitalize() #
Returns a copy of the string having its first letter uppercased, or the original string, if it's empty or already starts with an upper case letter.
'deb'.firstLetterCapitalize(); // Deb
'Deb'.firstLetterCapitalize(); // Deb
copied to clipboard
.firstLetterLowercase() #
Returns a copy of the string having its first letter lowercased, or the original string, if it's empty or already starts with a lower case letter.
'deb'.firstLetterLowercase(); // deb
'Deb'.firstLetterLowercase(); // deb
copied to clipboard
.prefix() #
Returns a string with prefix added
var value = 'eb'.prefix('D');
print(value); // Deb
copied to clipboard
.suffix() #
Returns a string with suffix added
var value = 'De'.suffix('b');
print(value); // Deb
copied to clipboard
.removePrefix(), .removeSuffix() and .removeSurrounding() #
Remove a prefix, a suffix, or both from a given string:
final name = 'James Bond'.removePrefix('James '); // Bond
final milliseconds = '100ms'.removeSuffix('ms'); // 100
final text = '<p>Some HTML</p>'
.removeSurrounding(prefix: '<p>', suffix: '</p>'); // Some HTML
copied to clipboard
.reversed #
Returns a new string with characters in reversed order.
final emptyString = ''.reversed; // ''
final reversed = 'abc🤔'.reversed; // '🤔cba'
copied to clipboard
License #
MIT License

Copyright (c) 2022 Debojyoti Singha

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.