Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
channel: 'stable'
- run: dart pub get
- run: dart format --fix .
- run: dart format .
- run: dart analyze
- run: flutter test --coverage
- name: Setup LCOV
Expand Down
10 changes: 7 additions & 3 deletions lib/import_resolver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ class ImportResolver {
for (var lib in libs) {
if (_isCoreDartType(lib)) continue;

if (lib.exportNamespace.definedNames2.keys.contains(element?.firstFragment.name2)) {
final package = lib.firstFragment.libraryFragment?.source.uri.pathSegments.first;
if (lib.exportNamespace.definedNames2.keys
.contains(element?.firstFragment.name2)) {
final package =
lib.firstFragment.libraryFragment?.source.uri.pathSegments.first;
if (targetFilePath.startsWith(RegExp('^$package/'))) {
return p.posix
.relative(element?.firstFragment.libraryFragment?.source.uri.path ?? '', from: targetFilePath)
.relative(
element?.firstFragment.libraryFragment?.source.uri.path ?? '',
from: targetFilePath)
.replaceFirst('../', '');
} else {
return element?.firstFragment.libraryFragment?.source.uri.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ mixin RouterExtensionBuilderHelper {
required RouteConfig route,
required DartEmitter emitter,
}) {
final methodName = '$navigationMethod${route.name?.capitalize}';
final methodName = route.parentClassName != null
? '${navigationMethod}Nested${route.name?.capitalize}In${route.parentClassName}'
: '$navigationMethod${route.name?.capitalize}';

final methodReturnType = route.isProcessedReturnTypeDynamic
? route.processedReturnType
Expand Down
2 changes: 1 addition & 1 deletion test/bottomsheets/bottomsheet_class_generator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ void main() {
});
});
});
}
}
79 changes: 39 additions & 40 deletions test/form/constant_test_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,39 +82,44 @@ EmailValueKey: emailController.text,
''';
const kExample1ViewModelExtensionForGetters = '''

extension ValueProperties on FormViewModel {
bool get isFormValid =>
this.fieldsValidationMessages.values.every((element) => element == null);
extension ValueProperties on FormStateHelper {
bool get hasAnyValidationMessage =>
this.fieldsValidationMessages.values.any((validation) => validation != null);

bool get isFormValid {

if (!_autoTextFieldValidation) this.validateForm();

return !hasAnyValidationMessage;
}

String? get nameValue => this.formValueMap[NameValueKey] as String?;
String? get emailValue => this.formValueMap[EmailValueKey] as String?;
DateTime? get dateValue => this.formValueMap[DateValueKey] as DateTime?;
String? get dropDownValue => this.formValueMap[DropDownValueKey] as String?;

set nameValue(String? value) {
this.setData(
this.formValueMap
..addAll({
NameValueKey: value,
}),
);

if (_TestViewTextEditingControllers.containsKey(NameValueKey)) {
_TestViewTextEditingControllers[NameValueKey]?.text = value ?? \'\';
}
this.setData(
this.formValueMap..addAll({NameValueKey: value}),
);

if (_TestViewTextEditingControllers.containsKey(NameValueKey)) {
_TestViewTextEditingControllers[NameValueKey]?.text = value ?? '' ;
}
}



set emailValue(String? value) {
this.setData(
this.formValueMap
..addAll({
EmailValueKey: value,
}),
);

if (_TestViewTextEditingControllers.containsKey(EmailValueKey)) {
_TestViewTextEditingControllers[EmailValueKey]?.text = value ?? \'\';
}
}
this.setData(
this.formValueMap..addAll({EmailValueKey: value}),
);

if (_TestViewTextEditingControllers.containsKey(EmailValueKey)) {
_TestViewTextEditingControllers[EmailValueKey]?.text = value ?? '' ;
}
}



bool get hasName => this.formValueMap.containsKey(NameValueKey) && (nameValue?.isNotEmpty ?? false);
bool get hasEmail => this.formValueMap.containsKey(EmailValueKey) && (emailValue?.isNotEmpty ?? false);
Expand All @@ -134,7 +139,7 @@ String? get dropDownValidationMessage => this.fieldsValidationMessages[DropDownV
''';
const kExample1ViewModelExtensionForMethods = '''

extension Methods on FormViewModel {
extension Methods on FormStateHelper {
Future<void> selectDate({
required BuildContext context,
required DateTime initialDate,
Expand All @@ -153,29 +158,23 @@ extension Methods on FormViewModel {
DateValueKey: selectedDate}),
);
}

if (_autoTextFieldValidation) {
this.validateForm();
}
}

if (_autoTextFieldValidation) this.validateForm();
}

void setDropDown(String dropDown) {
this.setData(
this.formValueMap..addAll({DropDownValueKey: dropDown}),
);

if (_autoTextFieldValidation) {
this.validateForm();
}
}

if (_autoTextFieldValidation) this.validateForm();
}


setNameValidationMessage(String? validationMessage) => this.fieldsValidationMessages[NameValueKey] = validationMessage;
setEmailValidationMessage(String? validationMessage) => this.fieldsValidationMessages[EmailValueKey] = validationMessage;
setDateValidationMessage(String? validationMessage) => this.fieldsValidationMessages[DateValueKey] = validationMessage;
setDropDownValidationMessage(String? validationMessage) => this.fieldsValidationMessages[DropDownValueKey] = validationMessage;
void setNameValidationMessage(String? validationMessage) => this.fieldsValidationMessages[NameValueKey] = validationMessage;
void setEmailValidationMessage(String? validationMessage) => this.fieldsValidationMessages[EmailValueKey] = validationMessage;
void setDateValidationMessage(String? validationMessage) => this.fieldsValidationMessages[DateValueKey] = validationMessage;
void setDropDownValidationMessage(String? validationMessage) => this.fieldsValidationMessages[DropDownValueKey] = validationMessage;

/// Clears text input fields on the Form
void clearForm() {
Expand Down
16 changes: 8 additions & 8 deletions test/form/form_builder_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,14 @@ void main() {
});
});
group('addFormViewModelExtensionForGetters -', () {
test('When called, Should add formviewmodel extension', () {
builder.addFormViewModelExtensionForGetters();

expect(builder.serializeStringBuffer,
kExample1ViewModelExtensionForGetters);
},
skip:
'This is too fickle. It\'s failing due to spacing issues. I want something more robust here');
test(
'When called, Should add formviewmodel extension',
() {
builder.addFormViewModelExtensionForGetters();
expect(builder.serializeStringBuffer,
kExample1ViewModelExtensionForGetters);
},
);
});
group('addFormViewModelExtensionForMethods -', () {
test('When called, Should add extension Methods on FormViewModel', () {
Expand Down
Loading
Loading