Skip to content

Commit

Permalink
(all) code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
pbissonho committed Mar 7, 2021
1 parent e3e50e9 commit 51a3e8c
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 16 deletions.
3 changes: 1 addition & 2 deletions packages/koin/lib/src/context/context_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ import '../koin_application.dart';
import '../koin_dart.dart';
import 'context.dart';

///
//ignore: avoid_classes_with_only_static_members
/// Help hold any implementation of KoinContext
///
class KoinContextHandler {
static KoinContext? _context;

Expand Down
1 change: 1 addition & 0 deletions packages/koin/lib/src/definition/definition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ typedef ProviderCreate<T> = T Function(Scope scope);

typedef ProviderCreateParam<T, A> = T Function(Scope scope, A param);

// ignore: one_member_abstracts
abstract class ProviderCreateBase<T> {
T create(Parameter? parameter, Scope scope);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/koin/lib/src/instance/instance_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ abstract class InstanceFactory<T> {
///
T createState(InstanceContext context) {
try {
final parameters = context.parameter;
final parameter = context.parameter;
koin.loggerObserver.onCreate(this);
return beanDefinition.definition.create(parameters, context.scope);
return beanDefinition.definition.create(parameter, context.scope);
} catch (erro) {
koin.logger.error('''
Instance creation error : could not create instance for $beanDefinition: ${erro.toString()}''');
Expand Down
1 change: 1 addition & 0 deletions packages/koin/lib/src/scope/scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import '../logger.dart';
import '../qualifier.dart';
import 'scope_definition.dart';

// ignore: one_member_abstracts
abstract class ScopeCallback {
void onScopeClose();
}
Expand Down
1 change: 1 addition & 0 deletions packages/koin/test/core/error_check_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ void main() {
});

// TODO
// Analyze a way to treat
/*
test('cycle error', () {
var app = koinApplication((app) {
Expand Down
7 changes: 1 addition & 6 deletions packages/koin/test/core/parameters_injection_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,13 @@ void main() {
expect(b.id, 43);
});

// TODO
// Analyze if it is really necessary.
test('shoud trow a exception when not pass parameters - getWithParams', () {
var app = koinApplication((app) {
app.module(
Module()..singleWithParam<MySingle, int>((s, id) => MySingle(id)));
});

final mySingle = app.koin.get<MySingle>();

expect(() => app.koin.get<MySingle>(),
throwsA(isA<InstanceCreationException>()));
print(mySingle);
}, skip: true);
});
}
1 change: 1 addition & 0 deletions packages/koin_flutter/lib/src/scope_observer.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/widgets.dart';
import 'package:koin/internals.dart';

// ignore: avoid_classes_with_only_static_members
class FlutterKoinScopeObserver {
static ScopeWidgetObersever scopeWidgetObserver = ScopeWidgetObersever();
}
Expand Down
4 changes: 2 additions & 2 deletions packages/koin_flutter/test/widget_extension_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ void main() {

// Create the Finders.
final componentSingleIdFinder = find.text('1');
//final componentBSingleFinder = find.text('10');
final componentBSingleFinder = find.text('10');
final componentIdFactoryFinder = find.text('60');
final componentScopedFinder = find.text('30');

expect(componentSingleIdFinder, findsNWidgets(1));
//expect(componentBSingleFinder, findsOneWidget);
expect(componentBSingleFinder, findsOneWidget);
expect(componentIdFactoryFinder, findsOneWidget);
expect(componentScopedFinder, findsOneWidget);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ class _HomePageWithParamsState extends State<HomePageWithParams>
body: Column(
children: <Widget>[
Text("${componentSingle.id.toString()}"),
// TODO
// Text("${componentBSingle.id.toString()}"),
Text("${componentBSingle.testId().toString()}"),
Text("${componentScoped.id.toString()}"),
Text("${componentFactory.id.toString()}"),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void main() {

testModule('shoud be a valid module', customModule,
checkParameters: checkParametersOf({
ComponentC: ComponentCParam('Fisrt', "Last"),
ComponentC: ComponentCParam('Fisrt', 'Last'),
}));

test('shoud be a invalid module', () {
Expand Down
2 changes: 1 addition & 1 deletion packages/koin_test/lib/src/error/error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ abstract class BrokenDefinitionException implements Exception {

@override
String toString() {
return '${runtimeType}: $msg';
return '$runtimeType: $msg';
}
}

0 comments on commit 51a3e8c

Please sign in to comment.