Skip to content

Commit

Permalink
chore: code tune
Browse files Browse the repository at this point in the history
  • Loading branch information
abc873693 committed Aug 20, 2024
1 parent 38e9a7f commit 6ee0deb
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 15 deletions.
4 changes: 2 additions & 2 deletions example/lib/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class HomePageState extends State<HomePage> {
isLogin = false;
userInfo = null;
content = null;
if (!mounted) return;
if (!context.mounted) return;
if (!isTablet) Navigator.of(context).pop();
checkLogin();
},
Expand Down Expand Up @@ -399,7 +399,7 @@ class HomePageState extends State<HomePage> {
_homeKey.currentState!.hideSnackBar();
} else {
//ignore: use_build_context_synchronously
if (!context.mounted) return;
if (!mounted) return;
_homeKey.currentState!
.showSnackBar(
text: ApLocalizations.of(context).notLogin,
Expand Down
2 changes: 1 addition & 1 deletion lib/models/announcement_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Announcement {
String? reviewDescription;
@JsonKey(name: 'tag')
List<String>? tags;
@JsonKey(ignore: true)
@JsonKey(includeToJson: false, includeFromJson: false)
late int randomWeight;

Map<String, dynamic> toJson() => _$AnnouncementToJson(this);
Expand Down
2 changes: 1 addition & 1 deletion lib/models/user_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class UserInfo {
final String? pictureUrl;
final String? email;

@JsonKey(ignore: true)
@JsonKey(includeToJson: false, includeFromJson: false)
Uint8List? pictureBytes;

Map<String, dynamic> toJson() => _$UserInfoToJson(this);
Expand Down
3 changes: 3 additions & 0 deletions lib/pages/about_us_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ class AboutUsPageState extends State<AboutUsPage> {
ApUtils.launchUrl(widget.fbFanPageUrl)
.catchError(
(dynamic onError) {
if (!context.mounted) return;
ApUtils.showToast(
context,
app.platformError,
Expand Down Expand Up @@ -213,6 +214,7 @@ class AboutUsPageState extends State<AboutUsPage> {
ApUtils.launchUrl(widget.githubUrl)
.catchError(
(dynamic onError) {
if (!context.mounted) return;
ApUtils.showToast(
context,
app.platformError,
Expand All @@ -231,6 +233,7 @@ class AboutUsPageState extends State<AboutUsPage> {
ApUtils.launchUrl('mailto:${widget.email}')
.catchError(
(dynamic onError) {
if (!context.mounted) return;
ApUtils.showToast(
context,
app.platformError,
Expand Down
6 changes: 3 additions & 3 deletions lib/pages/announcement/edit_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ class _AnnouncementEditPageState extends State<AnnouncementEditPage> {
reviewDescription: announcements.reviewDescription,
callback: GeneralCallback<Response<dynamic>>.simple(
context,
(_) => _,
(_) {},
),
);
} else {
Expand All @@ -683,7 +683,7 @@ class _AnnouncementEditPageState extends State<AnnouncementEditPage> {
reviewDescription: announcements.reviewDescription,
callback: GeneralCallback<Response<dynamic>>.simple(
context,
(_) => _,
(_) => <dynamic>{},
),
);
}
Expand All @@ -695,7 +695,7 @@ class _AnnouncementEditPageState extends State<AnnouncementEditPage> {
//ignore: use_build_context_synchronously
callback: GeneralCallback<Response<dynamic>>.simple(
context,
(_) => _,
(_) => <dynamic>{},
),
);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/resources/ap_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ class ApTheme extends InheritedWidget {
visualDensity: VisualDensity.adaptivePlatformDensity,
colorScheme: ColorScheme.fromSwatch(
accentColor: ApColors.blue500,
).copyWith(background: Colors.black12),
).copyWith(surface: Colors.black12),
);

static ThemeData get dark => ThemeData(
Expand All @@ -342,7 +342,7 @@ class ApTheme extends InheritedWidget {
colorScheme: ColorScheme.fromSwatch(
brightness: Brightness.dark,
accentColor: ApColors.blue300,
).copyWith(background: Colors.black12),
).copyWith(surface: Colors.black12),
);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/scaffold/score_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ class _ScoreContentState extends State<ScoreContent> {
border: Border.all(color: Colors.grey, width: 1.5),
);

TableBorder get _tableBorder => TableBorder.symmetric(
inside: const BorderSide(
TableBorder get _tableBorder => const TableBorder.symmetric(
inside: BorderSide(
color: Colors.grey,
width: 0.5,
),
Expand Down
11 changes: 7 additions & 4 deletions lib/utils/ap_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,13 @@ class ApUtils {
);
} else {
ApUtils.launchUrl(fansPageUrl).catchError(
(dynamic onError) => ApUtils.showToast(
context,
ApLocalizations.of(context).platformError,
),
(dynamic onError) {
if (!context.mounted) return;
ApUtils.showToast(
context,
ApLocalizations.of(context).platformError,
);
},
);
}
}
Expand Down

0 comments on commit 6ee0deb

Please sign in to comment.