Skip to content

Commit

Permalink
Remove unnecessary key in widget constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
petlyh committed Nov 7, 2024
1 parent b85fe4a commit 0963725
Show file tree
Hide file tree
Showing 28 changed files with 30 additions and 41 deletions.
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void registerKanjivgLicense() => LicenseRegistry.addLicense(() async* {
});

class JsDictApp extends StatelessWidget {
const JsDictApp({super.key});
const JsDictApp();

static const _mainColor = Color(0xFF27CA27);

Expand Down
2 changes: 1 addition & 1 deletion lib/screens/kanji_details/compound_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import "package:jsdict/packages/rounded_bottom_border.dart";
import "package:jsdict/screens/word_details/word_details_screen.dart";

class CompoundList extends StatelessWidget {
const CompoundList(this.type, this.compounds, {super.key});
const CompoundList(this.type, this.compounds);

final String type;
final List<Compound> compounds;
Expand Down
4 changes: 2 additions & 2 deletions lib/screens/kanji_details/kanji_details_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import "package:jsdict/widgets/link_popup.dart";
import "package:jsdict/widgets/link_span.dart";

class KanjiDetailsScreen extends StatelessWidget {
const KanjiDetailsScreen(Kanji this.kanji, {super.key}) : kanjiId = null;
const KanjiDetailsScreen.id(String this.kanjiId, {super.key}) : kanji = null;
const KanjiDetailsScreen(Kanji this.kanji) : kanjiId = null;
const KanjiDetailsScreen.id(String this.kanjiId) : kanji = null;

final Kanji? kanji;
final String? kanjiId;
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/kanji_details/stroke_diagram.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "package:jsdict/packages/stroke_order_diagram.dart";
import "package:jsdict/widgets/future_loader.dart";

class StrokeDiagramWidget extends StatelessWidget {
const StrokeDiagramWidget(this.kanjiCode, {super.key});
const StrokeDiagramWidget(this.kanjiCode);

final String kanjiCode;

Expand Down
2 changes: 1 addition & 1 deletion lib/screens/name_details_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import "package:jsdict/widgets/link_popup.dart";
import "package:jsdict/widgets/wikipedia.dart";

class NameDetailsScreen extends StatelessWidget {
const NameDetailsScreen(this.name, {super.key});
const NameDetailsScreen(this.name);

final Name name;

Expand Down
2 changes: 1 addition & 1 deletion lib/screens/search/result_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import "package:jsdict/widgets/link_span.dart";
import "package:provider/provider.dart";

class ResultPageScreen<T extends ResultType> extends StatelessWidget {
const ResultPageScreen({super.key, required this.query});
const ResultPageScreen({required this.query});

final String query;

Expand Down
2 changes: 1 addition & 1 deletion lib/screens/search/search_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import "package:jsdict/screens/settings_screen.dart";
import "package:provider/provider.dart";

class SearchScreen extends HookWidget {
const SearchScreen({super.key});
const SearchScreen();

static const _placeholder = Center(
child: Text("JS-Dict", style: TextStyle(fontSize: 32)),
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/search_options/radical_search_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "package:jsdict/providers/query_provider.dart";
import "package:jsdict/screens/search_options/search_options_screen.dart";

class RadicalSearchScreen extends SearchOptionsScreen {
const RadicalSearchScreen({super.key}) : super(body: const _RadicalSearch());
const RadicalSearchScreen() : super(body: const _RadicalSearch());
}

class _RadicalSearch extends HookWidget {
Expand Down
6 changes: 1 addition & 5 deletions lib/screens/search_options/search_options_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import "package:jsdict/jp_text.dart";
import "package:jsdict/providers/query_provider.dart";

class SearchOptionsScreen extends StatelessWidget {
const SearchOptionsScreen({
super.key,
required this.body,
this.floatingActionButton,
});
const SearchOptionsScreen({required this.body, this.floatingActionButton});

final Widget body;
final Widget? floatingActionButton;
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/search_options/tag_selection_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "package:jsdict/screens/search_options/search_options_screen.dart";
import "package:jsdict/widgets/info_chip.dart";

class TagSelectionScreen extends SearchOptionsScreen {
const TagSelectionScreen({super.key})
const TagSelectionScreen()
: super(
body: const _TagSelection(),
floatingActionButton: const _TagFAB(),
Expand Down
6 changes: 2 additions & 4 deletions lib/screens/sentence_details_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ import "package:jsdict/widgets/items/kanji_item.dart";
import "package:jsdict/widgets/link_popup.dart";

class SentenceDetailsScreen extends StatelessWidget {
const SentenceDetailsScreen(Sentence this.sentence, {super.key})
: sentenceId = null;
const SentenceDetailsScreen.id(String this.sentenceId, {super.key})
: sentence = null;
const SentenceDetailsScreen(Sentence this.sentence) : sentenceId = null;
const SentenceDetailsScreen.id(String this.sentenceId) : sentence = null;

final Sentence? sentence;
final String? sentenceId;
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "package:package_info_plus/package_info_plus.dart";
import "package:provider/provider.dart";

class SettingScreen extends StatelessWidget {
const SettingScreen({super.key});
const SettingScreen();

@override
Widget build(BuildContext context) {
Expand Down
1 change: 0 additions & 1 deletion lib/screens/word_details/definition_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import "package:jsdict/widgets/link_span.dart";
class DefinitionTile extends StatelessWidget {
const DefinitionTile(
this.definition, {
super.key,
this.textColor,
this.isLast = false,
});
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/word_details/inflection_table.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "package:jsdict/packages/inflection.dart";
import "package:ruby_text/ruby_text.dart";

class InflectionTable extends StatelessWidget {
const InflectionTable(this.data, {super.key});
const InflectionTable(this.data);

final InflectionData data;

Expand Down
6 changes: 3 additions & 3 deletions lib/screens/word_details/word_details_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ import "package:jsdict/widgets/link_popup.dart";
import "package:jsdict/widgets/wikipedia.dart";

class WordDetailsScreen extends StatelessWidget {
const WordDetailsScreen(String this.wordInput, {super.key})
const WordDetailsScreen(String this.wordInput)
: preloadedWord = null,
isSearch = false;

const WordDetailsScreen.preload(Word this.preloadedWord, {super.key})
const WordDetailsScreen.preload(Word this.preloadedWord)
: wordInput = null,
isSearch = false;

const WordDetailsScreen.search(String this.wordInput, {super.key})
const WordDetailsScreen.search(String this.wordInput)
: preloadedWord = null,
isSearch = true;

Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/action_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ void showActionDialog(BuildContext context, List<ActionTile> actions) =>
);

class ActionTile extends StatelessWidget {
const ActionTile.text(this.name, this.data, {super.key}) : isURL = false;
const ActionTile.text(this.name, this.data) : isURL = false;

const ActionTile.url(this.data, {super.key})
const ActionTile.url(this.data)
: isURL = true,
name = "Link";

Expand Down
1 change: 0 additions & 1 deletion lib/widgets/copyable_furigana_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import "package:ruby_text/ruby_text.dart";
class CopyableFuriganaText extends StatelessWidget {
const CopyableFuriganaText(
this.furigana, {
super.key,
this.spacing = 0.0,
this.style,
this.rubyStyle,
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/copyright_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "package:jsdict/widgets/link_span.dart";
import "package:url_launcher/url_launcher.dart";

class CopyrightText extends StatelessWidget {
const CopyrightText(this.copyright, {super.key});
const CopyrightText(this.copyright);

final SentenceCopyright copyright;

Expand Down
3 changes: 1 addition & 2 deletions lib/widgets/error_indicator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import "package:jsdict/packages/jisho_client/failures.dart";
class ErrorIndicator extends StatelessWidget {
const ErrorIndicator(
this.error, {
super.key,
this.stackTrace,
this.onRetry,
this.isCompact = false,
Expand Down Expand Up @@ -80,7 +79,7 @@ void showErrorInfoDialog({
);

class ErrorInfoDialog extends StatelessWidget {
const ErrorInfoDialog(this.error, {super.key, this.stackTrace});
const ErrorInfoDialog(this.error, {this.stackTrace});

final Object error;
final StackTrace? stackTrace;
Expand Down
1 change: 0 additions & 1 deletion lib/widgets/future_loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ final loadingIndicator = Center(

class FutureLoader<T> extends HookWidget {
const FutureLoader({
super.key,
required this.onLoad,
required this.handler,
this.frameBuilder,
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/info_chip.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "package:flutter/material.dart";
import "package:jsdict/jp_text.dart";

class InfoChip extends StatelessWidget {
const InfoChip(this.text, {super.key, this.color, this.onTap, this.icon});
const InfoChip(this.text, {this.color, this.onTap, this.icon});

final String text;
final Color? color;
Expand Down
1 change: 0 additions & 1 deletion lib/widgets/items/item_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import "package:flutter/material.dart";

class ItemCard extends StatelessWidget {
const ItemCard({
super.key,
required this.child,
required this.onTap,
required this.onLongPress,
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/items/kanji_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "package:jsdict/widgets/action_dialog.dart";
import "package:jsdict/widgets/items/item_card.dart";

class KanjiItem extends StatelessWidget {
const KanjiItem({super.key, required this.kanji});
const KanjiItem({required this.kanji});

final Kanji kanji;

Expand Down Expand Up @@ -55,7 +55,7 @@ class KanjiItem extends StatelessWidget {
}

class KanjiItemList extends StatelessWidget {
const KanjiItemList(this.kanjiList, {super.key});
const KanjiItemList(this.kanjiList);

final List<Kanji> kanjiList;

Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/items/name_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "package:jsdict/widgets/action_dialog.dart";
import "package:jsdict/widgets/items/item_card.dart";

class NameItem extends StatelessWidget {
const NameItem({super.key, required this.name});
const NameItem({required this.name});

final Name name;

Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/items/sentence_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import "package:jsdict/widgets/items/item_card.dart";
import "package:ruby_text/ruby_text.dart";

class SentenceItem extends StatelessWidget {
const SentenceItem({super.key, required this.sentence});
const SentenceItem({required this.sentence});

final Sentence sentence;

Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/items/word_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import "package:jsdict/widgets/items/item_card.dart";
import "package:ruby_text/ruby_text.dart";

class WordItem extends StatelessWidget {
const WordItem({super.key, required this.word});
const WordItem({required this.word});

final Word word;

Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/link_popup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "package:flutter/material.dart";
import "package:url_launcher/url_launcher.dart";

class LinkPopupButton extends StatelessWidget {
const LinkPopupButton(this.data, {super.key});
const LinkPopupButton(this.data);

final List<(String text, String url)> data;

Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/wikipedia.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "package:jsdict/models/models.dart";
import "package:url_launcher/url_launcher.dart";

class WikipediaWidget extends StatelessWidget {
const WikipediaWidget(this.wikipedia, {super.key});
const WikipediaWidget(this.wikipedia);

final WikipediaInfo wikipedia;

Expand Down

0 comments on commit 0963725

Please sign in to comment.