extensions 0.3.13 copy "extensions: ^0.3.13" to clipboard
extensions: ^0.3.13 copied to clipboard

A set of APIs for commonly used programming patterns and utilities, such as dependency injection, logging, and configuration.

A set of APIs for commonly used programming patterns and utilities, such as dependency injection, logging, and configuration.

pub package Build Status

Configuration #

import 'package:extensions/configuration.dart';

void main() {
  var configurationBuilder = ConfigurationBuilder()
    // Adds a memory collection to the configuration system.
    ..addInMemoryCollection(
      <String, String>{
        'Logging:LogLevel:Default': 'Warning',
      }.entries,
    );

  var config = configurationBuilder.build();
  print(config['Logging:LogLevel:Default']);
}

Dependency Injection #

import 'package:extensions/dependency_injection.dart';

void main() {
  var serviceCollection = ServiceCollection();
  serviceCollection.addSingleton<MyService>(
    implementationInstance: MyService(),
  );
  var services = serviceCollection.buildServiceProvider();
  var myService = services.getRequiredService<MyService>();
}

Logging #

package:extensions/logging.dart' provides a class [LoggerFactory][LoggerFactory] to create a [Logger`][Logger] for a specific category.

import 'package:extensions/logging.dart';

void main() {
  LoggerFactory.create(
    (builder) => builder
    ..addDebug()
    ..setMinimumLevel(LogLevel.debug),
  ).createLogger('MyLogger').logDebug('Hello World');
}

The preceeding code uses the [LoggerFactory] static method [create][LoggerFactory.create] to create a [Logger][Logger]. The output is displayed in the debug window and looks like this:

[MyLogger] LogLevel.debug: Hello World

Generic Host #

import 'package:extensions/hosting.dart' 

Future<void> main(List<String> args) async =>
    await Host.createDefaultBuilder(args)
        .useConsoleLifetime()
        .build()
        .run();

Extensions is a derived work of the dotnet/runtime

1
likes
130
pub points
45%
popularity

Publisher

verified publisherjamiewest.dev

A set of APIs for commonly used programming patterns and utilities, such as dependency injection, logging, and configuration.

Repository
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

async, collection, path, tuple, uuid, watcher

More

Packages that depend on extensions