modular_di 0.0.5 copy "modular_di: ^0.0.5" to clipboard
modular_di: ^0.0.5 copied to clipboard

A lightweight and flexible module system for Flutter applications, providing dependency injection and module management capabilities.

example/lib/main.dart

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

import 'features/core/core_module.dart';
import 'features/home/home_module.dart';
import 'features/message/message_module.dart';
import 'features/profile/profile_module.dart';

/// ### All the modules that the app has. <br/>
/// It's used to initialize the dependencies. <br/><br/>
final modules = <Module>[
  CoreModule(),
  MessageModule(),
  HomeModule(),
  ProfileModule(),
];

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  ModulesManager.instance.addModules(modules);
  await ModulesManager.instance.initAllModules();
  runApp(const MyApp());
}

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      initialRoute: '/',
      routes: {
        '/': (context) => const ModuleWidget<HomeModule>(child: HomeScreen()),
        '/message': (context) => const ModuleWidget<MessageModule>(child: MessageScreen()),
        '/profile': (context) => const ModuleWidget<ProfileModule>(child: ProfileScreen()),
      },
    );
  }
}
1
likes
150
points
--
downloads

Publisher

verified publisherdeivao.dev

A lightweight and flexible module system for Flutter applications, providing dependency injection and module management capabilities.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

auto_injector, flutter, meta, uuid

More

Packages that depend on modular_di