Skip to content

Commit

Permalink
Fixed linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
prijindal committed May 1, 2024
1 parent 6d68de0 commit 7a50ab4
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 28 deletions.
14 changes: 7 additions & 7 deletions lib/components/habbitform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ class HabbitDialogForm extends StatefulWidget {
required BuildContext context,
required Habbit? habbit,
}) async {
final _habbit = habbit;
if (_habbit == null) {
final habbit0 = habbit;
if (habbit0 == null) {
throw StateError("habbit should not be null");
}
final editedData = await showDialog<Habbit>(
context: context,
builder: (BuildContext context) {
return HabbitDialogForm(
name: _habbit.name,
description: _habbit.description,
config: _habbit.config,
hidden: _habbit.hidden,
name: habbit0.name,
description: habbit0.description,
config: habbit0.config,
hidden: habbit0.hidden,
);
},
);
if (editedData != null) {
editedData.id = _habbit.id;
editedData.id = habbit0.id;
MyDatabase.instance.writeAsync(() {
MyDatabase.instance.add<Habbit>(editedData, update: true);
});
Expand Down
4 changes: 2 additions & 2 deletions lib/components/habbittile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class _HabbitTileState extends State<HabbitTile> {
r'habbit.id == $0 AND deletionTime == nil SORT(creationTime DESC) LIMIT(1)',
[widget.habbit.id]).firstOrNull;
if (lastEntry == null) {
if (context.mounted) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(milliseconds: 100),
Expand All @@ -104,7 +104,7 @@ class _HabbitTileState extends State<HabbitTile> {
await MyDatabase.instance.writeAsync(() {
MyDatabase.instance.delete<HabbitEntry>(lastEntry);
});
if (context.mounted) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(milliseconds: 100),
Expand Down
2 changes: 1 addition & 1 deletion lib/helpers/sync.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Future<void> jsonToDb(String jsonEncoded) async {
});
for (var i = 0; i < entries.length; i++) {
if (entries[i]["id"] is String) {
entries[i]["id"] = new ObjectId().toEJson();
entries[i]["id"] = ObjectId().toEJson();
}
if (entries[i]["creationTime"] is int) {
entries[i]["creationTime"] = toEJson(DateTime.fromMillisecondsSinceEpoch(
Expand Down
10 changes: 0 additions & 10 deletions lib/pages/habbit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,6 @@ class HabbitPageState extends State<HabbitPage> {
_entriesSubscription = query.changes.listen((event) {
setState(() {
_entries = event.results.toList();
print(7 * 24 * 60);
for (var entry in _entries!) {
print(entry.creationTime.toLocal());
print(
DateTime.now()
.toLocal()
.difference(entry.creationTime.toLocal())
.inMinutes,
);
}
});
});
}
Expand Down
7 changes: 3 additions & 4 deletions lib/pages/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ class _MyHomePageState extends State<MyHomePage> {
Future<void> _syncDb() async {
try {
await syncDb();
if (context.mounted) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("Sync successfully"),
),
);
}
} catch (e, stack) {
if (context.mounted) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
Expand All @@ -84,7 +84,7 @@ class _MyHomePageState extends State<MyHomePage> {
if (user != null) {
await _syncDb();
} else {
if (context.mounted) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: const Text("Please login to allow sync"),
Expand Down Expand Up @@ -140,7 +140,6 @@ class _MyHomePageState extends State<MyHomePage> {
// final results = MyDatabase.instance
// .query<HabbitEntry>(r'@count DISTINCT(habbit) LIMIT(3)', []).toList();
// print(results);
// TODO
// final count = MyDatabase.instance.habbitEntry.id.count();
// final query = (MyDatabase.instance.habbitEntry.selectOnly())
// ..addColumns([MyDatabase.instance.habbitEntry.habbit, count])
Expand Down
8 changes: 4 additions & 4 deletions lib/pages/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class _LoginScreenState extends State<LoginScreen> {
Future<void> _signUpUser() async {
try {
final creds = await _getCreds("signup");
if (context.mounted) {
if (mounted) {
Navigator.of(context).pop<UserCredential>(creds);
}
} on FirebaseAuthException catch (e, stack) {
Expand All @@ -46,7 +46,7 @@ class _LoginScreenState extends State<LoginScreen> {
error: e,
stackTrace: stack,
);
if (context.mounted) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(e.message ?? "Error while signing up"),
Expand All @@ -62,7 +62,7 @@ class _LoginScreenState extends State<LoginScreen> {
_isLoading = true;
});
final creds = await _getCreds("login");
if (context.mounted) {
if (mounted) {
Navigator.of(context).pop<UserCredential>(creds);
}
} on FirebaseAuthException catch (e, stack) {
Expand All @@ -74,7 +74,7 @@ class _LoginScreenState extends State<LoginScreen> {
if (e.code == "user-not-found") {
await _signUpUser();
} else {
if (context.mounted) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(e.message ?? "Error while logging in"),
Expand Down

0 comments on commit 7a50ab4

Please sign in to comment.