Codelessly / ResponsiveFramework

Easily make Flutter apps responsive. Automatically adapt UI to different screen sizes. Responsiveness made simple. Demo: https://gallery.codelessly.com/flutterwebsites/minimal/
https://codelessly.com
MIT License
1.25k stars 150 forks source link

type 'Null' is not a subtype of type 'double' in type cast #172

Open offical-waqas-khurshid opened 5 months ago

offical-waqas-khurshid commented 5 months ago

The following _TypeError was thrown building ConditionalRouteWidget(dirty, dependencies: [InheritedResponsiveBreakpoints, _ModalScopeStatus]): type 'Null' is not a subtype of type 'double' in type cast

The relevant error-causing widget was: ConditionalRouteWidget ConditionalRouteWidget:file:///C:/Users/waqas.khursheed/Desktop/FlutterMinimalWebsite/lib/main_advanced.dart:41:18 When the exception was thrown, this was the stack:

0 new ResponsiveValue (package:responsive_framework/src/responsive_value.dart:47:61)

1 MyApp.build... (package:minimal/main_advanced.dart:53:32)

2 ConditionalRouteWidget.build (package:minimal/utils/conditional_route_widget.dart:26:21)

3 StatelessElement.build (package:flutter/src/widgets/framework.dart:5550:49)

4 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5480:15)

5 Element.rebuild (package:flutter/src/widgets/framework.dart:5196:7)

6 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:5462:5)

7 ComponentElement.mount (package:flutter/src/widgets/framework.dart:5456:5)

... Normal element mounting (182 frames)

189 Element.inflateWidget (package:flutter/src/widgets/framework.dart:4335:16)

190 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6893:36)

191 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6905:32)

... Normal element mounting (492 frames)

683 Element.inflateWidget (package:flutter/src/widgets/framework.dart:4335:16)

684 Element.updateChild (package:flutter/src/widgets/framework.dart:3846:18)

685 _RawViewElement._updateChild (package:flutter/src/widgets/view.dart:291:16)

686 _RawViewElement.mount (package:flutter/src/widgets/view.dart:314:5)

... Normal element mounting (7 frames)

693 Element.inflateWidget (package:flutter/src/widgets/framework.dart:4335:16)

694 Element.updateChild (package:flutter/src/widgets/framework.dart:3846:18)

695 RootElement._rebuild (package:flutter/src/widgets/binding.dart:1354:16)

696 RootElement.mount (package:flutter/src/widgets/binding.dart:1323:5)

697 RootWidget.attach. (package:flutter/src/widgets/binding.dart:1276:18)

698 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2844:19)

699 RootWidget.attach (package:flutter/src/widgets/binding.dart:1275:13)

700 WidgetsBinding.attachToBuildOwner (package:flutter/src/widgets/binding.dart:1088:27)

701 WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:1070:5)

702 WidgetsBinding.scheduleAttachRootWidget. (package:flutter/src/widgets/binding.dart:1056:7)

706 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

(elided 3 frames from class _Timer and dart:async-patch)

EkjyotSandhu12 commented 5 months ago

Yes facing the same issue Right now i am using 1.1.1. Just to hide the error

pstemporowski commented 4 months ago

To ensure all scenarios are accounted for, including the one in the example where 'mobile' is specified along with two values, it would be necessary to set a default value. This adjustment will help cover cases that the current condition in your case misses.

EkjyotSandhu12 commented 3 months ago
    return ResponsiveScaledBox(
      width: ResponsiveValue<double>(
        context,
        conditionalValues: [
          //Scale:- the application will scale and maintain ratio of designScreenWidth pixels in any resolution by scaling.
          Condition.largerThan(
            breakpoint: 0,
            value: ThemeConstants.designScreenWidth,
          ),
        ],
        defaultValue: 0,  // <-- ADD THIS
      ).value,
      child: ClampingScrollWrapper.builder(
        dragWithMouse: true,
        context,
        child,
      ),
    );
rayliverified commented 5 days ago

This was a tough call with a long history and limitations of Dart's type capabilities. Making it non-nullable broke usages that require nullable values.

What's remaining is the confusion between typed null / <double?> non-nullable and the value's nullability. Any suggestions?

lpdevit commented 4 days ago

This was a tough call with a long history and limitations of Dart's type capabilities.

Making it non-nullable broke usages that require nullable values.

What's remaining is the confusion between typed null / <double?> non-nullable and the value's nullability.

Any suggestions?

Hi, same problem here, any suggestions? Thank you for your great job!