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

Use CupertinoAlertDialog crash,The getter 'alertDialogLabel' was called on null. #23047

Closed
luohaohaha opened this issue Oct 13, 2018 · 11 comments

Comments

@luohaohaha
Copy link

commented Oct 13, 2018

It works fine on Android and 0.9.6, and iOS crashes after the update.
my code

WillPopScope(
              child:  Platform.isAndroid?AlertDialog(
                title:  Text((null == title || title.isEmpty)?'提示':title),
                content: Text(tip ?? '',style: TextStyle(color: theme.textTheme.caption.color,fontSize: 15.0)),
                actions:actions,titlePadding: EdgeInsets.all(16.0),contentPadding: EdgeInsets.all(16.0),
              ):CupertinoAlertDialog(
                title:  Text((null == title || title.isEmpty)?'提示':title),
                content: Text(tip ?? '',style: TextStyle(color: theme.textTheme.caption.color,fontSize: 15.0)),
                actions:actions,
              ),
              onWillPop: () async => cancel);

crash log

flutter: The following NoSuchMethodError was thrown building LayoutBuilder:
flutter: The getter 'alertDialogLabel' was called on null.
flutter: Receiver: null
flutter: Tried calling: alertDialogLabel
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0      Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:50:5)
flutter: #1      CupertinoAlertDialog.build.<anonymous closure> (package:flutter/src/cupertino/dialog.dart:244:40)
flutter: #2      _LayoutBuilderElement._layout.<anonymous closure> (package:flutter/src/widgets/layout_builder.dart:111:26)
flutter: #3      BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2253:19)
flutter: #4      _LayoutBuilderElement._layout (package:flutter/src/widgets/layout_builder.dart:107:11)
flutter: #5      RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:1727:58)
flutter: #6      PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:796:15)
flutter: #7      RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:1727:13)
flutter: #8      _RenderLayoutBuilder.performLayout (package:flutter/src/widgets/layout_builder.dart:205:5)
flutter: #9      RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
flutter: #10     RenderPadding.performLayout (package:flutter/src/rendering/shifted_box.dart:199:11)
flutter: #11     RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
flutter: #12     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
flutter: #13     RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
flutter: #14     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
flutter: #15     RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
flutter: #16     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
flutter: #17     RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
flutter: #18     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
flutter: #19     RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
flutter: #20     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
flutter: #21     RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
flutter: #22     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
flutter: #23     RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
flutter: #24     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:108:13)
flutter: #25     RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:2884:13)
flutter: #26     RenderObject.layout (package:flutter/src/rendering/object.dart:1631:7)
flutter: #27     RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
flutter: #28     RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1506:7)
flutter: #29     PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:765:18)
flutter: #30     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:270:19)
flutter: #31     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:671:13)
flutter: #32     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:208:5)
flutter: #33     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
flutter: #34     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
flutter: #35     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
flutter: #36     _invoke (dart:ui/hooks.dart:139:13)
flutter: #37     _drawFrame (dart:ui/hooks.dart:128:3)
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════

doctor

LuoHaoMAC:wts_flutter-new haoluo$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel dev, v0.10.0, on Mac OS X 10.13.6 17G65, locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.2)
[✓] iOS toolchain - develop for iOS devices (Xcode 9.3)
[✓] Android Studio (version 3.1)
[✓] Connected device (2 available)

• No issues found!

@zoechi zoechi added this to the Goals milestone Oct 15, 2018

@xster xster added the severe: crash label Oct 23, 2018

@xster xster added this to Easy fix in iOS Framework Oct 23, 2018

@Julyyq

This comment has been minimized.

Copy link

commented Oct 23, 2018

Got same error at 0.10.2-pre.30 version.

@szotp

This comment has been minimized.

Copy link

commented Nov 7, 2018

Any workarounds? Seems like pretty severe issue if alerts do not work at all.

@Daibaku0615

This comment has been minimized.

Copy link

commented Nov 7, 2018

I think this is related to new version of flutter.
After I upgraded to 0.10.2 it became show this error all of a sudden.

@Adrianogba

This comment has been minimized.

Copy link

commented Nov 7, 2018

Yeah, this problem exists since 0.10.0.

@Sh1d0w

This comment has been minimized.

Copy link

commented Nov 7, 2018

Having the same issue after updating to the latest version 0.10.2, the app now is being broken.

@Sh1d0w

This comment has been minimized.

Copy link

commented Nov 8, 2018

I've found a solution to the problem, had to add fallback to localizationsDelegates, as follows:

localizationsDelegates: [
    .....
    const FallbackCupertinoLocalisationsDelegate(),
]

And the delegate:

class FallbackCupertinoLocalisationsDelegate
    extends LocalizationsDelegate<CupertinoLocalizations> {
  const FallbackCupertinoLocalisationsDelegate();

  @override
  bool isSupported(Locale locale) => true;

  @override
  Future<CupertinoLocalizations> load(Locale locale) =>
      DefaultCupertinoLocalizations.load(locale);

  @override
  bool shouldReload(FallbackCupertinoLocalisationsDelegate old) => false;
}

Hope it helps you guys.

@xster

This comment has been minimized.

Copy link
Contributor

commented Nov 10, 2018

Deduping #13452

@xster xster closed this Nov 10, 2018

@longsirhero

This comment has been minimized.

Copy link

commented Nov 13, 2018

Got same error at 0.11.3 version. Xcode 10.1 , Simulator iPhone XR - 12.1

@allanwolski

This comment has been minimized.

Copy link

commented Nov 22, 2018

Got same error at channel beta, v0.11.9, on Mac OS X 10.13.6

@Adrianogba

This comment has been minimized.

Copy link

commented Mar 9, 2019

Still happening on flutter 1.3.4, this was never fixed.

@HuberCui

This comment has been minimized.

Copy link

commented Mar 30, 2019

I've found a solution to the problem, had to add fallback to localizationsDelegates, as follows:

localizationsDelegates: [
    .....
    const FallbackCupertinoLocalisationsDelegate(),
]

And the delegate:

class FallbackCupertinoLocalisationsDelegate
    extends LocalizationsDelegate<CupertinoLocalizations> {
  const FallbackCupertinoLocalisationsDelegate();

  @override
  bool isSupported(Locale locale) => true;

  @override
  Future<CupertinoLocalizations> load(Locale locale) =>
      DefaultCupertinoLocalizations.load(locale);

  @override
  bool shouldReload(FallbackCupertinoLocalisationsDelegate old) => false;
}

Hope it helps you guys.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.