pub package package publisher

.NET Extensions for Dart

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

Example

import 'package:extensions/hosting.dart';

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

Code Adaptations

The majority of code in this library is taken directly from the dotnet/runtime extension's namespace and aims to be as close a port as possible. However dart and c# dont always mix well. Below are some examples of how this library will handle scenarios that required some code modification.

Out Parameters

Parameters in dart are passed by value whereas with c# they can be passed by reference using the out keyword. In this example, we that the method TryGetValue returns a boolean

Dictionary<int, long> myDic;

if(myDic.TryGetValue(100, out var lValue))
{
    return lValue;
}

Libraries

caching
Contains classes and abstractions for caching data in memory and distributed systems.
configuration
Contains classes for reading application configuration from various sources.
dependency_injection
Provides a dependency injection container for managing services and their lifetimes.
diagnostics
Provides metrics and instrumentation support for application telemetry.
file_providers
Provides abstractions for file system operations with change tracking and composite file providers.
file_system_globbing
Provides support for matching file system paths using glob patterns with include/exclude semantics.
hosting
Provides classes for managing application lifetime, hosting background services, and coordinating application startup/shutdown.
http
Provides typed HTTP client factory with lifetime management and request/response logging.
logging
Provides a flexible logging infrastructure with support for multiple log providers and structured logging.
options
Provides types for implementing the options pattern for strongly-typed configuration.
primitives
Contains fundamental primitives and change notification types used throughout the extensions package.
system
Provides fundamental system types for resource management, threading, and common exceptions.