oinject 0.1.2 copy "oinject: ^0.1.2" to clipboard
oinject: ^0.1.2 copied to clipboard

A lightweight dependency injection package for Flutter, simplifying state and service management across widgets.

example/main.dart

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

void main() {
  runApp(const App());
}

class App extends StatelessWidget {
  const App({super.key});

  @override
  Widget build(BuildContext context) {
    provide(context, 'Provide from App widget');

    return MaterialApp(home: _Home());
  }
}

class _Home extends StatelessWidget {
  const _Home();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(child: _ShowProvidedText()),
    );
  }
}

class _ShowProvidedText extends StatelessWidget {
  const _ShowProvidedText();

  @override
  Widget build(BuildContext context) {
    final text = inject<String>(context);

    return Text(text!);
  }
}
0
likes
150
points
21
downloads

Publisher

verified publisherodroe.dev

Weekly Downloads

A lightweight dependency injection package for Flutter, simplifying state and service management across widgets.

Homepage
Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

_octr, flutter

More

Packages that depend on oinject