Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve lint ci #160

Merged
merged 2 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@ jobs:
- name: Retrieve the secret and decode it to file
env:
FIREBASE_OPTIONS_BASE64: ${{ secrets.FIREBASE_OPTIONS_BASE64 }}
GOOGLE_SERVICE_INFO_PLIST_BASE64: ${{ secrets.GOOGLE_SERVICE_INFO_PLIST_BASE64 }}
FIREBASE_JSON_BASE64: ${{ secrets.FIREBASE_JSON_BASE64 }}
GOOGLE_SERVICES_JSON_BASE64: ${{ secrets.GOOGLE_SERVICES_JSON_BASE64 }}
run: |
cd khelo
echo $FIREBASE_OPTIONS_BASE64 | base64 -di > lib/firebase_options.dart
echo $FIREBASE_OPTIONS_BASE64 | base64 --decode > lib/firebase_options.dart
echo $GOOGLE_SERVICE_INFO_PLIST_BASE64 | base64 --decode > ios/Runner/GoogleService-Info.plist
echo $FIREBASE_JSON_BASE64 | base64 --decode > firebase.json
echo $GOOGLE_SERVICES_JSON_BASE64 | base64 --decode > android/app/google-services.json

- name: Install dependencies
run: |
Expand All @@ -32,7 +38,16 @@ jobs:

- name: Lint test
run: |
cd data && flutter analyze --fatal-infos
cd ../style && flutter analyze --fatal-infos
cd ../khelo && flutter analyze --fatal-infos
cd khelo
dart format . --set-exit-if-changed
dart analyze --fatal-infos

cd ../data
dart format . --set-exit-if-changed
dart analyze --fatal-infos

cd ../style
dart format . --set-exit-if-changed
dart analyze --fatal-infos

cd ..
3 changes: 2 additions & 1 deletion data/lib/api/ball_score/ball_score_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ class ExtraSummary with _$ExtraSummary {
}

extension BallScoreModelData on BallScoreModel? {
double get formattedOver => double.parse("${(this?.over_number ?? 1) - 1}.${this?.ball_number ?? 0}");
double get formattedOver =>
double.parse("${(this?.over_number ?? 1) - 1}.${this?.ball_number ?? 0}");

bool? isLegalDelivery() {
if (this == null) {
Expand Down
4 changes: 2 additions & 2 deletions data/lib/api/leaderboard/leaderboard_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ enum LeaderboardField {
}
}

int getMinScoreToGetFeatured(){
switch(this){
int getMinScoreToGetFeatured() {
switch (this) {
case LeaderboardField.batting:
return 50;
case LeaderboardField.bowling:
Expand Down
8 changes: 4 additions & 4 deletions data/lib/api/match_event/match_event_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ class MatchEventMilestone with _$MatchEventMilestone {
_$MatchEventMilestoneFromJson(json);

factory MatchEventMilestone.fromFireStore(
DocumentSnapshot<Map<String, dynamic>> snapshot,
SnapshotOptions? options,
) =>
DocumentSnapshot<Map<String, dynamic>> snapshot,
SnapshotOptions? options,
) =>
MatchEventMilestone.fromJson(snapshot.data()!);
}
}
1 change: 0 additions & 1 deletion data/lib/api/network/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ final rawDioProvider = Provider((ref) {

extension HttpExtensions on http.Client {
Future<http.Response> req(Endpoint endpoint) async {

final request = http.Request(
endpoint.method.name,
Uri.parse('${DataConfig.instance.apiBaseUrl}${endpoint.path}'),
Expand Down
8 changes: 4 additions & 4 deletions data/lib/api/partnership/partnership_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class PartnershipModel with _$PartnershipModel {
_$PartnershipModelFromJson(json);

factory PartnershipModel.fromFireStore(
DocumentSnapshot<Map<String, dynamic>> snapshot,
SnapshotOptions? options,
) =>
DocumentSnapshot<Map<String, dynamic>> snapshot,
SnapshotOptions? options,
) =>
PartnershipModel.fromJson(snapshot.data()!);
}

Expand All @@ -45,4 +45,4 @@ class PartnershipPlayer with _$PartnershipPlayer {

factory PartnershipPlayer.fromJson(Map<String, dynamic> json) =>
_$PartnershipPlayerFromJson(json);
}
}
27 changes: 12 additions & 15 deletions data/lib/service/auth/auth_service.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../../api/user/user_models.dart';
import '../../errors/app_error.dart';
import '../../extensions/string_extensions.dart';
import '../../storage/app_preferences.dart';
import '../../storage/provider/preferences_provider.dart';
import '../user/user_service.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../../api/user/user_models.dart';

final firebaseAuthProvider = Provider((ref) => FirebaseAuth.instance);

Expand Down Expand Up @@ -61,21 +60,19 @@ class AuthService {
verificationCompleted: (phoneAuthCredential) async {
final userCredential =
await _auth.signInWithCredential(phoneAuthCredential);
_onVerificationSuccess(countryCode, phoneNumber, userCredential);
onVerificationCompleted != null
? onVerificationCompleted(phoneAuthCredential, userCredential)
: null;
await _onVerificationSuccess(
countryCode,
phoneNumber,
userCredential,
);
onVerificationCompleted?.call(phoneAuthCredential, userCredential);
},
verificationFailed: (FirebaseAuthException e) =>
onVerificationFailed != null
? onVerificationFailed(AppError.fromError(e, e.stackTrace))
: null,
onVerificationFailed?.call(AppError.fromError(e, e.stackTrace)),
codeSent: (String verificationId, int? resendToken) =>
onCodeSent != null ? onCodeSent(verificationId, resendToken) : null,
onCodeSent?.call(verificationId, resendToken),
codeAutoRetrievalTimeout: (verificationId) =>
onCodeAutoRetrievalTimeout != null
? onCodeAutoRetrievalTimeout(verificationId)
: null,
onCodeAutoRetrievalTimeout?.call(verificationId),
);
} catch (error, stack) {
throw AppError.fromError(error, stack);
Expand Down
3 changes: 2 additions & 1 deletion data/lib/service/team/team_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ class TeamService {
.where(
FireStoreConst.nameLowercase,
isLessThan: '${searchKey.caseAndSpaceInsensitive}z',
).orderBy(FireStoreConst.id);
)
.orderBy(FireStoreConst.id);

if (lastTeamId != null && lastTeamId.isNotEmpty) {
query = query.startAfter([lastTeamId]);
Expand Down
14 changes: 7 additions & 7 deletions data/lib/storage/provider/preferences_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:shared_preferences/shared_preferences.dart';

final sharedPreferencesProvider =
Provider<SharedPreferences>((ref) => throw UnimplementedError());
Provider<SharedPreferences>((ref) => throw UnimplementedError());

StateNotifierProvider<PreferenceNotifier<T>, T> createPrefProvider<T>({
required String prefKey,
required T defaultValue,
}) {
return StateNotifierProvider<PreferenceNotifier<T>, T>(
(ref) => PreferenceNotifier<T>(
(ref) => PreferenceNotifier<T>(
ref.watch(sharedPreferencesProvider).get(prefKey) as T? ?? defaultValue,
(curr) {
(curr) {
final prefs = ref.watch(sharedPreferencesProvider);
if (curr == null) {
prefs.remove(prefKey);
Expand All @@ -35,9 +35,9 @@ class PreferenceNotifier<T> extends StateNotifier<T> {
Function(T curr)? onUpdate;

PreferenceNotifier(
super.value,
this.onUpdate,
);
super.value,
this.onUpdate,
);

@override
set state(T value) {
Expand All @@ -47,4 +47,4 @@ class PreferenceNotifier<T> extends StateNotifier<T> {

@override
T get state => super.state;
}
}
26 changes: 13 additions & 13 deletions data/lib/utils/combine_latest.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@ Stream<(T1, T2, T3)> combineLatest3<T1, T2, T3>(
}

Stream<(T1, T2, T3, T4)> combineLatest4<T1, T2, T3, T4>(
Stream<T1> stream1,
Stream<T2> stream2,
Stream<T3> stream3,
Stream<T4> stream4,
) {
Stream<T1> stream1,
Stream<T2> stream2,
Stream<T3> stream3,
Stream<T4> stream4,
) {
final firstThree = combineLatest3(stream1, stream2, stream3);
return combineLatest2(firstThree, stream4)
.map((tuple) => (tuple.$1.$1, tuple.$1.$2, tuple.$1.$3, tuple.$2));
}

Stream<(T1, T2, T3, T4, T5)> combineLatest5<T1, T2, T3, T4, T5>(
Stream<T1> stream1,
Stream<T2> stream2,
Stream<T3> stream3,
Stream<T4> stream4,
Stream<T5> stream5,
) {
Stream<T1> stream1,
Stream<T2> stream2,
Stream<T3> stream3,
Stream<T4> stream4,
Stream<T5> stream5,
) {
final firstFour = combineLatest4(stream1, stream2, stream3, stream4);
return combineLatest2(firstFour, stream5).map(
(tuple) => (tuple.$1.$1, tuple.$1.$2, tuple.$1.$3, tuple.$1.$4, tuple.$2),
(tuple) => (tuple.$1.$1, tuple.$1.$2, tuple.$1.$3, tuple.$1.$4, tuple.$2),
);
}
}
4 changes: 2 additions & 2 deletions khelo/lib/components/country_code_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import 'package:twemoji_v2/twemoji_v2.dart';

import '../gen/assets.gen.dart';


class CountryCodeView extends StatelessWidget {
final CountryCode countryCode;
final Function(CountryCode) onCodeChange;

const CountryCodeView({super.key, required this.countryCode, required this.onCodeChange});
const CountryCodeView(
{super.key, required this.countryCode, required this.onCodeChange});

@override
Widget build(BuildContext context) {
Expand Down
3 changes: 2 additions & 1 deletion khelo/lib/ui/flow/home/search/search_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ class SearchHomeViewNotifier extends StateNotifier<SearchHomeViewState> {
void onChange() {
final searchKey = state.searchController.text.toLowerCase().trim();
if (searchKey.isEmpty) {
state = state.copyWith(matches: [], teams: [], tournaments: [], users: []);
state =
state.copyWith(matches: [], teams: [], tournaments: [], users: []);
return;
}
_debounce?.cancel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class MatchOfficialSelectionView extends StatelessWidget {
type: official,
isWholeCellTappable: true,
user: state.officials
.firstWhereOrNull((element) => element.type == official)
.firstWhereOrNull(
(element) => element.type == official)
?.user,
onCardTap: () async {
final officials = await AppRoute.addMatchOfficials(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class OverDetailView extends StatelessWidget {
BuildContext context, {
required String title,
required Widget trailing,
VoidCallback? onTap,
VoidCallback? onTap,
}) {
return OnTapScale(
onTap: onTap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class UserDetailSheet extends StatelessWidget {
BuildContext context,
UserModel user, {
String? actionButtonTitle,
VoidCallback? onButtonTap,
VoidCallback? onButtonTap,
}) {
HapticFeedback.mediumImpact();
return showModalBottomSheet(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class MatchDetailScorecardView extends ConsumerWidget {
bool highlightRow = false,
int? highlightColumnNumber,
required List<String> data,
VoidCallback? onTap,
VoidCallback? onTap,
}) {
return Container(
color: context.colorScheme.surface,
Expand Down
3 changes: 2 additions & 1 deletion khelo/lib/ui/flow/matches/match_list_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ class MatchListViewNotifier extends StateNotifier<MatchListViewState> {
.streamUserRelatedMatches(
userId: state.currentUserId!,
limit: state.matches.length + 10,
).listen((matches) {
)
.listen((matches) {
state = state.copyWith(
matches: matches,
loading: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ class MatchCompleteSheet extends ConsumerWidget {
...state.allInnings.map(
(inning) {
final teamName = state.match?.teams
.firstWhereOrNull((element) => element.team.id == inning.team_id)
.firstWhereOrNull(
(element) => element.team.id == inning.team_id)
?.team
.name;
return _teamScore(context, state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import 'package:style/animations/on_tap_scale.dart';
import 'package:style/extensions/context_extensions.dart';
import 'package:style/text/app_text_style.dart';


class TeamDetailMemberContent extends ConsumerWidget {
const TeamDetailMemberContent({super.key});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ class _MakeAdminScreenState extends ConsumerState<MakeTeamAdminScreen> {
state.owner.id)
? context
.l10n.team_detail_remove_ownership_title
: context
.l10n.common_transfer_ownership,
: context.l10n.common_transfer_ownership,
onTap: () async {
context.pop();
if (notifier.team.created_by_user.id !=
Expand All @@ -135,8 +134,8 @@ class _MakeAdminScreenState extends ConsumerState<MakeTeamAdminScreen> {
final newOwner =
await SearchUserBottomSheet.show<UserModel>(
context,
emptyScreenTitle: context
.l10n.common_transfer_ownership,
emptyScreenTitle:
context.l10n.common_transfer_ownership,
emptyScreenDescription: context.l10n
.team_detail_transfer_ownership_description,
);
Expand All @@ -163,8 +162,7 @@ class _MakeAdminScreenState extends ConsumerState<MakeTeamAdminScreen> {
UserDetailSheet.show(context, state.owner);
}
},
trailing: Text(
context.l10n.common_owner,
trailing: Text(context.l10n.common_owner,
style: AppTextStyle.body2
.copyWith(color: context.colorScheme.primary)),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class SearchTeamViewNotifier extends StateNotifier<SearchTeamState> {
if (state.tournament == null || state.selectedTeam == null) {
return;
}
if(state.tournament!.team_ids.contains(state.selectedTeam!.id)) return;
if (state.tournament!.team_ids.contains(state.selectedTeam!.id)) return;
try {
final teamIds = state.tournament!.team_ids.toList();
teamIds.add(state.selectedTeam!.id);
Expand Down
6 changes: 4 additions & 2 deletions khelo/lib/ui/flow/team/team_list_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ class _TeamListScreenState extends ConsumerState<TeamListScreen>
final team = state.filteredTeams[index];
return TeamDetailCell(
team: team,
showMoreOptionButton: team.isAdminOrOwner(state.currentUserId),
onTap: () => AppRoute.teamDetail(teamId: team.id).push(context),
showMoreOptionButton:
team.isAdminOrOwner(state.currentUserId),
onTap: () =>
AppRoute.teamDetail(teamId: team.id).push(context),
onMoreOptionTap: () => _moreActionButton(context, team),
);
}
Expand Down
3 changes: 2 additions & 1 deletion khelo/lib/ui/flow/team/team_list_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ class TeamListViewNotifier extends StateNotifier<TeamListViewState> {
.streamUserRelatedTeams(
userId: state.currentUserId!,
limit: state.teams.length + 10,
).listen((teams) {
)
.listen((teams) {
state = state.copyWith(
teams: {...state.teams, ...teams}.toList(),
loading: false,
Expand Down
Loading
Loading