karee_inject 1.0.3 icon indicating copy to clipboard operation
karee_inject: ^1.0.3 copied to clipboard

Part of Karee that manage all annotation used to inject dependency

Karee Inject #

Library used to help developers to better manage dependency injection during flutter development.

Usage #

Karee Inject provide an amazing collection of annotation like Service for services, Value for reading value from application config file, Autowired to auto initialize classe and Persistable A simple usage example:

Use of @Persistable with data model

import 'package:karee_inject/karee_inject.dart';

@Persistable
class User {

  double id;
  String name;

  User(this.id, this.name);

}

Use of Service to define a service, Autowired and Value to inject application configuration and other services.

@Service
class ServiceUser {

  @Value('@{application.server.base-url}')
  late final String baseUrl;

  @Autowired
  late final DatabaseInterface db;

  User? getUserById(double id){

    return db
      .find(User.runtimeType)
      .where('id', isEqualTo: id);
      
  }
}

Use of Controller to define a Controller, and Autowired to inject Services property;

@Controller
class UserController {

  @Autowired
  late final UserService userService;

  void showUserDetailView(double id){

    User? user = userService.getUserById();
    
    if(user == null){
      screen(UserNotFoundScreen(), RouteMode.PUSH);
      return;
    }

    screen(UserDetailScreen(user: user), RouteMode.PUSH);  
  }
}

Test #

# Generate additional source first
flutter packages pub run build_runner build --delete-conflicting-outputs

# Then run test
flutter test
1
likes
130
pub points
3%
popularity

Publisher

verified publisher iconflutter.bixterprise.com

Part of Karee that manage all annotation used to inject dependency

Documentation

API reference

License

Icon for licenses.MIT (LICENSE)

Dependencies

meta

More

Packages that depend on karee_inject