flutter_getit 1.2.1 copy "flutter_getit: ^1.2.1" to clipboard
flutter_getit: ^1.2.1 copied to clipboard

Project that allows you to use get_it as a dependency injection but controlled by Flutter's lifecycle, registering and unregistering in page navigation.

example/example.md

Exemplos #

Exemplo de page #

class HomePage extends StatelessWidget {
  
  final controller = Injector.get<HomeController>();
  
  HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    var controller = context.get<HomeController>();
    return Scaffold(
      appBar: AppBar(
        title: const Text('Home'),
      ),
      body: Center(child: Text(controller.name)),
    );
  }
}

Exemplo de rota #

class HomeRoute extends FlutterGetItPageRoute {
  
  const HomeRoute({super.key});
  
  @override
  List<Bind> get bindings => [
    Bind.singleton((i) => HomeController())
  ];  
  
  @override
  WidgetBuilder get page => (context) => HomePage();
}

Exemplo de configuração #

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const HomeRouter(),
    );
  }
}
82
likes
150
pub points
89%
popularity

Publisher

verified publisheracademiadoflutter.com.br

Project that allows you to use get_it as a dependency injection but controlled by Flutter's lifecycle, registering and unregistering in page navigation.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter, get_it

More

Packages that depend on flutter_getit