Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Enabled  non_constant_identifier_names
rule
  • Loading branch information
Aadeesh11 committed Dec 5, 2021
1 parent 56d932b commit b5dcde1
Show file tree
Hide file tree
Showing 29 changed files with 150 additions and 149 deletions.
2 changes: 1 addition & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ linter:

avoid_redundant_argument_values: false

non_constant_identifier_names: false
non_constant_identifier_names: true

constant_identifier_names: false

Expand Down
4 changes: 2 additions & 2 deletions lib/services/database_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ enum DatabaseBox {
IB,
}

List<TypeAdapter> DatabaseAdapters = <TypeAdapter>[
List<TypeAdapter> databaseAdapters = <TypeAdapter>[
IbRawPageDataAdapter(),
];

Expand Down Expand Up @@ -38,7 +38,7 @@ class DatabaseServiceImpl implements DatabaseService {
}

// Register Adapters for Hive
for (var adapter in DatabaseAdapters) {
for (var adapter in databaseAdapters) {
Hive.registerAdapter(adapter);
}
}
Expand Down
10 changes: 5 additions & 5 deletions lib/services/ib_engine_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,19 @@ class IbEngineServiceImpl implements IbEngineService {
var toc = <IbTocItem>[];

for (var li in element.children) {
var eff_index = num ? index.toString() : String.fromCharCode(index);
var effIndex = num ? index.toString() : String.fromCharCode(index);
if (li.getElementsByTagName('ol').isNotEmpty) {
toc.add(
IbTocItem(
leading: '$eff_index.',
leading: '$effIndex.',
content: li.firstChild.text,
items: _parseToc(li.children[1], num: !num),
),
);
} else {
toc.add(
IbTocItem(
leading: '$eff_index.',
leading: '$effIndex.',
content: li.text,
),
);
Expand All @@ -191,7 +191,7 @@ class IbEngineServiceImpl implements IbEngineService {
var toc = <IbTocItem>[];

for (var li in element.children) {
var eff_index = num ? index.toString() : String.fromCharCode(index);
var effIndex = num ? index.toString() : String.fromCharCode(index);
var sublist = <IbTocItem>[];

for (var node in li.nodes) {
Expand All @@ -206,7 +206,7 @@ class IbEngineServiceImpl implements IbEngineService {

toc.add(
IbTocItem(
leading: '$eff_index.',
leading: '$effIndex.',
content: root ? li.nodes[0].text.trim() : li.text.trim(),
items: sublist.isNotEmpty ? sublist : null,
),
Expand Down
6 changes: 3 additions & 3 deletions lib/ui/views/profile/edit_profile_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,17 @@ class _EditProfileViewState extends State<EditProfileView> {

_dialogService.popDialog();

if (_model.isSuccess(_model.UPDATE_PROFILE)) {
if (_model.isSuccess(_model.updateProfileKey)) {
await Future.delayed(const Duration(seconds: 1));
Get.back(result: _model.updatedUser);
SnackBarUtils.showDark(
'Profile Updated',
'Your profile was successfully updated.',
);
} else if (_model.isError(_model.UPDATE_PROFILE)) {
} else if (_model.isError(_model.updateProfileKey)) {
SnackBarUtils.showDark(
'Error',
_model.errorMessageFor(_model.UPDATE_PROFILE),
_model.errorMessageFor(_model.updateProfileKey),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/views/profile/user_favourites_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class _UserFavouritesViewState extends State<UserFavouritesView>
builder: (context, model, child) {
final _items = <Widget>[];

if (model.isSuccess(model.FETCH_USER_FAVOURITES)) {
if (model.isSuccess(model.fetchUserFavouritesKey)) {
for (var project in model.userFavourites) {
_items.add(
ProjectCard(
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/views/profile/user_projects_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class _UserProjectsViewState extends State<UserProjectsView>
builder: (context, model, child) {
final _items = <Widget>[];

if (model.isSuccess(model.FETCH_USER_PROJECTS)) {
if (model.isSuccess(model.fetchUserProjectsKey)) {
for (var project in model.userProjects) {
_items.add(
ProjectCard(
Expand Down
6 changes: 3 additions & 3 deletions lib/ui/views/projects/edit_project_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,17 @@ class _EditProjectViewState extends State<EditProjectView> {

_dialogService.popDialog();

if (_model.isSuccess(_model.UPDATE_PROJECT)) {
if (_model.isSuccess(_model.updateProjectKey)) {
await Future.delayed(const Duration(seconds: 1));
Get.back(result: _model.updatedProject);
SnackBarUtils.showDark(
'Project Updated',
'The project was successfully updated.',
);
} else if (_model.isError(_model.UPDATE_PROJECT)) {
} else if (_model.isError(_model.updateProjectKey)) {
SnackBarUtils.showDark(
'Error',
_model.errorMessageFor(_model.UPDATE_PROJECT),
_model.errorMessageFor(_model.updateProjectKey),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/views/projects/featured_projects_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class _FeaturedProjectsViewState extends State<FeaturedProjectsView> {
builder: (context, model, child) {
final _items = <Widget>[];

if (model.isSuccess(model.FETCH_FEATURED_PROJECTS)) {
if (model.isSuccess(model.fetchFeaturedProjectsKey)) {
for (var project in model.featuredProjects) {
_items.add(
FeaturedProjectCard(
Expand Down
36 changes: 18 additions & 18 deletions lib/ui/views/projects/project_details_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ class _ProjectDetailsViewState extends State<ProjectDetailsView> {

void onShareButtonPressed() {
final RenderBox box = context.findRenderObject();
var URL =
var url =
'https://circuitverse.org/users/${widget.project.relationships.author.data.id}/projects/${widget.project.id}';
Share.share(URL,
Share.share(url,
sharePositionOrigin: box.localToGlobal(Offset.zero) & box.size);
}

Expand Down Expand Up @@ -253,13 +253,13 @@ class _ProjectDetailsViewState extends State<ProjectDetailsView> {

_dialogService.popDialog();

if (_model.isSuccess(_model.FORK_PROJECT)) {
if (_model.isSuccess(_model.forkProjectKey)) {
await Get.toNamed(ProjectDetailsView.id,
arguments: _model.forkedProject);
} else if (_model.isError(_model.FORK_PROJECT)) {
} else if (_model.isError(_model.forkProjectKey)) {
SnackBarUtils.showDark(
'Error',
_model.errorMessageFor(_model.FORK_PROJECT),
_model.errorMessageFor(_model.forkProjectKey),
);
}
}
Expand Down Expand Up @@ -294,15 +294,15 @@ class _ProjectDetailsViewState extends State<ProjectDetailsView> {
Future<void> onStarProjectPressed() async {
await _model.toggleStarForProject(_recievedProject.id);

if (_model.isSuccess(_model.TOGGLE_STAR)) {
if (_model.isSuccess(_model.toggleStarKey)) {
SnackBarUtils.showDark(
'Project ${_model.isProjectStarred ? 'Starred' : 'Unstarred'}',
'You have successfully ${_model.isProjectStarred ? 'stared' : 'unstarred'} the project',
);
} else if (_model.isError(_model.TOGGLE_STAR)) {
} else if (_model.isError(_model.toggleStarKey)) {
SnackBarUtils.showDark(
'Error',
_model.errorMessageFor(_model.TOGGLE_STAR),
_model.errorMessageFor(_model.toggleStarKey),
);
}
}
Expand Down Expand Up @@ -335,16 +335,16 @@ class _ProjectDetailsViewState extends State<ProjectDetailsView> {

_dialogService.popDialog();

if (_model.isSuccess(_model.ADD_COLLABORATORS) &&
if (_model.isSuccess(_model.addCollaboratorsKey) &&
_model.addedCollaboratorsSuccessMessage.isNotEmpty) {
SnackBarUtils.showDark(
'Collaborators Added',
_model.addedCollaboratorsSuccessMessage,
);
} else if (_model.isError(_model.ADD_COLLABORATORS)) {
} else if (_model.isError(_model.addCollaboratorsKey)) {
SnackBarUtils.showDark(
'Error',
_model.errorMessageFor(_model.ADD_COLLABORATORS),
_model.errorMessageFor(_model.addCollaboratorsKey),
);
}
}
Expand Down Expand Up @@ -466,16 +466,16 @@ class _ProjectDetailsViewState extends State<ProjectDetailsView> {

_dialogService.popDialog();

if (_model.isSuccess(_model.DELETE_PROJECT)) {
if (_model.isSuccess(_model.deleteProjectKey)) {
Get.back(result: true);
SnackBarUtils.showDark(
'Project Deleted',
'Project is successfully deleted.',
);
} else if (_model.isError(_model.DELETE_PROJECT)) {
} else if (_model.isError(_model.deleteProjectKey)) {
SnackBarUtils.showDark(
'Error',
_model.errorMessageFor(_model.DELETE_PROJECT),
_model.errorMessageFor(_model.deleteProjectKey),
);
}
}
Expand Down Expand Up @@ -516,15 +516,15 @@ class _ProjectDetailsViewState extends State<ProjectDetailsView> {

_dialogService.popDialog();

if (_model.isSuccess(_model.DELETE_COLLABORATORS)) {
if (_model.isSuccess(_model.deleteCollaboartorsKey)) {
SnackBarUtils.showDark(
'Collaborator Deleted',
'Collaborator was successfully deleted.',
);
} else if (_model.isError(_model.DELETE_COLLABORATORS)) {
} else if (_model.isError(_model.deleteCollaboartorsKey)) {
SnackBarUtils.showDark(
'Error',
_model.errorMessageFor(_model.DELETE_COLLABORATORS),
_model.errorMessageFor(_model.deleteCollaboartorsKey),
);
}
}
Expand Down Expand Up @@ -634,7 +634,7 @@ class _ProjectDetailsViewState extends State<ProjectDetailsView> {
),
);

if (_model.isSuccess(_model.FETCH_PROJECT_DETAILS) &&
if (_model.isSuccess(_model.fetchProjectDetailsKey) &&
_model.collaborators.isNotEmpty) {
_items.add(const Divider());

Expand Down
2 changes: 1 addition & 1 deletion lib/utils/unicode_map.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// Unicode Map for Subscript and Subscript character
var UnicodeMap = {
const UnicodeMap = {
' ': [' ', ' '],
'0': ['\u2070', '\u2080'],
'1': ['\u00B9', '\u2081'],
Expand Down
10 changes: 5 additions & 5 deletions lib/viewmodels/profile/edit_profile_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:mobile_app/viewmodels/base_viewmodel.dart';

class EditProfileViewModel extends BaseModel {
// ViewState Keys
String UPDATE_PROFILE = 'update_profile';
String updateProfileKey = 'update_profile';

final UsersApi _userApi = locator<UsersApi>();
final LocalStorageService _storage = locator<LocalStorageService>();
Expand All @@ -24,16 +24,16 @@ class EditProfileViewModel extends BaseModel {

Future updateProfile(String name, String educationalInstitute, String country,
bool subscribed) async {
setStateFor(UPDATE_PROFILE, ViewState.Busy);
setStateFor(updateProfileKey, ViewState.Busy);
try {
updatedUser = await _userApi.updateProfile(
name, educationalInstitute, country, subscribed);
_storage.currentUser = _updatedUser;

setStateFor(UPDATE_PROFILE, ViewState.Success);
setStateFor(updateProfileKey, ViewState.Success);
} on Failure catch (f) {
setStateFor(UPDATE_PROFILE, ViewState.Error);
setErrorMessageFor(UPDATE_PROFILE, f.message);
setStateFor(updateProfileKey, ViewState.Error);
setErrorMessageFor(updateProfileKey, f.message);
}
}
}
10 changes: 5 additions & 5 deletions lib/viewmodels/profile/profile_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:mobile_app/viewmodels/base_viewmodel.dart';

class ProfileViewModel extends BaseModel {
// ViewState Keys
String FETCH_USER_PROFILE = 'fetch_user_profile';
String fetchUserProfileKey = 'fetch_user_profile';

final UsersApi _usersApi = locator<UsersApi>();

Expand All @@ -21,14 +21,14 @@ class ProfileViewModel extends BaseModel {
}

Future fetchUserProfile(String userId) async {
setStateFor(FETCH_USER_PROFILE, ViewState.Busy);
setStateFor(fetchUserProfileKey, ViewState.Busy);
try {
user = await _usersApi.fetchUser(userId);

setStateFor(FETCH_USER_PROFILE, ViewState.Success);
setStateFor(fetchUserProfileKey, ViewState.Success);
} on Failure catch (f) {
setStateFor(FETCH_USER_PROFILE, ViewState.Error);
setErrorMessageFor(FETCH_USER_PROFILE, f.message);
setStateFor(fetchUserProfileKey, ViewState.Error);
setErrorMessageFor(fetchUserProfileKey, f.message);
}
}
}
10 changes: 5 additions & 5 deletions lib/viewmodels/profile/user_favourites_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:mobile_app/viewmodels/base_viewmodel.dart';

class UserFavouritesViewModel extends BaseModel {
// ViewState Keys
String FETCH_USER_FAVOURITES = 'fetch_user_favourites';
String fetchUserFavouritesKey = 'fetch_user_favourites';

final ProjectsApi _projectsApi = locator<ProjectsApi>();
final LocalStorageService _localStorageService =
Expand Down Expand Up @@ -48,18 +48,18 @@ class UserFavouritesViewModel extends BaseModel {
);
} else {
// Set State as busy only very first time..
setStateFor(FETCH_USER_FAVOURITES, ViewState.Busy);
setStateFor(fetchUserFavouritesKey, ViewState.Busy);
// fetch projects for the very first time..
previousUserFavouritesBatch = await _projectsApi.getUserFavourites(
userId ?? _localStorageService.currentUser.data.id);
}

userFavourites.addAll(previousUserFavouritesBatch.data);

setStateFor(FETCH_USER_FAVOURITES, ViewState.Success);
setStateFor(fetchUserFavouritesKey, ViewState.Success);
} on Failure catch (f) {
setStateFor(FETCH_USER_FAVOURITES, ViewState.Error);
setErrorMessageFor(FETCH_USER_FAVOURITES, f.message);
setStateFor(fetchUserFavouritesKey, ViewState.Error);
setErrorMessageFor(fetchUserFavouritesKey, f.message);
}
}
}
10 changes: 5 additions & 5 deletions lib/viewmodels/profile/user_projects_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:mobile_app/viewmodels/base_viewmodel.dart';

class UserProjectsViewModel extends BaseModel {
// ViewState Keys
String FETCH_USER_PROJECTS = 'fetch_user_projects';
String fetchUserProjectsKey = 'fetch_user_projects';

final ProjectsApi _projectsApi = locator<ProjectsApi>();
final LocalStorageService _localStorageService =
Expand Down Expand Up @@ -48,16 +48,16 @@ class UserProjectsViewModel extends BaseModel {
);
} else {
// Set State as busy only very first time..
setStateFor(FETCH_USER_PROJECTS, ViewState.Busy);
setStateFor(fetchUserProjectsKey, ViewState.Busy);
// fetch projects for the very first time..
previousUserProjectsBatch = await _projectsApi.getUserProjects(
userId ?? _localStorageService.currentUser.data.id);
}
userProjects.addAll(previousUserProjectsBatch.data);
setStateFor(FETCH_USER_PROJECTS, ViewState.Success);
setStateFor(fetchUserProjectsKey, ViewState.Success);
} on Failure catch (f) {
setStateFor(FETCH_USER_PROJECTS, ViewState.Error);
setErrorMessageFor(FETCH_USER_PROJECTS, f.message);
setStateFor(fetchUserProjectsKey, ViewState.Error);
setErrorMessageFor(fetchUserProjectsKey, f.message);
}
}
}
Loading

0 comments on commit b5dcde1

Please sign in to comment.