basics 0.4.0+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 87

Dart Basics #

This repository contains a collection of useful extension methods on the built-in objects in Dart, such as String, Iterable, and Object.

Usage #

Import the basics library.

import 'package:basics/basics.dart';

Then use the methods directly on objects in your dart code.

List<int> numbers;

if (numbers.isNull) {
  print('Numbers is uninitialized');
}

for (var i in 1.to(10)) {
  if (i.isEven) numbers.add(i);
}

if (numbers.isNotNull && numbers.all(isEven)) {
  print('All numbers are even');
}

Notes #

This is not an official Google project.

[0.4.0] #

Added MapBasics.get.

[0.3.0] #

Added DateTimeBasics.

[0.2.0] - 2020-04-24 #

Add example and changelog.

[0.1.0] - 2020-04-24 #

Initial release.

example/main.dart

// Copyright (c) 2020, Google Inc. Please see the AUTHORS file for details.
// All rights reserved. Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

import 'package:basics/basics.dart';

main() async {
  const numbers = <int>[2, 4, 8];

  if (numbers.isNotNull && numbers.all((n) => n.isEven)) {
    print('All numbers are even.');
  }

  print('sum of numbers is: ${numbers.sum()}');

  for (var i in 5.range) {
    print('waiting 500 milliseconds...');
    await Future.delayed(500.milliseconds);
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  basics: ^0.4.0+1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or 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:basics/basics.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
74
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]
87
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.13

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
quiver ^2.1.2+1 2.1.3
Transitive dependencies
matcher 0.12.8
meta 1.1.8
path 1.7.0
stack_trace 1.9.5
Dev dependencies
test ^1.9.4