This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:kiwi/kiwi.dart'; | |
part 'test01.g.dart'; | |
abstract class Injector { | |
@Register.singleton(ServiceA) | |
@Register.factory(Service, from: ServiceB) | |
@Register.factory(ServiceB, name: 'factoryB') | |
@Register.factory(ServiceC, resolvers: {ServiceB: 'factoryB'}) | |
void common(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GENERATED CODE - DO NOT MODIFY BY HAND | |
part of 'test01.dart'; | |
// ************************************************************************** | |
// InjectorGenerator | |
// ************************************************************************** | |
class _$Injector extends Injector { | |
void configure() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:kiwi/kiwi.dart'; | |
part 'test01.g.dart'; | |
abstract class Injector { | |
@Register.singleton(ServiceA) | |
@Register.factory(Service, from: ServiceB) | |
@Register.factory(ServiceB, name: 'factoryB') | |
@Register.factory(ServiceC, resolvers: {ServiceB: 'factoryB'}) | |
@Register.factory(ServiceC, constructorName: 'other') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Service {} | |
class ServiceA extends Service {} | |
class ServiceB extends Service { | |
ServiceB(ServiceA serviceA); | |
} | |
... | |
// Registers a complex factory by resolving the dependency | |
// when the type is resolved. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gets the instance registered for the Sith type. | |
Sith theSith = container.resolve<Sith>(); | |
// Gets the instance registered for the Sith type under 'DartVader' name. | |
Sith dartVader = container.resolve<Sith>('DartVader'); | |
// Container is a callable class, so you can also resolve a type like this: | |
Sith sith = container<Sith>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Registers a new singleton. | |
container.registerSingleton((c) => Sith('Anakin', 'Skywalker')); | |
// Registers a new singleton with a specified name. | |
container.registerSingleton((c) => Sith('Anakin', 'Skywalker'), name: 'DartVader'); | |
// Registers a new singleton, with a specified name, and under a supertype. | |
container.registerSingleton<Character, Sith>((c) => Sith('Anakin', 'Skywalker'), name: 'DartVader'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Registers a new factory. | |
container.registerFactory((c) => Sith('Anakin', 'Skywalker')); | |
// Registers a new factory with a specified name. | |
container.registerFactory((c) => Sith('Anakin', 'Skywalker'), name: 'DartVader'); | |
// Registers a new factory, with a specified name, and under a supertype. | |
container.registerFactory<Character, Sith>((c) => Sith('Anakin', 'Skywalker'), name: 'DartVader'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Registers a new instance. | |
container.registerInstance(Sith('Anakin', 'Skywalker')); | |
// Registers a new instance with a specified name. | |
container.registerInstance(Sith('Anakin', 'Skywalker'), name: 'DartVader'); | |
// Registers a new instance, with a specified name, and under a supertype. | |
container.registerInstance<Character, Sith>(Sith('Anakin', 'Skywalker'), name: 'DartVader'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Container container = Container(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const _kDuration = const Duration(milliseconds: 2000); | |
const _kAnimInterval03 = const Interval(.00, .90); | |
... | |
Widget _buildAnimation(BuildContext context, Widget child) { | |
return Container( | |
child: Container( | |
width: _kActionSize * 4, | |
height: 256.0, | |
color: Colors.black87, | |
child: Center( |