-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
46 changed files
with
1,241 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
path_provider=/Users/ibrahim/development/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-0.5.0+1/ | ||
shared_preferences=/Users/ibrahim/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.1+2/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# Visual Studio Code related | ||
.vscode/ | ||
|
||
# Flutter/Dart/Pub related | ||
**/doc/api/ | ||
.dart_tool/ | ||
pubspec.lock | ||
.flutter-plugins | ||
.packages | ||
.pub-cache/ | ||
.pub/ | ||
/build/ | ||
*.g.dart | ||
|
||
# Android related | ||
**/android/**/gradle-wrapper.jar | ||
**/android/.gradle | ||
**/android/captures/ | ||
**/android/gradlew | ||
**/android/gradlew.bat | ||
**/android/local.properties | ||
**/android/**/GeneratedPluginRegistrant.java | ||
|
||
# iOS/XCode related | ||
**/ios/**/*.mode1v3 | ||
**/ios/**/*.mode2v3 | ||
**/ios/**/*.moved-aside | ||
**/ios/**/*.pbxuser | ||
**/ios/**/*.perspectivev3 | ||
**/ios/**/*sync/ | ||
**/ios/**/.sconsign.dblite | ||
**/ios/**/.tags* | ||
**/ios/**/.vagrant/ | ||
**/ios/**/DerivedData/ | ||
**/ios/**/Icon? | ||
**/ios/**/Pods/ | ||
**/ios/**/.symlinks/ | ||
**/ios/**/profile | ||
**/ios/**/xcuserdata | ||
**/ios/.generated/ | ||
**/ios/Flutter/App.framework | ||
**/ios/Flutter/Flutter.framework | ||
**/ios/Flutter/Generated.xcconfig | ||
**/ios/Flutter/app.flx | ||
**/ios/Flutter/app.zip | ||
**/ios/Flutter/flutter_assets/ | ||
**/ios/ServiceDefinitions.json | ||
**/ios/Runner/GeneratedPluginRegistrant.* | ||
|
||
# Exceptions to above rules. | ||
!**/ios/**/default.mode1v3 | ||
!**/ios/**/default.mode2v3 | ||
!**/ios/**/default.pbxuser | ||
!**/ios/**/default.perspectivev3 | ||
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages | ||
|
||
coverage/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled and should not be manually edited. | ||
|
||
version: | ||
revision: 8661d8aecd626f7f57ccbcb735553edc05a2e713 | ||
channel: stable | ||
|
||
project_type: package |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
TODO: Add Author Info here. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## [0.0.1] - TODO: Add release date. | ||
|
||
* TODO: Describe initial release. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
TODO: Add your license here. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# flrx | ||
|
||
A new Flutter package project. | ||
|
||
## Getting Started | ||
|
||
This project is a starting point for a Dart | ||
[package](https://flutter.io/developing-packages/), | ||
a library module containing code that can be shared easily across | ||
multiple Flutter or Dart projects. | ||
|
||
For help getting started with Flutter, view our | ||
[online documentation](https://flutter.io/docs), which offers tutorials, | ||
samples, guidance on mobile development, and a full API reference. | ||
|
||
##TODO | ||
|
||
Add Command Line Tools to generate files |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import 'package:dio/dio.dart'; | ||
|
||
class ApiClient extends Dio { | ||
ApiClient({BaseOptions options}) : super(options) { | ||
interceptors.add(LogInterceptor( | ||
error: true, | ||
request: true, | ||
requestBody: true, | ||
requestHeader: true, | ||
responseBody: true, | ||
responseHeader: true)); | ||
} | ||
|
||
void setDefaultHeader(Map<String, String> headers) { | ||
options.headers = headers; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import 'package:flrx/components/error/error_handler.dart'; | ||
import 'package:flrx/components/error/error_reporter.dart'; | ||
import 'package:flrx/components/registrar/service_registrar.dart'; | ||
|
||
class Application { | ||
static final ServiceRegistrar registrar = ServiceRegistrar(); | ||
|
||
static void init(void Function() initApp, | ||
void Function(ServiceRegistrar) setupSingletons) { | ||
setupSingletons(registrar); | ||
ErrorHandler.init(reporter: get<ErrorReporter>()).runApp(initApp); | ||
} | ||
|
||
static T get<T>() => registrar<T>(); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export 'error_handler.dart'; | ||
export 'error_reporter.dart'; | ||
export 'sentry_error_reporter.dart'; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:flrx/components/error/error_reporter.dart'; | ||
import 'package:flrx/components/logger/logger.dart'; | ||
import 'package:flrx/config/config.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
|
||
class ErrorHandler { | ||
//Create new Error Handler | ||
factory ErrorHandler.init({@required ErrorReporter reporter}) { | ||
_instance ??= ErrorHandler._internal(reporter); | ||
return _instance; | ||
} | ||
|
||
ErrorHandler._internal(this.reporter) | ||
: reportErrorOnDebug = reporter.reportOnDebug ?? false { | ||
_setupFlutterErrorHandler(); | ||
} | ||
|
||
static void dispose() => _instance = null; | ||
|
||
final ErrorReporter reporter; | ||
|
||
static ErrorHandler _instance; | ||
|
||
final bool reportErrorOnDebug; | ||
|
||
static ErrorHandler get instance { | ||
return _instance; | ||
} | ||
|
||
void _setupFlutterErrorHandler() { | ||
// This captures errors reported by the Flutter framework. | ||
FlutterError.onError = (FlutterErrorDetails details) async { | ||
if (Config.isInDebugMode && !reportErrorOnDebug) { | ||
// In development mode and Debug Mode reporting is disabled. Simply log it | ||
log(details); | ||
} else { | ||
// In production mode report to the application zone | ||
Zone.current.handleUncaughtError(details.exception, details.stack); | ||
} | ||
}; | ||
} | ||
|
||
void runApp(Function appFunction) { | ||
runZoned<Future<void>>(() async { | ||
appFunction(); | ||
}, onError: reportError); | ||
} | ||
|
||
void reportError(dynamic error, StackTrace stackTrace) async { | ||
if (Config.isInDebugMode && !reportErrorOnDebug) { | ||
log('Caught error: $error'); | ||
log(stackTrace); | ||
log('In dev mode. Not reporting Error'); | ||
return; | ||
} | ||
_instance.reporter.reportError(error, stackTrace); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
abstract class ErrorReporter { | ||
bool reportOnDebug = false; | ||
|
||
void reportError(dynamic error, StackTrace stackTrace); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import 'package:flrx/components/error/error_reporter.dart'; | ||
import 'package:flrx/components/logger/logger.dart'; | ||
import 'package:meta/meta.dart'; | ||
import 'package:sentry/sentry.dart'; | ||
|
||
/// Sentry Error Reporter from [https://flutter.dev/docs/cookbook/maintenance/error-reporting] | ||
class SentryErrorReporter with ErrorReporter { | ||
SentryErrorReporter({@required String dsn}) | ||
: _sentry = SentryClient(dsn: dsn); | ||
|
||
final SentryClient _sentry; | ||
|
||
/// Reports [error] along with its [stackTrace] to Sentry.io. | ||
@override | ||
void reportError(dynamic error, StackTrace stackTrace) async { | ||
log('Reporting to Sentry.io...'); | ||
final SentryResponse response = await _sentry.captureException( | ||
exception: error, | ||
stackTrace: stackTrace, | ||
); | ||
|
||
if (response.isSuccessful) { | ||
log('Success! Event ID: ${response.eventId}'); | ||
} else { | ||
log('Failed to report to Sentry.io: ${response.error}'); | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'package:flrx/application.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
|
||
abstract class Localizer { | ||
String translate(final BuildContext context, final String key, | ||
{final Map<String, String> translationParams}); | ||
|
||
String plural( | ||
final BuildContext context, final String key, final int pluralValue); | ||
|
||
void setLocale(final BuildContext context, final Locale locale); | ||
|
||
LocalizationsDelegate<Object> getLocalizationDelegate(); | ||
} | ||
|
||
// ignore: unused_element, non_constant_identifier_names | ||
String translate(final BuildContext context, final String key, | ||
{final Map<String, String> translationParams}) => | ||
Application.get<Localizer>() | ||
.translate(context, key, translationParams: translationParams); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'package:flrx/components/localization/base_localizer.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:flutter_i18n/flutter_i18n.dart'; | ||
import 'package:flutter_i18n/flutter_i18n_delegate.dart'; | ||
|
||
class JsonLocalizer extends Localizer { | ||
JsonLocalizer( | ||
{@required this.fallbackFile, | ||
@required this.path, | ||
@required this.useCountryCode}); | ||
|
||
final String fallbackFile; | ||
final String path; | ||
final bool useCountryCode; | ||
|
||
@override | ||
String translate(final BuildContext context, final String key, | ||
{final Map<String, String> translationParams}) => | ||
FlutterI18n.translate(context, key, translationParams); | ||
|
||
@override | ||
String plural(final BuildContext context, final String key, | ||
final int pluralValue) => | ||
FlutterI18n.plural(context, key, pluralValue); | ||
|
||
@override | ||
void setLocale(final BuildContext context, final Locale locale) => | ||
FlutterI18n.refresh(context, locale); | ||
|
||
@override | ||
LocalizationsDelegate<Object> getLocalizationDelegate() => | ||
FlutterI18nDelegate( | ||
fallbackFile: fallbackFile, | ||
path: path, | ||
useCountryCode: useCountryCode); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export 'base_localizer.dart'; | ||
export 'json_localizer.dart'; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import 'package:flrx/application.dart'; | ||
|
||
abstract class Logger { | ||
void log(dynamic message); | ||
} | ||
|
||
void log(dynamic message) => Application.get<Logger>().log(message); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'package:flrx/components/logger/base_logger.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
|
||
class ConsoleLogger extends Logger { | ||
@override | ||
void log(dynamic message) { | ||
if (message is FlutterErrorDetails) { | ||
FlutterError.dumpErrorToConsole(message); | ||
} else | ||
debugPrint(message.toString()); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export 'base_logger.dart'; | ||
export 'console_logger.dart'; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import 'package:get_it/get_it.dart'; | ||
|
||
class ServiceRegistrar extends GetIt {} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'package:flrx/config/flavors/flavor_config.dart'; | ||
import 'package:flrx/flrx.dart'; | ||
|
||
abstract class Config { | ||
static bool get isInDebugMode { | ||
bool inDebugMode = false; | ||
assert(inDebugMode = true); | ||
return inDebugMode; | ||
} | ||
|
||
Config(); | ||
|
||
Config of(Flavor flavor); | ||
|
||
static T get<T extends Config>() { | ||
return FlavorConfig.instance.configList.firstWhere( | ||
(Config config) => config is T, | ||
orElse: () => | ||
throw Exception("Config $T is not registered in ConfigList")); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export 'base_config.dart'; | ||
export 'config_error.dart'; | ||
export 'flavors/flavor.dart'; | ||
export 'flavors/flavor_config.dart'; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import 'package:flrx/config/flavors/flavor.dart'; | ||
import 'package:meta/meta.dart'; | ||
|
||
class ConfigNotImplementedError extends UnimplementedError { | ||
ConfigNotImplementedError({@required this.configType, @required this.flavor}); | ||
|
||
String configType; | ||
BaseFlavor flavor; | ||
|
||
@override | ||
String toString() => | ||
"ConfigNotImplementedError: $configType Has not been implemented for $flavor"; | ||
} |
Oops, something went wrong.