Skip to content

Commit

Permalink
feat: Basic di implementation added
Browse files Browse the repository at this point in the history
  • Loading branch information
vanlooverenkoen committed Dec 24, 2023
1 parent f6ce067 commit 373e348
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 13 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ migrate_working_dir/
**/doc/api/
.dart_tool/
build/

# flutter-plugins
.flutter-plugins
.flutter-plugins-dependencies
20 changes: 15 additions & 5 deletions lib/impaktfull_architecture.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
library impaktfull_architecture;

/// A Calculator.
class Calculator {
/// Returns [value] plus 1.
int addOne(int value) => value + 1;
}
// 3rd party packages
export 'package:connectivity_plus/connectivity_plus.dart';
export 'package:device_info_plus/device_info_plus.dart';
export 'package:dio/dio.dart';
export 'package:get_it/get_it.dart';
export 'package:injectable/injectable.dart' hide test;
export 'package:flutter_secure_storage/flutter_secure_storage.dart';
export 'package:flutter_svg/flutter_svg.dart';
export 'package:provider/provider.dart';
export 'package:shared_preferences/shared_preferences.dart';
export 'package:sprintf/sprintf.dart';
export 'package:synchronized/synchronized.dart';
export 'package:tuple/tuple.dart';
export 'package:url_launcher/url_launcher.dart';
export 'package:url_launcher/url_launcher_string.dart';
22 changes: 22 additions & 0 deletions lib/src/di/di.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:injectable/injectable.dart';
import 'package:shared_preferences/shared_preferences.dart';

Future<void> configureImpaktfullArchitecture(GetItHelper gh,
{bool isWeb = kIsWeb}) async {
await _register3rdPartyStorage(gh, isWeb: isWeb);
}

Future<void> _register3rdPartyStorage(GetItHelper gh,
{required bool isWeb}) async {
await gh.lazySingletonAsync<SharedPreferences>(
() => SharedPreferences.getInstance(),
preResolve: true,
);
gh.lazySingleton<Connectivity>(() => Connectivity());
gh.lazySingleton<DeviceInfoPlugin>(() => DeviceInfoPlugin());
gh.lazySingleton<FlutterSecureStorage>(() => const FlutterSecureStorage());
}
13 changes: 13 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,21 @@ environment:
flutter: ">=1.17.0"

dependencies:
connectivity_plus: ^5.0.2
device_info_plus: ^9.1.1
flutter:
sdk: flutter
dio: ^5.4.0
get_it: ^7.6.4
injectable: ^2.3.2
flutter_secure_storage: ^9.0.0
flutter_svg: ^2.0.9
provider: ^6.1.1
shared_preferences: ^2.2.2
sprintf: ^7.0.0
synchronized: ^3.1.0+1
tuple: ^2.0.2
url_launcher: ^6.2.2

dev_dependencies:
flutter_test:
Expand Down
9 changes: 1 addition & 8 deletions test/impaktfull_architecture_test.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import 'package:flutter_test/flutter_test.dart';

import 'package:impaktfull_architecture/impaktfull_architecture.dart';

void main() {
test('adds one to input values', () {
final calculator = Calculator();
expect(calculator.addOne(2), 3);
expect(calculator.addOne(-7), -6);
expect(calculator.addOne(0), 1);
});
test('no-op', () {});
}
3 changes: 3 additions & 0 deletions tools/format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

fvm dart format .
3 changes: 3 additions & 0 deletions tools/packages_get.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

fvm flutter packages get

0 comments on commit 373e348

Please sign in to comment.