modularity_flutter 0.1.0 copy "modularity_flutter: ^0.1.0" to clipboard
modularity_flutter: ^0.1.0 copied to clipboard

Flutter integration for Modularity framework. Provides widgets and utilities for module-based Flutter apps.

example/lib/main.dart

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

void main() {
  runApp(
    ModularityRoot(
      child: const MyApp(),
    ),
  );
}

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: HomePage(),
    );
  }
}

class HomeModule extends Module {
  @override
  void binds(Binder binder) {
    binder.singleton(() => 'Hello from Home Module!');
  }
}

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

  @override
  Widget build(BuildContext context) {
    return ModuleScope(
      module: HomeModule(),
      child: Scaffold(
        appBar: AppBar(title: const Text('Modularity Example')),
        body: Center(
          child: Builder(
            builder: (context) {
              // Access dependency from the current module scope
              // We use ModuleProvider.of(context) to get the binder
              final binder = ModuleProvider.of(context);
              final message = binder.get<String>();
              return Text(message);
            },
          ),
        ),
      ),
    );
  }
}
1
likes
160
points
258
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter integration for Modularity framework. Provides widgets and utilities for module-based Flutter apps.

Repository (GitHub)
View/report issues

Topics

#dependency-injection #di #flutter #modules

Documentation

API reference

License

MIT (license)

Dependencies

flutter, modularity_contracts, modularity_core

More

Packages that depend on modularity_flutter