Skip to content

Commit

Permalink
[Presentation] Migrate to null safety
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed Jun 19, 2021
1 parent 7a06041 commit deed76d
Show file tree
Hide file tree
Showing 162 changed files with 831 additions and 848 deletions.
Expand Up @@ -2,7 +2,7 @@ import '../../enums/ascension_material_summary_type.dart';
import '../../enums/material_type.dart';

class AscensionMaterialsSummary {
final AscensionMaterialSummaryType? type;
final AscensionMaterialSummaryType type;
final List<MaterialSummary> materials;

const AscensionMaterialsSummary({
Expand All @@ -14,7 +14,7 @@ class AscensionMaterialsSummary {
class MaterialSummary {
final String key;
final MaterialType materialType;
final String? fullImagePath;
final String fullImagePath;
final int quantity;
final bool isFromBoss;
final List<int> days;
Expand Down
4 changes: 2 additions & 2 deletions lib/main.dart
Expand Up @@ -28,9 +28,9 @@ Future<void> main() async {
runApp(MyApp());
}

Future<dynamic> _onDidReceiveLocalNotification(int id, String title, String body, String payload) async {}
Future<dynamic> _onDidReceiveLocalNotification(int id, String? title, String? body, String? payload) async {}

Future<void> _onSelectNotification(String json) async {}
Future<void> _onSelectNotification(String? json) async {}

class MyApp extends StatelessWidget {
@override
Expand Down
2 changes: 1 addition & 1 deletion lib/presentation/artifact/artifact_page.dart
Expand Up @@ -166,7 +166,7 @@ class ArtifactPage extends StatelessWidget {
final details = Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(name, style: theme.textTheme.headline5.copyWith(fontWeight: FontWeight.bold, color: Colors.white)),
Text(name, style: theme.textTheme.headline5!.copyWith(fontWeight: FontWeight.bold, color: Colors.white)),
Rarity(stars: rarity, starSize: 25, alignment: MainAxisAlignment.start),
],
);
Expand Down
4 changes: 2 additions & 2 deletions lib/presentation/artifacts/artifacts_page.dart
Expand Up @@ -17,7 +17,7 @@ import 'widgets/artifact_info_card.dart';
class ArtifactsPage extends StatefulWidget {
final bool isInSelectionMode;

static Future<String> forSelection(BuildContext context, {List<String> excludeKeys = const []}) async {
static Future<String?> forSelection(BuildContext context, {List<String> excludeKeys = const []}) async {
final bloc = context.read<ArtifactsBloc>();
bloc.add(ArtifactsEvent.init(excludeKeys: excludeKeys));

Expand All @@ -31,7 +31,7 @@ class ArtifactsPage extends StatefulWidget {
}

const ArtifactsPage({
Key key,
Key? key,
this.isInSelectionMode = false,
}) : super(key: key);

Expand Down
30 changes: 15 additions & 15 deletions lib/presentation/artifacts/widgets/artifact_card.dart
Expand Up @@ -24,12 +24,12 @@ class ArtifactCard extends StatelessWidget {
final bool isInSelectionMode;

const ArtifactCard({
Key key,
@required this.keyName,
@required this.name,
@required this.image,
@required this.rarity,
@required this.bonus,
Key? key,
required this.keyName,
required this.name,
required this.image,
required this.rarity,
required this.bonus,
this.imgWidth = 140,
this.imgHeight = 120,
this.withElevation = true,
Expand All @@ -38,11 +38,11 @@ class ArtifactCard extends StatelessWidget {
super(key: key);

const ArtifactCard.withoutDetails({
Key key,
@required this.keyName,
@required this.name,
@required this.image,
@required this.rarity,
Key? key,
required this.keyName,
required this.name,
required this.image,
required this.rarity,
this.isInSelectionMode = false,
}) : imgWidth = 70,
imgHeight = 60,
Expand All @@ -52,8 +52,8 @@ class ArtifactCard extends StatelessWidget {
super(key: key);

ArtifactCard.item({
Key key,
@required ArtifactCardModel item,
Key? key,
required ArtifactCardModel item,
this.imgWidth = 140,
this.imgHeight = 120,
this.withElevation = true,
Expand Down Expand Up @@ -94,12 +94,12 @@ class ArtifactCard extends StatelessWidget {
? Text(
name,
textAlign: TextAlign.center,
style: theme.textTheme.subtitle1.copyWith(fontWeight: FontWeight.bold, color: Colors.white),
style: theme.textTheme.subtitle1!.copyWith(fontWeight: FontWeight.bold, color: Colors.white),
)
: Text(
name,
textAlign: TextAlign.center,
style: theme.textTheme.subtitle1.copyWith(fontWeight: FontWeight.bold, color: Colors.white),
style: theme.textTheme.subtitle1!.copyWith(fontWeight: FontWeight.bold, color: Colors.white),
overflow: TextOverflow.ellipsis,
),
),
Expand Down
9 changes: 4 additions & 5 deletions lib/presentation/artifacts/widgets/artifact_info_card.dart
Expand Up @@ -8,11 +8,11 @@ import 'package:genshindb/presentation/shared/item_expansion_panel.dart';

class ArtifactInfoCard extends StatelessWidget {
final bool isCollapsed;
final Function(bool) expansionCallback;
final Function(bool)? expansionCallback;

const ArtifactInfoCard({
Key key,
@required this.isCollapsed,
Key? key,
required this.isCollapsed,
this.expansionCallback,
}) : super(key: key);

Expand All @@ -26,7 +26,6 @@ class ArtifactInfoCard extends StatelessWidget {
final hpPercentage = s.translateStatTypeWithoutValue(StatType.hpPercentage);
final atkPercentage = s.translateStatTypeWithoutValue(StatType.atkPercentage);
final atk = s.translateStatTypeWithoutValue(StatType.atk);
final def = s.translateStatTypeWithoutValue(StatType.defPercentage, removeExtraSigns: true);
final defPercentage = s.translateStatTypeWithoutValue(StatType.defPercentage);
final energyRecharge = s.translateStatTypeWithoutValue(StatType.energyRechargePercentage, removeExtraSigns: true);
final elementaryMastery = s.translateStatTypeWithoutValue(StatType.elementaryMastery);
Expand All @@ -39,7 +38,7 @@ class ArtifactInfoCard extends StatelessWidget {
'${s.clock}: $atkPercentage / $defPercentage / $hpPercentage / $energyRecharge / $elementaryMastery',
);
considerations.add(
'${s.goblet}: $atkPercentage / $defPercentage / $hpPercentage / $elementaryMastery / ${s.elementalDmgPercentage} (${s.translateElementType(ElementType.electro)}, ${s.translateElementType(ElementType.hydro)}...)',
'${s.goblet}: $atkPercentage / $defPercentage / $hpPercentage / $elementaryMastery / ${s.physDmgPercentage('').trim()} / ${s.elementalDmgPercentage} (${s.translateElementType(ElementType.electro)}, ${s.translateElementType(ElementType.hydro)}...)',
);
considerations.add(
'${s.crown}: $atkPercentage / $defPercentage / $hpPercentage / $critRate / $critDmg / $elementaryMastery / ${s.healingBonus}',
Expand Down
10 changes: 5 additions & 5 deletions lib/presentation/artifacts/widgets/artifact_stats.dart
Expand Up @@ -4,11 +4,11 @@ import 'package:genshindb/generated/l10n.dart';

class ArtifactStats extends StatelessWidget {
final List<ArtifactCardBonusModel> bonus;
final Color textColor;
final Color? textColor;

const ArtifactStats({
Key key,
@required this.bonus,
Key? key,
required this.bonus,
this.textColor,
}) : super(key: key);

Expand All @@ -28,12 +28,12 @@ class ArtifactStats extends StatelessWidget {
Text(
s.xPieces(b.pieces),
textAlign: TextAlign.center,
style: theme.textTheme.subtitle2.copyWith(fontSize: 14, color: textColor),
style: theme.textTheme.subtitle2!.copyWith(fontSize: 14, color: textColor),
),
Text(
b.bonus,
textAlign: TextAlign.center,
style: theme.textTheme.bodyText2.copyWith(fontSize: 12, color: textColor),
style: theme.textTheme.bodyText2!.copyWith(fontSize: 12, color: textColor),
),
],
),
Expand Down
Expand Up @@ -23,8 +23,8 @@ class CalculatorAscensionMaterialsPage extends StatelessWidget {
final int sessionKey;

const CalculatorAscensionMaterialsPage({
Key key,
@required this.sessionKey,
Key? key,
required this.sessionKey,
}) : super(key: key);

@override
Expand Down Expand Up @@ -149,7 +149,7 @@ class CalculatorAscensionMaterialsPage extends StatelessWidget {
return;
}

context.read<CalculatorAscMaterialsItemBloc>().add(CalculatorAscMaterialsItemEvent.load(key: keyName, isCharacter: true));
context.read<CalculatorAscMaterialsItemBloc>().add(CalculatorAscMaterialsItemEvent.load(key: keyName!, isCharacter: true));

await showModalBottomSheet(
context: context,
Expand All @@ -172,7 +172,7 @@ class CalculatorAscensionMaterialsPage extends StatelessWidget {
return;
}

context.read<CalculatorAscMaterialsItemBloc>().add(CalculatorAscMaterialsItemEvent.load(key: keyName, isCharacter: false));
context.read<CalculatorAscMaterialsItemBloc>().add(CalculatorAscMaterialsItemEvent.load(key: keyName!, isCharacter: false));

await showModalBottomSheet<bool>(
context: context,
Expand Down
Expand Up @@ -14,29 +14,29 @@ import 'skill_item.dart';

class AddEditItemBottomSheet extends StatelessWidget {
final int sessionKey;
final int index;
final String keyName;
final int? index;
final String? keyName;
final bool isInEditMode;
final bool isAWeapon;
final bool isActive;

const AddEditItemBottomSheet.toAddItem({
Key key,
@required this.sessionKey,
@required this.keyName,
@required this.isAWeapon,
}) : index = null,
Key? key,
required this.sessionKey,
required this.keyName,
required this.isAWeapon,
}) : index = null,
isInEditMode = false,
isActive = true,
super(key: key);

const AddEditItemBottomSheet.toEditItem({
Key key,
@required this.sessionKey,
@required this.index,
@required this.isAWeapon,
@required this.isActive,
}) : keyName = null,
Key? key,
required this.sessionKey,
required this.index,
required this.isAWeapon,
required this.isActive,
}) : keyName = null,
isInEditMode = true,
super(key: key);

Expand All @@ -60,18 +60,18 @@ class AddEditItemBottomSheet extends StatelessWidget {
Text(
s.level,
textAlign: TextAlign.center,
style: theme.textTheme.subtitle2.copyWith(fontWeight: FontWeight.bold),
style: theme.textTheme.subtitle2!.copyWith(fontWeight: FontWeight.bold),
),
Container(
margin: const EdgeInsets.only(bottom: 5),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
OutlineButton(
OutlinedButton(
onPressed: () => _showLevelPickerDialog(context, state.currentLevel, true),
child: Text(s.currentX(state.currentLevel)),
),
OutlineButton(
OutlinedButton(
onPressed: () => _showLevelPickerDialog(context, state.desiredLevel, false),
child: Text(s.desiredX(state.desiredLevel)),
),
Expand All @@ -98,7 +98,7 @@ class AddEditItemBottomSheet extends StatelessWidget {
children: [
Text(
s.useMaterialsFromInventory,
style: theme.textTheme.subtitle2.copyWith(fontWeight: FontWeight.bold),
style: theme.textTheme.subtitle2!.copyWith(fontWeight: FontWeight.bold),
),
Container(
margin: const EdgeInsets.only(top: 5),
Expand All @@ -118,17 +118,17 @@ class AddEditItemBottomSheet extends StatelessWidget {
ButtonBar(
buttonPadding: const EdgeInsets.symmetric(horizontal: 10),
children: <Widget>[
OutlineButton(
OutlinedButton(
onPressed: () => Navigator.pop(context),
child: Text(s.cancel, style: TextStyle(color: theme.primaryColor)),
),
if (isInEditMode)
OutlineButton(
OutlinedButton(
onPressed: () => _removeItem(context),
child: Text(s.delete, style: TextStyle(color: theme.primaryColor)),
),
if (isInEditMode)
OutlineButton(
OutlinedButton(
onPressed: () => isAWeapon
? _applyChangesForWeapon(
state.currentLevel,
Expand All @@ -151,8 +151,7 @@ class AddEditItemBottomSheet extends StatelessWidget {
),
child: Text(isActive ? s.inactive : s.active, style: TextStyle(color: theme.primaryColor)),
),
RaisedButton(
color: theme.primaryColor,
ElevatedButton(
onPressed: () => isAWeapon
? _applyChangesForWeapon(
state.currentLevel,
Expand Down Expand Up @@ -216,7 +215,7 @@ class AddEditItemBottomSheet extends StatelessWidget {
final event = !isInEditMode
? CalculatorAscMaterialsEvent.addWeapon(
sessionKey: sessionKey,
key: keyName,
key: keyName!,
currentLevel: currentLevel,
desiredLevel: desiredLevel,
currentAscensionLevel: currentAscensionLevel,
Expand All @@ -225,7 +224,7 @@ class AddEditItemBottomSheet extends StatelessWidget {
)
: CalculatorAscMaterialsEvent.updateWeapon(
sessionKey: sessionKey,
index: index,
index: index!,
currentLevel: currentLevel,
desiredLevel: desiredLevel,
currentAscensionLevel: currentAscensionLevel,
Expand All @@ -250,7 +249,7 @@ class AddEditItemBottomSheet extends StatelessWidget {
final event = !isInEditMode
? CalculatorAscMaterialsEvent.addCharacter(
sessionKey: sessionKey,
key: keyName,
key: keyName!,
currentLevel: currentLevel,
desiredLevel: desiredLevel,
skills: skills,
Expand All @@ -260,7 +259,7 @@ class AddEditItemBottomSheet extends StatelessWidget {
)
: CalculatorAscMaterialsEvent.updateCharacter(
sessionKey: sessionKey,
index: index,
index: index!,
currentLevel: currentLevel,
desiredLevel: desiredLevel,
skills: skills,
Expand All @@ -274,7 +273,7 @@ class AddEditItemBottomSheet extends StatelessWidget {
}

void _removeItem(BuildContext context) {
context.read<CalculatorAscMaterialsBloc>().add(CalculatorAscMaterialsEvent.removeItem(sessionKey: sessionKey, index: index));
context.read<CalculatorAscMaterialsBloc>().add(CalculatorAscMaterialsEvent.removeItem(sessionKey: sessionKey, index: index!));
Navigator.pop(context);
}

Expand Down

0 comments on commit deed76d

Please sign in to comment.