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

type 'Null' is not a subtype of type 'GenericFunctionTypeElement' in type cast at offset <number> #53330

Closed
shubham-jain2 opened this issue Aug 24, 2023 · 1 comment
Labels
area-migration (deprecated) Deprecated: this label is no longer actively used (was: issues with the `dart migrate` tool).

Comments

@shubham-jain2
Copy link

Flutter : 3.7.0, Dart : 2.9

While running the dart migrate tool to migrate to null-safety got this error.

type 'Null' is not a subtype of type 'GenericFunctionTypeElement' in type cast at offset 857 in .../lib/app_specific_utils/_core/app_cloud_provider.dart (DioError)

#0 EdgeBuilder.visitNamedType (package:nnbd_migration/src/edge_builder.dart:1488:36)
#1 NamedTypeImpl.accept (package:analyzer/src/dart/ast/ast.dart:9003:50)
#2 EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2375:24)
#3 EdgeBuilder.visitCatchClause (package:nnbd_migration/src/edge_builder.dart:666:5)
#4 CatchClauseImpl.accept (package:analyzer/src/dart/ast/ast.dart:1708:50)
#5 EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2375:24)
#6 EdgeBuilder._dispatchList (package:nnbd_migration/src/edge_builder.dart:2393:7)
#7 EdgeBuilder.visitTryStatement (package:nnbd_migration/src/edge_builder.dart:2001:7)
#8 TryStatementImpl.accept (package:analyzer/src/dart/ast/ast.dart:12926:50)
#9 EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2375:24)
#10 EdgeBuilder.visitNode (package:nnbd_migration/src/edge_builder.dart:1567:9)
#11 GeneralizingAstVisitor.visitStatement (package:analyzer/dart/ast/visitor.dart:649:40)
#12 GeneralizingAstVisitor.visitBlock (package:analyzer/dart/ast/visitor.dart:170:32)
#13 BlockImpl.accept (package:analyzer/src/dart/ast/ast.dart:1260:50)
#14 EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2375:24)
#15 EdgeBuilder.visitNode (package:nnbd_migration/src/edge_builder.dart:1567:9)
#16 GeneralizingAstVisitor.visitFunctionBody (package:analyzer/dart/ast/visitor.dart:362:46)
#17 GeneralizingAstVisitor.visitBlockFunctionBody (package:analyzer/dart/ast/visitor.dart:173:56)
#18 BlockFunctionBodyImpl.accept (package:analyzer/src/dart/ast/ast.dart:1207:50)
#19 EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2375:24)
#20 EdgeBuilder._handleExecutableDeclaration (package:nnbd_migration/src/edge_builder.dart:2682:7)
#21 EdgeBuilder.visitMethodDeclaration (package:nnbd_migration/src/edge_builder.dart:1393:5)
#22 MethodDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:8533:50)
#23 EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2375:24)
#24 EdgeBuilder._dispatchList (package:nnbd_migration/src/edge_builder.dart:2393:7)
#25 EdgeBuilder.visitClassOrMixinOrExtensionDeclaration (package:nnbd_migration/src/edge_builder.dart:717:7)
#26 EdgeBuilder.visitClassDeclaration (package:nnbd_migration/src/edge_builder.dart:676:5)
#27 ClassDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:2000:50)
#28 EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2375:24)
#29 EdgeBuilder.visitNode (package:nnbd_migration/src/edge_builder.dart:1567:9)
#30 GeneralizingAstVisitor.visitCompilationUnit (package:analyzer/dart/ast/visitor.dart:216:52)
#31 CompletenessTracker.visitCompilationUnit. (package:nnbd_migration/src/utilities/completeness_tracker.dart:52:24)
#32 PermissiveModeVisitor.reportExceptionsIfPermissive (package:nnbd_migration/src/utilities/permissive_mode.dart:26:24)
#33 CompletenessTracker.visitCompilationUnit (package:nnbd_migration/src/utilities/completeness_tracker.dart:43:5)
#34 CompilationUnitImpl.accept (package:analyzer/src/dart/ast/ast.dart:2501:50)
#35 NullabilityMigrationImpl.processInput (package:nnbd_migration/src/nullability_migration_impl.dart:224:12)
#36 NonNullableFix.processUnit (package:nnbd_migration/src/front_end/non_nullable_fix.dart:162:16)
#37 _FixCodeProcessor.runLaterPhases. (package:nnbd_migration/migration_cli.dart:1088:19)
#38 _FixCodeProcessor.processResources (package:nnbd_migration/migration_cli.dart:1020:26)

#39 _FixCodeProcessor.runLaterPhases (package:nnbd_migration/migration_cli.dart:1086:5)

#40 MigrationCliRunner.run (package:nnbd_migration/migration_cli.dart:695:24)

#41 MigrateCommand.run (package:dartdev/src/commands/migrate.dart:37:7)

#42 CommandRunner.runCommand (package:args/command_runner.dart:212:13)

#43 DartdevRunner.runCommand (package:dartdev/dartdev.dart:241:18)

#44 runDartdev (package:dartdev/dartdev.dart:65:18)

#45 main (file:///opt/s/w/ir/x/w/sdk/pkg/dartdev/bin/dartdev.dart:11:3)

========================================================================
The file at the path is

abstract class AppCloudProvider
extends BaseApiProvider {
var path = "";
Dio _apiClient;

AppCloudProvider(this.path, this._apiClient);

@OverRide
Future<AppResponse> delete(T item) async {
try {
var response = await _apiClient.delete("$path/${item.uniqueId}");
return AppResponse(data: response.data);
} on DioError catch (e) {
return ApiHelper.processErrorInDioServerResponse(e);
}
}

@OverRide
Future<AppResponse> update(T item) async {
try {
var data = toMap(item);
var response = await apiClient.post(updatePath(), data: data);
try {
Map<String, dynamic> data = response.data;
if (data[AppColumn.code] == 1) {
return AppResponse(data: item);
} else {
return AppResponse(
data: null, error: ErrorResponse.fromResponse(response));
}
} catch (e) {
return ApiHelper.processErrorInParsing(e);
}
} on DioError catch (e) {
print(e.message);
return ApiHelper.processErrorInDioServerResponse(e);
}
}

String updatePath() => path;

@OverRide
Future<AppResponse> add(T item) async {
return update(item);
// try {
// var response =
// await _apiClient.post("$path/${item.uniqueId}", data: toMap(item));
// return AppResponse(data: response.data);
// } on DioError catch (e) {
// return ApiHelper.processErrorInDioServerResponse(e);
// }
}

@OverRide
Future addItems(List items) =>
throw Exception("not implemented");

@OverRide
Future updateItems(List items)=>
throw Exception("not implemented");

@OverRide
Future<AppResponse> fetch(String id) async {
try {
var response = await _apiClient.get(updateFetchPath(id));

  try {
    Map<String, dynamic> data = response.data;
    if (data[AppColumn.code] == 1) {
      return AppResponse(data: fromMap(data["Data"]));
    } else {
      return AppResponse(
          data: null, error: ErrorResponse.fromResponse(response));
    }
  } catch (e) {
    return ApiHelper.processErrorInParsing(e);
  }
} on DioError catch (e) {
  print(e.message);
  return ApiHelper.processErrorInDioServerResponse(e);
}

}

@OverRide
Future<AppResponse<AppListManager>> fetchItems(
{List orderBy,
int limitBy,
int startFrom,
List where,
bool isClearOldItems = false,
Map<String, dynamic> options}) async {
// print("$this --fetching items");

/// saving query info too for next time fetch from local db
var secondaryInfo = Map<String, dynamic>();

if (where != null) {
  where.forEach((item) => secondaryInfo[item.key] =
      (item.value is String) ? item.value : "${item.value}");
}
if (startFrom != null) secondaryInfo["page"] = "$startFrom";

try {
  Uri uri = Uri(path: path, queryParameters: secondaryInfo);

  var response = await _apiClient.getUri(uri);
  try {
    if (response.data[AppColumn.code] != 5) {
      if (response.data != null && response.data[AppColumn.data] != null) {
        var items = processItemsFromResponse(
            response.data[AppColumn.data], secondaryInfo);
        return AppResponse.fromData(AppListManager(
            items,
            limitBy,
            //added check when the data field directly contains a list instead of nested object
            (response.data[AppColumn.data] is List)?1:response.data[AppColumn.data]["page"],
            (response.data[AppColumn.data] is List)?99:response.data[AppColumn.data]["total_pages"]));
      } else {
        return AppResponse(
            data: null, error: ErrorResponse.fromResponse(response));
      }
    } else {
      return AppResponse(
          data: null,
          error: ErrorResponse.error("Your Account is Deactivated"));
    }
  } catch (e) {
    return ApiHelper.processErrorInParsing(e);
  }
} on DioError catch (e) {
  return ApiHelper.processErrorInDioServerResponse(e);
}

}

@OverRide
Map<String, dynamic> toMap(T item) {
return item.toMap();
}

/// override this method if response doesn't contains direct list of items
List processItemsFromResponse(data, Map<String, dynamic> secondaryInfo) {
List items = (data as List).map((record) {
var item = fromMap(record);
return item;
}).toList();
return items;
}

Dio get apiClient => _apiClient;

String updateFetchPath(String id) {
return "$path/$id";
}
}

@lrhn lrhn added the area-migration (deprecated) Deprecated: this label is no longer actively used (was: issues with the `dart migrate` tool). label Aug 24, 2023
@stereotype441
Copy link
Member

As of 1c7fe71, the null safety migration tool has been removed from active development and retired. No further work on the tool is planned.

If you still need help, or you believe this issue has been closed in error, please feel free to reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-migration (deprecated) Deprecated: this label is no longer actively used (was: issues with the `dart migrate` tool).
Projects
None yet
Development

No branches or pull requests

3 participants