Skip to content

Commit

Permalink
Reformat the code using "flutter format", set line to 80 characters.
Browse files Browse the repository at this point in the history
  • Loading branch information
noordawod committed Jan 7, 2021
1 parent 75ae080 commit 74fbe58
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ trim_trailing_whitespace = true
end_of_line = lf
insert_final_newline = true
charset = utf-8
max_line_length = 100
max_line_length = 80
indent_size = 2
indent_style = space
7 changes: 5 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import 'package:get_it_example/app_model.dart';
GetIt getIt = GetIt.instance;

void main() {
getIt.registerSingleton<AppModel>(AppModelImplementation(), signalsReady: true);
getIt.registerSingleton<AppModel>(AppModelImplementation(),
signalsReady: true);

runApp(MyApp());
}
Expand Down Expand Up @@ -39,7 +40,9 @@ class _MyHomePageState extends State<MyHomePage> {
void initState() {
// Access the instance of the registered AppModel
// As we don't know for sure if AppModel is already ready we use getAsync
getIt.isReady<AppModel>().then((_) => getIt<AppModel>().addListener(update));
getIt
.isReady<AppModel>()
.then((_) => getIt<AppModel>().addListener(update));
// Alternative
// getIt.get<AppModel>().addListener(update);

Expand Down
19 changes: 15 additions & 4 deletions lib/get_it.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ typedef FactoryFunc<T> = T Function();

/// For Factories that expect up to two parameters if you need only one use `void` for the one
/// you don't use
typedef FactoryFuncParam<T, P1, P2> = T Function(P1 param1, P2 param2);
typedef FactoryFuncParam<T, P1, P2> = T Function(
P1 param1,
P2 param2,
);

/// Signature of the factory function used by async factories
typedef FactoryFuncAsync<T> = Future<T> Function();
Expand All @@ -32,7 +35,10 @@ typedef ScopeDisposeFunc = FutureOr Function();

/// For async Factories that expect up to two parameters if you need only one use `void` for the one
/// you don't use
typedef FactoryFuncParamAsync<T, P1, P2> = Future<T> Function(P1 param1, P2 param2);
typedef FactoryFuncParamAsync<T, P1, P2> = Future<T> Function(
P1 param1,
P2 param2,
);

class WaitingTimeOutException implements Exception {
/// In case of an timeout while waiting for an instance to get ready
Expand All @@ -48,13 +54,18 @@ class WaitingTimeOutException implements Exception {
/// Lists with Types that are already ready.
final List<String> areReady;

WaitingTimeOutException(this.areWaitedBy, this.notReadyYet, this.areReady);
WaitingTimeOutException(
this.areWaitedBy,
this.notReadyYet,
this.areReady,
);
// todo : assert(areWaitedBy != null && notReadyYet != null && areReady != null);

@override
String toString() {
// ignore: avoid_print
print('GetIt: There was a timeout while waiting for an instance to signal ready');
print(
'GetIt: There was a timeout while waiting for an instance to signal ready');
// ignore: avoid_print
print('The following instance types where waiting for completion');
for (final entry in areWaitedBy.entries) {
Expand Down
Loading

0 comments on commit 74fbe58

Please sign in to comment.