extension_kit 0.1.0+3

  • Readme
  • Changelog
  • Example
  • Installing
  • 50

extension_kit #

This is Dart extension kit. If this plugin is imported your project, it enable to use various extension function.

https://pub.dev/packages/extension_kit

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  extension_kit:

Feature list #

Implementation extension's list. It will be create more extension feature in future.

Usage #

Import extension_kit.

import 'package:extension_kit/extension_kit.dart';

int #

millisecondsToDate

print(1601996400000.millisecondsToDate()); // DateTime(2020, 10, 7)

double #

roundWithDigit

const value1 = 10.45678;
print(value1.roundWithDigit(1));   // 10.5
print(value1.roundWithDigit(2));   // 10.46
print(value1.roundWithDigit(3));   // 10.457
print(value1.roundWithDigit(0));   // 10.45678
print(value1.roundWithDigit(-1));  // 10.45678

const value2 = 10.434321;
print(value2.roundWithDigit(1));   // 10.4
print(value2.roundWithDigit(2);    // 10.43
print(value2.roundWithDigit(3));   // 10.434

num #

commaFormat

print(100.commaFormat());         // '100'
print(1000.commaFormat());        // '1,000'
print(1000000.commaFormat());     // '1,000,000'
print(1000000.123.commaFormat()); // '1,000,000.123'

String #

toDate

print('20201008'.toDate());       // DateTime(2020, 10, 8)

toInt

print('123'.toInt());             // 123

toDouble

print('123.4567'.toDouble());     // 123.4567

isNewLine

print('\n'.isNewLine());          // true
print('test'.isNewLine());        // false

Date #

formatString

final date = DateTime(2020, 10, 7);
print(date.formatString());                     // '10.07 2020'
print(date.formatString(format: 'yyyy/MM/dd')); // '2020/10/07'

diffDays, diffHours, diffMinutes, diffSeconds

final dateA = DateTime(2020, 10, 7, 20, 10, 30);
final dateB = DateTime(2020, 8, 2, 10, 5, 10);
final dateC = DateTime(2020, 10, 7, 20, 10, 30);

// dateA - dateB
print(dateA.diffDays(dateB));       // 66
print(dateA.diffHours(dateB));      // 1594
print(dateA.diffMinutes(dateB));    // 95645
print(dateA.diffSeconds(dateB));    // 5738720

isCompare

// dateA >= dateB => true
// dateA < dateB => false
final dateA = DateTime(2020, 10, 7, 20, 10, 30);
final dateB = DateTime(2020, 8, 2, 10, 5, 10);
final dateC = DateTime(2020, 10, 7, 20, 10, 30);

print(dateA.isCompare(dateB));  // true
print(dateA.isCompare(dateC));  // true
print(dateB.isCompare(dateA));  // false

0.1.0+3 #

Updated document.

0.1.0+2 #

Updated document.

0.1.0+1 #

Updated document.

0.1.0 #

First release.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:extension_kit/extension_kit.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  @override
  void initState() {
    super.initState();
  }


  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('Running on: $_platformVersion\n'),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  extension_kit: ^0.1.0+3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:extension_kit/extension_kit.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

We analyzed this package on Jun 11, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.9+1
  • Flutter: 1.17.3

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:extension_kit/extension_kit.dart]

Package does not support Flutter platform macos

Because of import path [package:extension_kit/extension_kit.dart]

Package does not support Flutter platform web

Because of import path [package:extension_kit/extension_kit.dart]

Package does not support Flutter platform windows

Because of import path [package:extension_kit/extension_kit.dart]

Package not compatible with SDK dart

because of import path [extension_kit]

Health suggestions

Format lib/extension/date_extension.dart.

Run flutter format to format lib/extension/date_extension.dart.

Format lib/extension/double_extension.dart.

Run flutter format to format lib/extension/double_extension.dart.

Format lib/extension/int_extension.dart.

Run flutter format to format lib/extension/int_extension.dart.

Format lib/extension_kit.dart.

Run flutter format to format lib/extension_kit.dart.

Format lib/generated/i18n.dart.

Run flutter format to format lib/generated/i18n.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
intl ^0.16.1 0.16.1
Transitive dependencies
collection 1.14.12
meta 1.1.8
path 1.7.0
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test
pedantic_mono any