Skip to content

Dart type checking became more strict #5605

Closed
@drewwarren

Description

@drewwarren

I have a function

double get packedPercent =>
      deadline.totalItems == 0 ? 0 : packedCount / deadline.totalItems;

This function used to work fine, even when deadline.totalItems was 0. Now it fails when a type error when deadline.totalItems is 0.

I'm guessing this is because I am returning an int 0 instead of a double 0.0.

I do not get any output from dart analysis related to this, even when using https://github.com/raw/flutter/flutter/master/.analysis_options

StoreManager: ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
StoreManager: The following assertion was thrown building _Deadline:
StoreManager: type 'int' is not a subtype of type 'double' of 'function result' where
StoreManager:   int is from dart:core
StoreManager:   double is from dart:core
StoreManager: Either the assertion indicates an error in the framework itself, or we should provide substantially
StoreManager: more information in this error message to help you determine and fix the underlying cause.
StoreManager: In either case, please report this assertion by filing a bug on GitHub:
StoreManager:   https://github.com/flutter/flutter/issues/new
StoreManager: When the exception was thrown, this was the stack:
StoreManager: #0      _Deadline.packedPercent (lib/routes/dashboard/deadlines.dart:74)
StoreManager: #1      _Deadline.packedPercentAndTimeLeft (lib/routes/dashboard/deadlines.dart:137)
StoreManager: #2      _Deadline.build (lib/routes/dashboard/deadlines.dart:93)
StoreManager: #3      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:2027)
StoreManager: #4      BuildableElement.rebuild (package:flutter/src/widgets/framework.dart:1941)
StoreManager: #5      ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:2013)
StoreManager: #6      ComponentElement.mount (package:flutter/src/widgets/framework.dart:2008)
StoreManager: #7      Element.inflateWidget (package:flutter/src/widgets/framework.dart:1584)
StoreManager: #8      MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:2780)
StoreManager: #9      Element.inflateWidget (package:flutter/src/widgets/framework.dart:1584)
StoreManager: #10     Element.updateChild (package:flutter/src/widgets/framework.dart:1461)
StoreManager: #11     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:2039)
StoreManager: #12     BuildableElement.rebuild (package:flutter/src/widgets/framework.dart:1941)
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    customer: fast (g3)waiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter responds

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions