force_type 1.0.3 copy "force_type: ^1.0.3" to clipboard
force_type: ^1.0.3 copied to clipboard

A Dart package that provides functions to forcefully convert dynamic types to specific types.

example/force_type_example.dart

import 'package:force_type/force_type.dart';
import 'package:test/test.dart';

void main() {
  group('A group of tests', () {
    final dynamicA = 123;
    final dynamicB = "123";
    final dynamicC = "123.456";
    final dynamicD = "true";
    final dynamicE = "1";
    final dynamicF = "1969-07-20 20:18:04Z";

    test('Force String Test', () {
      expect(dynamicA.forceString, "123");
    });

    test('Force Integer Test', () {
      expect(dynamicB.forceInteger, 123);
    });

    test('Force Double Test', () {
      expect(dynamicC.forceDouble, 123.456);
    });

    test('Force Boolean Test', () {
      expect(dynamicD.forceBoolean, true);
      expect(dynamicE.forceBoolean, true);
    });

    test('Force DateTime Test', () {
      expect(dynamicF.forceDateTime, DateTime.parse("1969-07-20 20:18:04Z"));
    });
  });
}
1
likes
0
pub points
62%
popularity

Publisher

verified publisherkakzaki.dev

A Dart package that provides functions to forcefully convert dynamic types to specific types.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on force_type