df_type 0.1.3 copy "df_type: ^0.1.3" to clipboard
df_type: ^0.1.3 copied to clipboard

A package designed to simplify and enhance interactions with Dart types.

example/example.dart

//.title
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
//
// Dart/Flutter (DF) Packages by DevCetra.com & contributors. See LICENSE file
// in root directory.
//
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
//.title~

// ignore_for_file: omit_local_variable_types

import 'package:df_type/df_type.dart';

// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

void main() {
  // Lazy-convert any standard dart type (num, double, bool, String, Duration,
  // DateTime, etc.) to an int if sensible or return null:
  final int? i = letIntOrNull('55');
  print(i); // 55

  // Lazy-convert any map from one type to another if sensible, otherwise
  // return null.
  final Map<String, int>? m = letMapOrNull<String, int>({55: '56'});
  print(m); // {55, 56}

  // Lazy-convert comma separated strings, a value, or an iterable to a list if
  // sensible, otherwise return null.
  print(letListOrNull('1, 2, 3, 4')); // [1, 2, 3, 4]
  print(letListOrNull('[1, 2, 3, 4]')); // [1, 2, 3, 4]
  print(letListOrNull([1, 2, 3, 4])); // [1, 2, 3, 4]
  print(letListOrNull(1)); // [1]

  // Lazy-convert any value to a double if sensible, otherwise return null.
  print(letOrNull<double>('123')); // 123.0

  // Check if a type is nullable or not:
  print(isNullable<int>()); // false
  print(isNullable<int?>()); // true

  // Convert a String to a Duration.

  final Duration duration =
      const ConvertStringToDuration('11:11:00.00').toDuration();
  print(duration); // 11:11:00.000000
}
2
likes
0
pub points
68%
popularity

Publisher

verified publisherdevcetra.com

A package designed to simplify and enhance interactions with Dart types.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

collection

More

Packages that depend on df_type