Skip to content

Crash when compiling after making a code change to a Flutter application that uses Dart 3 and records #51815

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

Closed
maxluchterhand1 opened this issue Mar 22, 2023 · 2 comments
Assignees
Labels
legacy-area-front-end Legacy: Use area-dart-model instead.

Comments

@maxluchterhand1
Copy link

Hey,

we have a Flutter project that's on Dart 3. We were originally on the Flutter beta channel but switched to the Master after we had some issues with compiling.

Flutter 3.9.0-13.0.pre.3 • channel master • https://github.com/flutter/flutter.gitdd-assets ±✚  ets ±✚  
Framework • revision 5804c12323 (28 hours ago) • 2023-03-21 02:58:27 -0400
Engine • revision 1b289e20c2
Tools • Dart 3.0.0 (build 3.0.0-348.0.dev) • DevTools 2.22.2

We are using the following experimental features:
- sealed-class
- patterns
- records
- class-modifiers

Now we find ourselves in a situation where we cannot compile our application after making changes to certain files, although we are yet to figure out a pattern as to which files are affected. The error message is always the same:

Unhandled exception:
Crash when compiling file:///....../body_chart_anatomy_preview.dart at character offset 941:
Not implemented

#0      TypeBuilderComputer.visitRecordType (package:front_end/src/fasta/kernel/type_builder_computer.dart:197:5)
#1      RecordType.accept (package:kernel/ast.dart:13385:14)
#2      TypeBuilderComputer.visitInterfaceType.<anonymous closure> (package:front_end/src/fasta/kernel/type_builder_computer.dart:101:65)
#3      new _List.generate (dart:core-patch/array.dart:112:28)
#4      TypeBuilderComputer.visitInterfaceType (package:front_end/src/fasta/kernel/type_builder_computer.dart:100:23)
#5      InterfaceType.accept (package:kernel/ast.dart:12085:42)
#6      DillLoader.computeTypeBuilder (package:front_end/src/fasta/dill/dill_loader.dart:345:17)
#7      computeTypeBuilder (package:front_end/src/fasta/dill/dill_class_builder.dart:248:24)

This is the file in question:

import 'package:evalu_rehab/assessment/domain/assessment_result.dart';
import 'package:evalu_rehab/assessment/presentation/assessments/body_chart/body_chart_anatomy_data_point_stack.dart';
import 'package:evalu_rehab/assessment/presentation/assessments/body_chart/body_chart_anatomy_detail_view.dart';
import 'package:evalu_rehab/assessment/state/body_chart/body_chart_cubit.dart';
import 'package:evalu_rehab/assets/assets.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

class BodyChartAnatomyPreview extends StatelessWidget {
  const BodyChartAnatomyPreview({super.key});

  String _assetName(BodyChartAngle angle) {
    switch (angle) {
      case BodyChartAngle.front: return Assets.bodyAnatomy.front;
      case BodyChartAngle.back: return Assets.bodyAnatomy.back;
      case BodyChartAngle.side: return Assets.bodyAnatomy.side;
    }
  }

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        for (final value in [
          BodyChartAngle.front,
          BodyChartAngle.side,              <------------
          BodyChartAngle.back,
        ])
          Expanded(
            child: GestureDetector(
              onTap: () {
                showDialog(
                  context: context,
                  builder: (_) => BlocProvider.value(
                    value: context.read<BodyChartCubit>(),
                    child: BodyChartAnatomyDetailView(
                      bodyChartAngle: value,
                    ),
                  ),
                );
              },
              child: BodyChartAnatomyDataPointStack(
                anatomyView: Image.asset(_assetName(value)),
                bodyChartAngle: value,
              ),
            ),
          ),
      ],
    );
  }
}

The change I made to the file in order to cause the problem was simply changing the order of elements in the list at which I pointed with the arrow in the code sample. The only way to get the app to compile again is either reverting the change or running flutter clean.

This issue seems to me like this has to have already been noticed by someone. However, I could not find any issue here or over at Flutter's GitHub.

@maxluchterhand1 maxluchterhand1 changed the title Crash when compiling after making a code change to a Flutter application using Dart 3 and records Crash when compiling after making a code change to a Flutter application that uses Dart 3 and records Mar 22, 2023
@mit-mit mit-mit added the legacy-area-front-end Legacy: Use area-dart-model instead. label Mar 22, 2023
@bernaferrari
Copy link
Contributor

I've been waiting this for months. Thanks for reporting!!

@MostafaDadkhah
Copy link

I have this issue after add records to project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy-area-front-end Legacy: Use area-dart-model instead.
Projects
None yet
Development

No branches or pull requests

5 participants