diff --git a/example/.gitignore b/example/.gitignore index b142d3f..9394988 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -67,3 +67,4 @@ !**/ios/**/default.pbxuser !**/ios/**/default.perspectivev3 !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages +.flutter-plugins-dependencies diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 6e40137..08e7c32 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -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' @@ -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" diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 9ce586c..8ceca13 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,11 +1,12 @@ + =2.1.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: flutter: diff --git a/lib/src/ansi_parser.dart b/lib/src/ansi_parser.dart index cf02642..66fe606 100644 --- a/lib/src/ansi_parser.dart +++ b/lib/src/ansi_parser.dart @@ -7,17 +7,17 @@ class AnsiParser { AnsiParser(this.dark); - Color foreground; - Color background; - List spans; + Color? foreground; + Color? background; + List? spans; void parse(String s) { spans = []; var state = TEXT; - StringBuffer buffer; + StringBuffer? buffer; var text = StringBuffer(); var code = 0; - List codes; + late List codes; for (var i = 0, n = s.length; i < n; i++) { var c = s[i]; @@ -35,7 +35,7 @@ class AnsiParser { break; case BRACKET: - buffer.write(c); + buffer!.write(c); if (c == '[') { state = CODE; } else { @@ -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; @@ -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; @@ -72,7 +72,7 @@ class AnsiParser { } } - spans.add(createSpan(text.toString())); + spans!.add(createSpan(text.toString())); } void handleCodes(List codes) { @@ -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]; diff --git a/lib/src/log_console.dart b/lib/src/log_console.dart index e7042bd..11e4bb7 100644 --- a/lib/src/log_console.dart +++ b/lib/src/log_console.dart @@ -8,7 +8,7 @@ class LogConsole extends StatefulWidget { LogConsole({this.dark = false, this.showCloseButton = false}); - static Future open(BuildContext context, {bool dark}) async { + static Future open(BuildContext context, {bool? dark}) async { var logConsole = LogConsole( showCloseButton: true, dark: dark ?? Theme.of(context).brightness == Brightness.dark, @@ -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); @@ -50,7 +50,7 @@ class _LogConsoleState extends State { var _scrollController = ScrollController(); var _filterController = TextEditingController(); - Level _filterLevel = Level.verbose; + Level? _filterLevel = Level.verbose; double _logFontSize = 14; var _currentId = 0; @@ -63,7 +63,8 @@ class _LogConsoleState extends State { _scrollController.addListener(() { if (!_scrollListenerEnabled) return; - var scrolledToBottom = _scrollController.offset >= _scrollController.position.maxScrollExtent; + var scrolledToBottom = _scrollController.offset >= + _scrollController.position.maxScrollExtent; setState(() { _followBottom = scrolledToBottom; }); @@ -83,7 +84,7 @@ class _LogConsoleState extends State { 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) { @@ -261,7 +262,7 @@ class _LogConsoleState extends State { value: Level.wtf, ) ], - onChanged: (value) { + onChanged: (dynamic value) { _filterLevel = value; _refreshFilter(); }, @@ -302,8 +303,8 @@ class _LogConsoleState extends State { } class LogBar extends StatelessWidget { - final bool dark; - final Widget child; + final bool? dark; + final Widget? child; LogBar({this.dark, this.child}); @@ -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, + color: dark! ? Colors.blueGrey[900] : Colors.white, child: Padding( padding: EdgeInsets.fromLTRB(15, 8, 15, 8), child: child, diff --git a/lib/src/log_console_on_shake.dart b/lib/src/log_console_on_shake.dart index 3469244..317e2dc 100644 --- a/lib/src/log_console_on_shake.dart +++ b/lib/src/log_console_on_shake.dart @@ -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, }); @@ -16,7 +16,7 @@ class LogConsoleOnShake extends StatefulWidget { } class _LogConsoleOnShakeState extends State { - ShakeDetector _detector; + late ShakeDetector _detector; bool _open = false; @override diff --git a/lib/src/shake_detector.dart b/lib/src/shake_detector.dart index 86e24b0..2e51202 100644 --- a/lib/src/shake_detector.dart +++ b/lib/src/shake_detector.dart @@ -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; @@ -19,7 +19,7 @@ class ShakeDetector { int lastShakeTimestamp = DateTime.now().millisecondsSinceEpoch; - StreamSubscription streamSubscription; + StreamSubscription? streamSubscription; ShakeDetector({ this.onPhoneShake, @@ -53,7 +53,7 @@ class ShakeDetector { lastShakeTimestamp = now; if (++shakeCount >= minShakeCount) { shakeCount = 0; - onPhoneShake(); + onPhoneShake!(); } } }); @@ -62,7 +62,7 @@ class ShakeDetector { /// Stops listening to accelerometer events void stopListening() { if (streamSubscription != null) { - streamSubscription.cancel(); + streamSubscription!.cancel(); } } } diff --git a/pubspec.yaml b/pubspec.yaml index 088827e..a132353 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,11 +5,11 @@ author: Simon Leier 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 \ No newline at end of file + sensors: 2.0.3 \ No newline at end of file