Skip to content

Commit 43c4231

Browse files
committed
Update
1 parent 257a094 commit 43c4231

File tree

2 files changed

+21
-40
lines changed

2 files changed

+21
-40
lines changed

lib/src/generate_screen_bindings/_insight_mappers.dart

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ final _screenSegmentMapper = _InsightMapper(
3131
final path = insight.annotation.path ?? '';
3232
final screenSegment = p.joinAll(
3333
[
34-
path.isNotEmpty && path.startsWith(RegExp(r'[\\/]'))
35-
? path.substring(1)
36-
: path,
34+
path.isNotEmpty && path.startsWith(RegExp(r'[\\/]')) ? path.substring(1) : path,
3735
screenKey,
3836
],
3937
);
@@ -79,8 +77,7 @@ final insightMappers = [
7977
_InsightMapper(
8078
placeholder: Placeholders.IS_ACCESSIBLE_ONLY_IF_LOGGED_IN_AND_VERIFIED,
8179
mapInsights: (insight) async {
82-
final b =
83-
insight.annotation.isAccessibleOnlyIfLoggedInAndVerified ?? false;
80+
final b = insight.annotation.isAccessibleOnlyIfLoggedInAndVerified ?? false;
8481
return b.toString();
8582
},
8683
),
@@ -101,8 +98,7 @@ final insightMappers = [
10198
_InsightMapper(
10299
placeholder: Placeholders.IS_ALWAYS_ACCESSIBLE,
103100
mapInsights: (insight) async {
104-
final a =
105-
insight.annotation.isAccessibleOnlyIfLoggedInAndVerified ?? false;
101+
final a = insight.annotation.isAccessibleOnlyIfLoggedInAndVerified ?? false;
106102
final b = insight.annotation.isAccessibleOnlyIfLoggedIn ?? false;
107103
final c = insight.annotation.isAccessibleOnlyIfLoggedOut ?? false;
108104
if (a && b) {
@@ -128,8 +124,9 @@ final insightMappers = [
128124
placeholder: Placeholders.IS_REDIRECTABLE,
129125
mapInsights: (insight) async {
130126
final b = insight.annotation.isRedirectable ?? false;
131-
if (b) {
132-
for (final e in insight.annotation.internalParameters!) {
127+
final params = insight.annotation.internalParameters;
128+
if (b && params != null && params.isNotEmpty) {
129+
for (final e in params) {
133130
final field = FieldUtils.ofOrNull(e)!;
134131
if (field.nullable == true) {
135132
throw Exception(
@@ -144,10 +141,8 @@ final insightMappers = [
144141
_InsightMapper(
145142
placeholder: Placeholders.IP0,
146143
mapInsights: (insight) async {
147-
final params = insight.annotation.internalParameters
148-
?.map((e) => FieldUtils.ofOrNull(e))
149-
.nonNulls ??
150-
{};
144+
final params =
145+
insight.annotation.internalParameters?.map((e) => FieldUtils.ofOrNull(e)).nonNulls ?? {};
151146
if (params.isNotEmpty) {
152147
final a = params.map((e) {
153148
final fieldName = e.fieldPath!.join('_').toCamelCase();
@@ -175,10 +170,8 @@ final insightMappers = [
175170
_InsightMapper(
176171
placeholder: Placeholders.IP1,
177172
mapInsights: (insight) async {
178-
final params = insight.annotation.internalParameters
179-
?.map((e) => FieldUtils.ofOrNull(e))
180-
.nonNulls ??
181-
{};
173+
final params =
174+
insight.annotation.internalParameters?.map((e) => FieldUtils.ofOrNull(e)).nonNulls ?? {};
182175
if (params.isNotEmpty) {
183176
final a = params.map((e) {
184177
final fieldName = e.fieldPath!.join('_').toCamelCase();
@@ -198,10 +191,8 @@ final insightMappers = [
198191
_InsightMapper(
199192
placeholder: Placeholders.IP2,
200193
mapInsights: (insight) async {
201-
final params = insight.annotation.internalParameters
202-
?.map((e) => FieldUtils.ofOrNull(e))
203-
.nonNulls ??
204-
{};
194+
final params =
195+
insight.annotation.internalParameters?.map((e) => FieldUtils.ofOrNull(e)).nonNulls ?? {};
205196
if (params.isNotEmpty) {
206197
final a = params.map((e) {
207198
final fieldName = e.fieldPath!.join('_').toCamelCase();
@@ -219,10 +210,8 @@ final insightMappers = [
219210
_InsightMapper(
220211
placeholder: Placeholders.QP0,
221212
mapInsights: (insight) async {
222-
final params = insight.annotation.queryParameters
223-
?.map((e) => FieldUtils.ofOrNull(e))
224-
.nonNulls ??
225-
{};
213+
final params =
214+
insight.annotation.queryParameters?.map((e) => FieldUtils.ofOrNull(e)).nonNulls ?? {};
226215
if (params.isNotEmpty) {
227216
final a = params.map((e) {
228217
final fieldName = e.fieldPath!.join('_').toCamelCase();
@@ -250,10 +239,8 @@ final insightMappers = [
250239
_InsightMapper(
251240
placeholder: Placeholders.QP1,
252241
mapInsights: (insight) async {
253-
final params = insight.annotation.internalParameters
254-
?.map((e) => FieldUtils.ofOrNull(e))
255-
.nonNulls ??
256-
{};
242+
final params =
243+
insight.annotation.internalParameters?.map((e) => FieldUtils.ofOrNull(e)).nonNulls ?? {};
257244
if (params.isNotEmpty) {
258245
final a = params.map((e) {
259246
final fieldName = e.fieldPath!.join('_').toCamelCase();
@@ -270,10 +257,8 @@ final insightMappers = [
270257
_InsightMapper(
271258
placeholder: Placeholders.QP2,
272259
mapInsights: (insight) async {
273-
final params = insight.annotation.internalParameters
274-
?.map((e) => FieldUtils.ofOrNull(e))
275-
.nonNulls ??
276-
{};
260+
final params =
261+
insight.annotation.internalParameters?.map((e) => FieldUtils.ofOrNull(e)).nonNulls ?? {};
277262
if (params.isNotEmpty) {
278263
final a = params.map((e) {
279264
final fieldName = e.fieldPath!.join('_').toCamelCase();
@@ -315,5 +300,4 @@ enum Placeholders {
315300
TITLE,
316301
}
317302

318-
typedef _InsightMapper
319-
= InsightMapper<ClassInsight<ModelGenerateScreenBindings>, Placeholders>;
303+
typedef _InsightMapper = InsightMapper<ClassInsight<ModelGenerateScreenBindings>, Placeholders>;

lib/src/generate_screen_bindings/generate.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ Future<void> generateScreenBindings({
6868
final insights = <ClassInsight<ModelGenerateScreenBindings>>[];
6969

7070
// For each file...
71-
for (final filePathResult in sourceFileExplorerResults.filePathResults
72-
.where((e) => e.category == _Categories.DART)) {
71+
for (final filePathResult
72+
in sourceFileExplorerResults.filePathResults.where((e) => e.category == _Categories.DART)) {
7373
final filePath = filePathResult.path;
7474

7575
// Extract insights from the file.
@@ -78,9 +78,6 @@ Future<void> generateScreenBindings({
7878
filePath,
7979
);
8080

81-
printBlue(filePath);
82-
printRed(temp.length);
83-
8481
insights.addAll(temp);
8582
}
8683

0 commit comments

Comments
 (0)