Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
Convert project to recommended lints
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Jan 20, 2022
1 parent ae1b6bd commit 1311ffb
Show file tree
Hide file tree
Showing 69 changed files with 1,171 additions and 953 deletions.
32 changes: 29 additions & 3 deletions app/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
analyzer:
errors:
undefined_prefixed_name: ignore
# 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
10 changes: 5 additions & 5 deletions app/lib/add.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ class _AddServerPageState extends State<AddServerPage> {
builder: (context) => AlertDialog(
actions: [
TextButton(
child: Text("disagree").tr(),
child: const Text("disagree").tr(),
onPressed: () => Navigator.of(context).pop(false)),
TextButton(
child: Text("agree").tr(),
child: const Text("agree").tr(),
onPressed: () => Navigator.of(context).pop(true))
],
title: Text("settings.servers.add.title").tr(
title: const Text("settings.servers.add.title").tr(
namedArgs: {"name": server.name, "url": server.url}),
content: Text("settings.servers.add.body").tr(
content: const Text("settings.servers.add.body").tr(
namedArgs: {"name": server.name, "url": server.url}))));
if (shouldAdd!) {
await _serversBox.add(url);
Expand All @@ -57,6 +57,6 @@ class _AddServerPageState extends State<AddServerPage> {

@override
Widget build(BuildContext context) {
return ServersSettingsPage();
return const ServersSettingsPage();
}
}
20 changes: 10 additions & 10 deletions app/lib/app_module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ class AppModule extends Module {
// Provide all the routes for your module
@override
final List<ModularRoute> routes = [
ChildRoute('/', child: (_, args) => MyHomePage(), children: [
ChildRoute('/', child: (_, args) => const MyHomePage(), children: [
...HomeRoutes.values.map((e) => ChildRoute(e.route,
child: (_, __) => e.widget, transition: TransitionType.fadeIn)),
WildcardRoute(child: (_, __) => ErrorDisplay())
WildcardRoute(child: (_, __) => const ErrorDisplay())
]),
WildcardRoute(child: (_, __) => ErrorDisplay()),
WildcardRoute(child: (_, __) => const ErrorDisplay()),
ModuleRoute('/editor', module: EditorModule()),
ModuleRoute('/backends', module: BackendsModule()),
ModuleRoute('/articles', module: ArticlesModule()),
ModuleRoute('/settings', module: SettingsModule()),
ModuleRoute('/courses', module: CourseModule()),
ChildRoute('/error', child: (_, args) => ErrorDisplay()),
ChildRoute('/error', child: (_, args) => const ErrorDisplay()),
ChildRoute('/add',
child: (_, args) => AddServerPage(url: args.queryParams['url']!)),
];
Expand Down Expand Up @@ -64,17 +64,17 @@ extension HomeRoutesExtension on HomeRoutes {
Widget get widget {
switch (this) {
case HomeRoutes.home:
return HomePage();
return const HomePage();
case HomeRoutes.backends:
return BackendsPage();
return const BackendsPage();
case HomeRoutes.articles:
return ArticlesPage();
return const ArticlesPage();
case HomeRoutes.courses:
return CoursesPage();
return const CoursesPage();
case HomeRoutes.editor:
return EditorPage();
return const EditorPage();
case HomeRoutes.settings:
return SettingsPage();
return const SettingsPage();
}
}

Expand Down
38 changes: 20 additions & 18 deletions app/lib/app_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ import 'package:phosphor_flutter/phosphor_flutter.dart';
import 'themes/theme.dart';

class AppWidget extends StatelessWidget {
const AppWidget({Key? key}) : super(key: key);

// This widget is the root of your application.
@override
Widget build(BuildContext context) {
// var locale = Hive.box('appearance').get('locale', defaultValue: 'default');
//if (locale != 'default') context.locale = Locale.fromSubtags(scriptCode: locale);
return EasyLocalization(
supportedLocales: [Locale('en'), Locale('de'), Locale('fr')],
supportedLocales: const [Locale('en'), Locale('de'), Locale('fr')],
path: 'translations',
fallbackLocale: Locale('en'),
fallbackLocale: const Locale('en'),
useOnlyLangCode: true,
child: ValueListenableBuilder(
valueListenable: Hive.box('appearance').listenable(),
Expand All @@ -28,18 +30,18 @@ class AppWidget extends StatelessWidget {
title: 'Dev-Doctor',
localizationsDelegates: [
...context.localizationDelegates,
LocaleNamesLocalizationsDelegate()
const LocaleNamesLocalizationsDelegate()
],
supportedLocales: context.supportedLocales,
locale: context.locale,
themeMode: ThemeMode.values[box.get('theme', defaultValue: 0)],
debugShowCheckedModeBanner: false,
builder: (context, widget) {
ErrorWidget.builder = (FlutterErrorDetails errorDetails) {
return ErrorDisplay();
return const ErrorDisplay();
};

return widget ?? ErrorDisplay();
return widget ?? const ErrorDisplay();
},
theme: ThemeData(
// This is the theme of your application.
Expand Down Expand Up @@ -79,7 +81,7 @@ class AppWidget extends StatelessWidget {
// the app on. For desktop platforms, the controls will be smaller and
// closer together (more dense) than on mobile platforms.
visualDensity: VisualDensity.adaptivePlatformDensity),
home: MyHomePage(),
home: const MyHomePage(),
).modular();
}));
}
Expand Down Expand Up @@ -116,33 +118,33 @@ class _MyHomePageState extends State<MyHomePage> {
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
backgroundColor: Theme.of(context).primaryColor,
activeIcon: Icon(PhosphorIcons.houseFill),
icon: Icon(PhosphorIcons.houseLight),
activeIcon: const Icon(PhosphorIcons.houseFill),
icon: const Icon(PhosphorIcons.houseLight),
label: 'home'.tr()),
BottomNavigationBarItem(
backgroundColor: Theme.of(context).primaryColor,
activeIcon: Icon(PhosphorIcons.storefrontFill),
icon: Icon(PhosphorIcons.storefrontLight),
activeIcon: const Icon(PhosphorIcons.storefrontFill),
icon: const Icon(PhosphorIcons.storefrontLight),
label: 'backends.title'.tr()),
BottomNavigationBarItem(
backgroundColor: Theme.of(context).primaryColor,
activeIcon: Icon(PhosphorIcons.articleFill),
icon: Icon(PhosphorIcons.articleLight),
activeIcon: const Icon(PhosphorIcons.articleFill),
icon: const Icon(PhosphorIcons.articleLight),
label: 'articles.title'.tr()),
BottomNavigationBarItem(
backgroundColor: Theme.of(context).primaryColor,
activeIcon: Icon(PhosphorIcons.graduationCapFill),
icon: Icon(PhosphorIcons.graduationCapLight),
activeIcon: const Icon(PhosphorIcons.graduationCapFill),
icon: const Icon(PhosphorIcons.graduationCapLight),
label: 'courses.title'.tr()),
BottomNavigationBarItem(
backgroundColor: Theme.of(context).primaryColor,
activeIcon: Icon(PhosphorIcons.pencilFill),
icon: Icon(PhosphorIcons.pencilLight),
activeIcon: const Icon(PhosphorIcons.pencilFill),
icon: const Icon(PhosphorIcons.pencilLight),
label: 'editor.title'.tr()),
BottomNavigationBarItem(
backgroundColor: Theme.of(context).primaryColor,
activeIcon: Icon(PhosphorIcons.gearFill),
icon: Icon(PhosphorIcons.gearLight),
activeIcon: const Icon(PhosphorIcons.gearFill),
icon: const Icon(PhosphorIcons.gearLight),
label: 'settings.title'.tr())
],
unselectedItemColor: Theme.of(context).unselectedWidgetColor,
Expand Down
9 changes: 6 additions & 3 deletions app/lib/articles/bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ArticleBloc extends Disposable {
bool error = false;

bool get hasError => error;
CoursePartBloc() {}
ArticleBloc();
Future<void> fetch(
{ServerEditorBloc? editorBloc,
String? server,
Expand All @@ -27,11 +27,12 @@ class ArticleBloc extends Disposable {
: await CoursesServer.fetch(index: serverId, url: server);
if (editorBloc == null &&
!(currentServer?.added ?? false) &&
server != null)
server != null) {
Modular.to.pushNamed(Uri(
pathSegments: ["", "add"],
queryParameters: {"url": server, "redirect": Modular.to.path})
.toString());
}
if (articleId != null) article = currentServer?.articles[articleId];
this.article = article;
var current = article == null
Expand All @@ -42,7 +43,9 @@ class ArticleBloc extends Disposable {
articleSubject.add(current ?? Article(slug: ''));
if (current == null) error = true;
} catch (e) {
print("Error $e");
if (kDebugMode) {
print("Error $e");
}
error = true;
}
}
Expand Down
Loading

1 comment on commit 1311ffb

@vercel
Copy link

@vercel vercel bot commented on 1311ffb Jan 20, 2022

Choose a reason for hiding this comment

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

Please sign in to comment.