Skip to content

Commit

Permalink
Merge pull request #815 from dkaera/feature/analyzer_issues
Browse files Browse the repository at this point in the history
Analyzer issues
  • Loading branch information
dkaera committed Mar 19, 2024
2 parents a618e06 + f2a954f commit 5658ea0
Show file tree
Hide file tree
Showing 16 changed files with 372 additions and 211 deletions.
28 changes: 28 additions & 0 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at https://dart.dev/lints.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
27 changes: 19 additions & 8 deletions example/lib/database.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 12 additions & 14 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Future<void> main() async {
class FloorApp extends StatelessWidget {
final TaskDao dao;

const FloorApp(this.dao);
const FloorApp(this.dao, {super.key});

@override
Widget build(BuildContext context) {
Expand All @@ -37,10 +37,10 @@ class TasksWidget extends StatefulWidget {
final TaskDao dao;

const TasksWidget({
Key? key,
super.key,
required this.title,
required this.dao,
}) : super(key: key);
});

@override
State<StatefulWidget> createState() => TasksWidgetState();
Expand Down Expand Up @@ -100,18 +100,17 @@ class TasksWidgetState extends State<TasksWidget> {
}

TaskStatus _getMenuType(int index) => TaskStatus.values[index - 1];

}

class TasksListView extends StatelessWidget {
final TaskDao dao;
final TaskStatus? selectedType;

const TasksListView({
Key? key,
super.key,
required this.dao,
required this.selectedType,
}) : super(key: key);
});

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -145,10 +144,10 @@ class TaskListCell extends StatelessWidget {
final TaskDao dao;

const TaskListCell({
Key? key,
super.key,
required this.task,
required this.dao,
}) : super(key: key);
});

@override
Widget build(BuildContext context) {
Expand All @@ -158,22 +157,22 @@ class TaskListCell extends StatelessWidget {
padding: const EdgeInsets.only(left: 16),
color: Colors.green,
child: const Align(
alignment: Alignment.centerLeft,
child: Text(
'Change status',
style: TextStyle(color: Colors.white),
),
alignment: Alignment.centerLeft,
),
),
secondaryBackground: Container(
padding: const EdgeInsets.only(right: 16),
color: Colors.red,
child: const Align(
alignment: Alignment.centerRight,
child: Text(
'Delete',
style: TextStyle(color: Colors.white),
),
alignment: Alignment.centerRight,
),
),
direction: DismissDirection.horizontal,
Expand Down Expand Up @@ -202,7 +201,7 @@ class TaskListCell extends StatelessWidget {
break;
}

if (statusMessage != null) {
if (statusMessage != null && context.mounted) {
final scaffoldMessengerState = ScaffoldMessenger.of(context);
scaffoldMessengerState.hideCurrentSnackBar();
scaffoldMessengerState.showSnackBar(
Expand All @@ -220,10 +219,9 @@ class TasksTextField extends StatelessWidget {
final TaskDao dao;

TasksTextField({
Key? key,
super.key,
required this.dao,
}) : _textEditingController = TextEditingController(),
super(key: key);
}) : _textEditingController = TextEditingController();

@override
Widget build(BuildContext context) {
Expand Down
Loading

0 comments on commit 5658ea0

Please sign in to comment.