Skip to content
This repository has been archived by the owner on Feb 11, 2025. It is now read-only.

Commit

Permalink
chore(dx): add linter options
Browse files Browse the repository at this point in the history
  • Loading branch information
abhigyantrips committed Mar 3, 2024
1 parent aa58dc9 commit 43b220a
Show file tree
Hide file tree
Showing 18 changed files with 132 additions and 181 deletions.
30 changes: 3 additions & 27 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,5 @@
# 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-lang.github.io/linter/lints/index.html.
#
# 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
- always_use_package_imports
- directives_ordering
- prefer_single_quotes
2 changes: 1 addition & 1 deletion lib/controllers/post_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:noticeboard/repositories/post_repo.dart';

class PostController extends GetxController {
final PostRepo _repo = PostRepo();
final posts = Posts(ms: 0, query: "", result: []).obs;
final posts = Posts(ms: 0, query: '', result: []).obs;
Future fetchPosts() async {
var temp = await _repo.getPosts();
if (temp.result.isNotEmpty) {
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class MainApp extends StatelessWidget {
return GetMaterialApp(
debugShowCheckedModeBanner: false,
title: 'Notice Board',
theme: ThemeData(primarySwatch: primaryBlack, fontFamily: "Lufga"),
theme: ThemeData(primarySwatch: primaryBlack, fontFamily: 'Lufga'),
home: const TabNavigator());
}
}
Expand Down
100 changes: 50 additions & 50 deletions lib/models/Post.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ class Posts {
List<Result> result;

factory Posts.fromJson(Map<String, dynamic> json) => Posts(
ms: json["ms"],
query: json["query"],
result: List<Result>.from(json["result"].map((x) => Result.fromJson(x))),
ms: json['ms'],
query: json['query'],
result: List<Result>.from(json['result'].map((x) => Result.fromJson(x))),
);

Map<String, dynamic> toJson() => {
"ms": ms,
"query": query,
"result": List<dynamic>.from(result.map((x) => x.toJson())),
'ms': ms,
'query': query,
'result': List<dynamic>.from(result.map((x) => x.toJson())),
};
}

Expand Down Expand Up @@ -74,45 +74,45 @@ class Result {
String title;

factory Result.fromJson(Map<String, dynamic> json) => Result(
imageUrl: json["ImageUrl"],
published: json["Published"],
createdAt: DateTime.parse(json["_createdAt"]),
id: json["_id"],
rev: json["_rev"],
type: json["_type"],
updatedAt: DateTime.parse(json["_updatedAt"]),
date: DateTime.parse(json["date"]),
endTime: DateTime.parse(json["endTime"]),
longDescription: json["longDescription"],
mainImage: MainImage.fromJson(json["mainImage"]),
order: json["order"],
publishedAt: DateTime.parse(json["publishedAt"]),
redirect: json["redirect"],
shortDescription: json["shortDescription"],
startTime: DateTime.parse(json["startTime"]),
tags: List<String>.from(json["tags"].map((x) => x)),
title: json["title"],
imageUrl: json['ImageUrl'],
published: json['Published'],
createdAt: DateTime.parse(json['_createdAt']),
id: json['_id'],
rev: json['_rev'],
type: json['_type'],
updatedAt: DateTime.parse(json['_updatedAt']),
date: DateTime.parse(json['date']),
endTime: DateTime.parse(json['endTime']),
longDescription: json['longDescription'],
mainImage: MainImage.fromJson(json['mainImage']),
order: json['order'],
publishedAt: DateTime.parse(json['publishedAt']),
redirect: json['redirect'],
shortDescription: json['shortDescription'],
startTime: DateTime.parse(json['startTime']),
tags: List<String>.from(json['tags'].map((x) => x)),
title: json['title'],
);

Map<String, dynamic> toJson() => {
"ImageUrl": imageUrl,
"Published": published,
"_createdAt": createdAt.toIso8601String(),
"_id": id,
"_rev": rev,
"_type": type,
"_updatedAt": updatedAt.toIso8601String(),
"date": "${date.year.toString().padLeft(4, '0')}-${date.month.toString().padLeft(2, '0')}-${date.day.toString().padLeft(2, '0')}",
"endTime": endTime.toIso8601String(),
"longDescription": longDescription,
"mainImage": mainImage.toJson(),
"order": order,
"publishedAt": publishedAt.toIso8601String(),
"redirect": redirect,
"shortDescription": shortDescription,
"startTime": startTime.toIso8601String(),
"tags": List<dynamic>.from(tags.map((x) => x)),
"title": title,
'ImageUrl': imageUrl,
'Published': published,
'_createdAt': createdAt.toIso8601String(),
'_id': id,
'_rev': rev,
'_type': type,
'_updatedAt': updatedAt.toIso8601String(),
'date': "${date.year.toString().padLeft(4, '0')}-${date.month.toString().padLeft(2, '0')}-${date.day.toString().padLeft(2, '0')}",
'endTime': endTime.toIso8601String(),
'longDescription': longDescription,
'mainImage': mainImage.toJson(),
'order': order,
'publishedAt': publishedAt.toIso8601String(),
'redirect': redirect,
'shortDescription': shortDescription,
'startTime': startTime.toIso8601String(),
'tags': List<dynamic>.from(tags.map((x) => x)),
'title': title,
};
}

Expand All @@ -126,13 +126,13 @@ class MainImage {
Asset asset;

factory MainImage.fromJson(Map<String, dynamic> json) => MainImage(
type: json["_type"],
asset: Asset.fromJson(json["asset"]),
type: json['_type'],
asset: Asset.fromJson(json['asset']),
);

Map<String, dynamic> toJson() => {
"_type": type,
"asset": asset.toJson(),
'_type': type,
'asset': asset.toJson(),
};
}

Expand All @@ -146,12 +146,12 @@ class Asset {
String type;

factory Asset.fromJson(Map<String, dynamic> json) => Asset(
ref: json["_ref"],
type: json["_type"],
ref: json['_ref'],
type: json['_type'],
);

Map<String, dynamic> toJson() => {
"_ref": ref,
"_type": type,
'_ref': ref,
'_type': type,
};
}
76 changes: 38 additions & 38 deletions lib/models/contributor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,46 +54,46 @@ class Contributor {
int contributions;

factory Contributor.fromJson(Map<String, dynamic> json) => Contributor(
login: json["login"],
id: json["id"],
nodeId: json["node_id"],
avatarUrl: json["avatar_url"],
gravatarId: json["gravatar_id"],
url: json["url"],
htmlUrl: json["html_url"],
followersUrl: json["followers_url"],
followingUrl: json["following_url"],
gistsUrl: json["gists_url"],
starredUrl: json["starred_url"],
subscriptionsUrl: json["subscriptions_url"],
organizationsUrl: json["organizations_url"],
reposUrl: json["repos_url"],
eventsUrl: json["events_url"],
receivedEventsUrl: json["received_events_url"],
type: json["type"],
siteAdmin: json["site_admin"],
contributions: json["contributions"],
login: json['login'],
id: json['id'],
nodeId: json['node_id'],
avatarUrl: json['avatar_url'],
gravatarId: json['gravatar_id'],
url: json['url'],
htmlUrl: json['html_url'],
followersUrl: json['followers_url'],
followingUrl: json['following_url'],
gistsUrl: json['gists_url'],
starredUrl: json['starred_url'],
subscriptionsUrl: json['subscriptions_url'],
organizationsUrl: json['organizations_url'],
reposUrl: json['repos_url'],
eventsUrl: json['events_url'],
receivedEventsUrl: json['received_events_url'],
type: json['type'],
siteAdmin: json['site_admin'],
contributions: json['contributions'],
);

Map<String, dynamic> toJson() => {
"login": login,
"id": id,
"node_id": nodeId,
"avatar_url": avatarUrl,
"gravatar_id": gravatarId,
"url": url,
"html_url": htmlUrl,
"followers_url": followersUrl,
"following_url": followingUrl,
"gists_url": gistsUrl,
"starred_url": starredUrl,
"subscriptions_url": subscriptionsUrl,
"organizations_url": organizationsUrl,
"repos_url": reposUrl,
"events_url": eventsUrl,
"received_events_url": receivedEventsUrl,
"type": type,
"site_admin": siteAdmin,
"contributions": contributions,
'login': login,
'id': id,
'node_id': nodeId,
'avatar_url': avatarUrl,
'gravatar_id': gravatarId,
'url': url,
'html_url': htmlUrl,
'followers_url': followersUrl,
'following_url': followingUrl,
'gists_url': gistsUrl,
'starred_url': starredUrl,
'subscriptions_url': subscriptionsUrl,
'organizations_url': organizationsUrl,
'repos_url': reposUrl,
'events_url': eventsUrl,
'received_events_url': receivedEventsUrl,
'type': type,
'site_admin': siteAdmin,
'contributions': contributions,
};
}
4 changes: 1 addition & 3 deletions lib/models/styles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import 'package:flutter/material.dart';
class Styles {
static ThemeData themeData(bool isDarkTheme, BuildContext context) {
return ThemeData(
primarySwatch: Colors.red,
primaryColor: isDarkTheme ? Colors.black : Colors.white,
backgroundColor: isDarkTheme ? Colors.black : const Color(0xffF1F5FB),
indicatorColor:
isDarkTheme ? const Color(0xff0E1D36) : const Color(0xffCBDCF8),
hintColor:
Expand All @@ -26,7 +24,7 @@ class Styles {
: const ColorScheme.light()),
appBarTheme: const AppBarTheme(
elevation: 0.0,
),
), colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.red).copyWith(background: isDarkTheme ? Colors.black : const Color(0xffF1F5FB)),
);
}
}
2 changes: 1 addition & 1 deletion lib/repositories/contributors_repo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:noticeboard/models/contributor.dart';
class ContributorsRepo {
Future getApiData() async {
var url = Uri.parse(
"https://api.github.com/repos/mitblr-club/noticeboard/contributors");
'https://api.github.com/repos/mitblr-club/noticeboard/contributors');
Response response = await get(url);
if (response.statusCode == 200) {
final List<Contributor> contributors =
Expand Down
2 changes: 1 addition & 1 deletion lib/repositories/post_repo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ class PostRepo {
} catch (_) {
print(_.toString());
}
return Posts(ms: 0, query: "", result: []);
return Posts(ms: 0, query: '', result: []);
}
}
22 changes: 11 additions & 11 deletions lib/views/components/drawer_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ class DrawerView extends StatelessWidget {

Future<void> _launchURL(String url) async {
final Uri uri = Uri(
scheme: "https",
host: "www.docs.google.com",
scheme: 'https',
host: 'www.docs.google.com',
path:
"/forms/d/e/1FAIpQLScV8JBTgLg9eWwk3OdepyzpQd1oXD64dLx2PrPKg37fGN3jfQ/viewform");
'/forms/d/e/1FAIpQLScV8JBTgLg9eWwk3OdepyzpQd1oXD64dLx2PrPKg37fGN3jfQ/viewform');
if (!await launchUrl(
uri,
mode: LaunchMode.externalApplication,
)) {
throw "Can not launch url";
throw 'Can not launch url';
}
}

Expand All @@ -27,7 +27,7 @@ class DrawerView extends StatelessWidget {
DrawerHeader(
decoration: BoxDecoration(
image: DecorationImage(
image: const AssetImage("images/mitBuilding.png"),
image: const AssetImage('images/mitBuilding.png'),
fit: BoxFit.cover,
colorFilter: ColorFilter.mode(
Colors.black.withOpacity(0.4), BlendMode.darken))),
Expand All @@ -47,7 +47,7 @@ class DrawerView extends StatelessWidget {
),
),
title: const Text(
"Contributors",
'Contributors',
style: TextStyle(
color: Colors.white,
fontSize: 20,
Expand All @@ -59,29 +59,29 @@ class DrawerView extends StatelessWidget {
),
ListTile(
leading: IconButton(
onPressed: () => _launchURL(""),
onPressed: () => _launchURL(''),
icon: const Icon(
Icons.open_in_new,
color: Colors.orange,
),
),
title: const Text(
"Feedback",
'Feedback',
style: TextStyle(color: Colors.white, fontSize: 20),
),
onTap: () => _launchURL(""),
onTap: () => _launchURL(''),
),
const SizedBox(
height: 50,
),
const Column(
children: [
Text(
"Brought to you by mitblr.club",
'Brought to you by mitblr.club',
style: TextStyle(color: Colors.grey),
),
Image(
image: AssetImage("images/cxlogo.png"),
image: AssetImage('images/cxlogo.png'),
width: 200,
height: 100,
),
Expand Down
2 changes: 1 addition & 1 deletion lib/views/components/notice_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class _NoticeListState extends State<NoticeList> {
Colors.white),
backgroundColor: MaterialStateProperty.all<Color>(
Colors.orange)),
child: const Text("Read More"),
child: const Text('Read More'),
),
],
)
Expand Down
Loading

0 comments on commit 43b220a

Please sign in to comment.