Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,4 @@
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
.flutter-plugins-dependencies
4 changes: 2 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 28
compileSdkVersion 31

lintOptions {
disable 'InvalidPackage'
Expand All @@ -36,7 +36,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.github.leisim.example"
minSdkVersion 16
targetSdkVersion 28
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand Down
3 changes: 2 additions & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.leisim.example">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:name="io.flutter.app.FlutterApplication"
android:label="example"
android:icon="@drawable/ic_launcher">
<activity
android:name=".MainActivity"
android:name="io.flutter.embedding.android.FlutterActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Demonstrates how to use the logger_flutter plugin.
publish_to: 'none'

environment:
sdk: ">=2.1.0 <3.0.0"
sdk: '>=2.12.0 <3.0.0'

dependencies:
flutter:
Expand Down
20 changes: 10 additions & 10 deletions lib/src/ansi_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ class AnsiParser {

AnsiParser(this.dark);

Color foreground;
Color background;
List<TextSpan> spans;
Color? foreground;
Color? background;
List<TextSpan>? spans;

void parse(String s) {
spans = [];
var state = TEXT;
StringBuffer buffer;
StringBuffer? buffer;
var text = StringBuffer();
var code = 0;
List<int> codes;
late List<int> codes;

for (var i = 0, n = s.length; i < n; i++) {
var c = s[i];
Expand All @@ -35,7 +35,7 @@ class AnsiParser {
break;

case BRACKET:
buffer.write(c);
buffer!.write(c);
if (c == '[') {
state = CODE;
} else {
Expand All @@ -45,7 +45,7 @@ class AnsiParser {
break;

case CODE:
buffer.write(c);
buffer!.write(c);
var codeUnit = c.codeUnitAt(0);
if (codeUnit >= 48 && codeUnit <= 57) {
code = code * 10 + codeUnit - 48;
Expand All @@ -56,7 +56,7 @@ class AnsiParser {
continue;
} else {
if (text.isNotEmpty) {
spans.add(createSpan(text.toString()));
spans!.add(createSpan(text.toString()));
text.clear();
}
state = TEXT;
Expand All @@ -72,7 +72,7 @@ class AnsiParser {
}
}

spans.add(createSpan(text.toString()));
spans!.add(createSpan(text.toString()));
}

void handleCodes(List<int> codes) {
Expand All @@ -99,7 +99,7 @@ class AnsiParser {
}
}

Color getColor(int colorCode, bool foreground) {
Color? getColor(int colorCode, bool foreground) {
switch (colorCode) {
case 12:
return dark ? Colors.lightBlue[300] : Colors.indigo[700];
Expand Down
23 changes: 12 additions & 11 deletions lib/src/log_console.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class LogConsole extends StatefulWidget {

LogConsole({this.dark = false, this.showCloseButton = false});

static Future<void> open(BuildContext context, {bool dark}) async {
static Future<void> open(BuildContext context, {bool? dark}) async {
var logConsole = LogConsole(
showCloseButton: true,
dark: dark ?? Theme.of(context).brightness == Brightness.dark,
Expand All @@ -24,7 +24,7 @@ class LogConsole extends StatefulWidget {
}

static void add(OutputEvent outputEvent, {int bufferSize = 20}) {
while (_outputEventBuffer.length >= (bufferSize ?? 1)) {
while (_outputEventBuffer.length >= (bufferSize)) {
_outputEventBuffer.removeFirst();
}
_outputEventBuffer.add(outputEvent);
Expand All @@ -50,7 +50,7 @@ class _LogConsoleState extends State<LogConsole> {
var _scrollController = ScrollController();
var _filterController = TextEditingController();

Level _filterLevel = Level.verbose;
Level? _filterLevel = Level.verbose;
double _logFontSize = 14;

var _currentId = 0;
Expand All @@ -63,7 +63,8 @@ class _LogConsoleState extends State<LogConsole> {

_scrollController.addListener(() {
if (!_scrollListenerEnabled) return;
var scrolledToBottom = _scrollController.offset >= _scrollController.position.maxScrollExtent;
var scrolledToBottom = _scrollController.offset >=
_scrollController.position.maxScrollExtent;
setState(() {
_followBottom = scrolledToBottom;
});
Expand All @@ -83,7 +84,7 @@ class _LogConsoleState extends State<LogConsole> {

void _refreshFilter() {
var newFilteredBuffer = _renderedBuffer.where((it) {
var logLevelMatches = it.level.index >= _filterLevel.index;
var logLevelMatches = it.level.index >= _filterLevel!.index;
if (!logLevelMatches) {
return false;
} else if (_filterController.text.isNotEmpty) {
Expand Down Expand Up @@ -261,7 +262,7 @@ class _LogConsoleState extends State<LogConsole> {
value: Level.wtf,
)
],
onChanged: (value) {
onChanged: (dynamic value) {
_filterLevel = value;
_refreshFilter();
},
Expand Down Expand Up @@ -302,8 +303,8 @@ class _LogConsoleState extends State<LogConsole> {
}

class LogBar extends StatelessWidget {
final bool dark;
final Widget child;
final bool? dark;
final Widget? child;

LogBar({this.dark, this.child});

Expand All @@ -314,15 +315,15 @@ class LogBar extends StatelessWidget {
child: Container(
decoration: BoxDecoration(
boxShadow: [
if (!dark)
if (!dark!)
BoxShadow(
color: Colors.grey[400],
color: Colors.grey[400]!,
blurRadius: 3,
),
],
),
child: Material(
color: dark ? Colors.blueGrey[900] : Colors.white,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let’s make dark required or pass a default default value while initialisation

color: dark! ? Colors.blueGrey[900] : Colors.white,
child: Padding(
padding: EdgeInsets.fromLTRB(15, 8, 15, 8),
child: child,
Expand Down
6 changes: 3 additions & 3 deletions lib/src/log_console_on_shake.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ part of logger_flutter;

class LogConsoleOnShake extends StatefulWidget {
final Widget child;
final bool dark;
final bool? dark;
final bool debugOnly;

LogConsoleOnShake({
@required this.child,
required this.child,
this.dark,
this.debugOnly = true,
});
Expand All @@ -16,7 +16,7 @@ class LogConsoleOnShake extends StatefulWidget {
}

class _LogConsoleOnShakeState extends State<LogConsoleOnShake> {
ShakeDetector _detector;
late ShakeDetector _detector;
bool _open = false;

@override
Expand Down
8 changes: 4 additions & 4 deletions lib/src/shake_detector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
import 'package:sensors/sensors.dart';

class ShakeDetector {
final VoidCallback onPhoneShake;
final VoidCallback? onPhoneShake;

final double shakeThresholdGravity;

Expand All @@ -19,7 +19,7 @@ class ShakeDetector {

int lastShakeTimestamp = DateTime.now().millisecondsSinceEpoch;

StreamSubscription streamSubscription;
StreamSubscription? streamSubscription;

ShakeDetector({
this.onPhoneShake,
Expand Down Expand Up @@ -53,7 +53,7 @@ class ShakeDetector {
lastShakeTimestamp = now;
if (++shakeCount >= minShakeCount) {
shakeCount = 0;
onPhoneShake();
onPhoneShake!();
}
}
});
Expand All @@ -62,7 +62,7 @@ class ShakeDetector {
/// Stops listening to accelerometer events
void stopListening() {
if (streamSubscription != null) {
streamSubscription.cancel();
streamSubscription!.cancel();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be replaced with streamSubscription?.cancel()

}
}
}
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ author: Simon Leier <simonleier@gmail.com>
homepage: https://github.com/leisim/logger_flutter

environment:
sdk: ">=2.2.2 <3.0.0"
sdk: '>=2.12.0 <3.0.0'

dependencies:
flutter:
sdk: flutter

logger: ">=1.0.0"
sensors: ^0.4.2+4

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aren’t we using sensors_plus?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have yet to try that, will update on this

sensors: 2.0.3