-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
776 additions
and
275 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 |
---|---|---|
|
@@ -10,7 +10,6 @@ | |
.svn/ | ||
migrate_working_dir/ | ||
windows/ | ||
web/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
|
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
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,25 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "localic", | ||
"request": "launch", | ||
"type": "dart" | ||
}, | ||
{ | ||
"name": "localic (profile mode)", | ||
"request": "launch", | ||
"type": "dart", | ||
"flutterMode": "profile" | ||
}, | ||
{ | ||
"name": "localic (release mode)", | ||
"request": "launch", | ||
"type": "dart", | ||
"flutterMode": "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,19 @@ | ||
// | ||
// Generated file. Do not edit. | ||
// | ||
|
||
// ignore_for_file: directives_ordering | ||
// ignore_for_file: lines_longer_than_80_chars | ||
// ignore_for_file: depend_on_referenced_packages | ||
|
||
import 'package:file_picker/_internal/file_picker_web.dart'; | ||
import 'package:shared_preferences_web/shared_preferences_web.dart'; | ||
|
||
import 'package:flutter_web_plugins/flutter_web_plugins.dart'; | ||
|
||
// ignore: public_member_api_docs | ||
void registerPlugins(Registrar registrar) { | ||
FilePickerWeb.registerWith(registrar); | ||
SharedPreferencesPlugin.registerWith(registrar); | ||
registrar.registerMessageHandler(); | ||
} |
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
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,97 @@ | ||
import 'dart:developer'; | ||
|
||
import 'package:logger/logger.dart'; | ||
|
||
import '../../helpers/extensions/int_extension.dart'; | ||
|
||
final logger = LoggingService().createLogger(); | ||
|
||
class LoggingService { | ||
Logger createLogger() { | ||
return Logger( | ||
filter: _LogFilter(), | ||
printer: _LogPrinter(), | ||
output: _ConsoleLogOutput(), | ||
); | ||
} | ||
} | ||
|
||
class _LogFilter extends LogFilter { | ||
@override | ||
bool shouldLog(LogEvent event) => true; | ||
} | ||
|
||
class _LogPrinter extends LogPrinter { | ||
@override | ||
List<String> log(LogEvent event) { | ||
var message = event.message; | ||
var error = event.error; | ||
var stackTrace = event.stackTrace; | ||
var level = event.level; | ||
|
||
var builder = StringBuffer(); | ||
const spacer = '|'; | ||
builder.write(_getTime()); | ||
builder.write(spacer); | ||
builder.write(_logLevel(level)); | ||
builder.write(spacer); | ||
builder.write(_getLogLocation()); | ||
builder.write(spacer); | ||
builder.write(message); | ||
|
||
var errorString = error.toString(); | ||
if (errorString != 'null') { | ||
var errorLines = errorString.split('\n'); | ||
errorLines = errorLines.map((line) => ' $line').toList(); | ||
builder.write('\n${errorLines.join('\n')}'); | ||
builder.write('\n'); | ||
} | ||
|
||
var stackTraceString = stackTrace.toString(); | ||
if (stackTraceString != 'null') { | ||
var stackTraceLines = stackTraceString.split('\n'); | ||
stackTraceLines = | ||
stackTraceLines.map((line) => ' $line').take(100).toList(); | ||
builder.write('\n${stackTraceLines.join('\n')}'); | ||
} | ||
return [builder.toString()]; | ||
} | ||
|
||
String _logLevel(Level level) { | ||
return level.name.substring(0, 3).toUpperCase(); | ||
} | ||
|
||
String _getLogLocation() { | ||
final stack = StackTrace.current.toString().split('\n'); | ||
final line = stack[4]; | ||
return line.substring( | ||
line.lastIndexOf('/') + 1, | ||
line.indexOf('.dart'), | ||
); | ||
} | ||
|
||
String _getTime() { | ||
var now = DateTime.now().toUtc(); | ||
var h = now.hour.twoDigits(); | ||
var min = now.minute.twoDigits(); | ||
var sec = now.second.twoDigits(); | ||
var ms = now.millisecond.threeDigits(); | ||
return '$h:$min:$sec.$ms'; | ||
} | ||
} | ||
|
||
class _ConsoleLogOutput extends LogOutput { | ||
@override | ||
void output(OutputEvent event) { | ||
final color = _color(event.level); | ||
var message = color + event.lines.join('\n'); | ||
log(message); | ||
} | ||
|
||
String _color(Level level) => switch (level) { | ||
Level.error => '\u001b[1;31m', | ||
Level.warning => '\u001b[1;33m', | ||
Level.info => '\u001b[1;32m', | ||
_ => '\u001b[0m' | ||
}; | ||
} |
18 changes: 12 additions & 6 deletions
18
lib/global/services/translators/google_translator_service.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
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
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 @@ | ||
extension NullIntExtension on int? { | ||
bool get isNull => this == null; | ||
bool get isNotNull => this != null; | ||
bool get asBool => this == 1; | ||
|
||
bool get isNotNullOrZero => this != null && this != 0; | ||
bool get isNullOrZero => this == null || this == 0; | ||
} | ||
|
||
extension IntExtension on int { | ||
String twoDigits() { | ||
if (this >= 10) return '$this'; | ||
return '0$this'; | ||
} | ||
|
||
String threeDigits() { | ||
if (this >= 100) return '$this'; | ||
if (this >= 10) return '0$this'; | ||
return '00$this'; | ||
} | ||
} |
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 @@ | ||
extension StringExtension on String? { | ||
bool get isNullOrEmpty => this == null || this!.trim().isEmpty; | ||
|
||
bool get isNotNullOrEmpty => !isNullOrEmpty; | ||
|
||
bool get asBool { | ||
if (isNullOrEmpty) return false; | ||
switch (this!.toLowerCase()) { | ||
case 'true': | ||
case '1': | ||
return true; | ||
case 'false': | ||
case '0': | ||
return false; | ||
default: | ||
throw Exception('Invalid boolean value: $this'); | ||
} | ||
} | ||
|
||
/// remove all whitespace from the string | ||
String removeAllWhitespace() { | ||
return this!.trim().replaceAll(' ', ''); | ||
} | ||
|
||
bool containsIgnoreCase(String other) { | ||
return this!.toLowerCase().contains(other.toLowerCase()); | ||
} | ||
} |
Oops, something went wrong.