module_provider 0.0.4 copy "module_provider: ^0.0.4" to clipboard
module_provider: ^0.0.4 copied to clipboard

outdated

Package to facilitate the creation of applications in modules structure

module_provider #

Package to facilitate the creation applications in hierarquical modules structure

import 'package:module_provider/module_provider.dart';

Module: The module contain the basic structure for determined component, it is created when 'Component' is builded, and disposed when the 'Component' is disposed. When module is dispose, all services are disposable also.

Service: The service provide a class containing functions and properties to components, modules and another services, he is created and maintained in memory, when module be disposable, all services also be disposed.

Component: Componentes are a pages or widgets extended from StatefulWidget, but with a simple class, don't needing create a StatefullWidget and State class. All components need the module referente on your constructor.

Controller: The controller are utilized inside a components, for maintain the logical separated from component, and avoid the recreation of variables when widget build is called.

Simple exemple to use Module Provider #

On main.dart, i will informed that the 'AppModule' is my root module, so the component returned from 'build' function inside the module will be showed.

import 'app_module.dart';

void main() {
	runApp(MaterialApp(
		title: 'Module Provider',
		theme: ThemeData(primarySwatch: Colors.blue,),
		home: AppModule()
	));
}

app_module.dart

import 'package:flutter/material.dart';

class AppModule extends Module {
	@override
	List<Inject<Service>> get services => [
		Inject((m, arg) => AppService(m)),
		Inject((m, arg) => AuthService(m, this.service<AppService>())),
	];

	@override
	List<Inject<Module>> get modules => [
		Inject((m, arg) => HomeModule(m)),
		Inject((m, arg) => RegistrationModule(m, arg)),
	];

	@override
	List<Inject<Component>> get components => [
		Inject((m, arg) => MainPage(m)),
		Inject((m, arg) => SplashScreenPage(m)),
	];

	AppModule() : super(null);

	@override
  	Widget build(BuildContext context) => component<MainPage>();
}
6
likes
0
pub points
0%
popularity

Publisher

unverified uploader

Package to facilitate the creation of applications in modules structure

Homepage

License

unknown (LICENSE)

Dependencies

flutter, useful_classes

More

Packages that depend on module_provider