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 · 17 comments
Closed
Labels
f: cupertino framework severe: crash severe: regression

Comments

@luohaohaha
Copy link

@luohaohaha luohaohaha 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 framework f: cupertino labels Oct 15, 2018
@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
Copy link

@Julyyq Julyyq commented Oct 23, 2018

Got same error at 0.10.2-pre.30 version.

@zoechi zoechi added the severe: regression label Oct 24, 2018
@szotp
Copy link

@szotp szotp commented Nov 7, 2018

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

@ghost
Copy link

@ghost ghost 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
Copy link

@Adrianogba Adrianogba commented Nov 7, 2018

Yeah, this problem exists since 0.10.0.

@Sh1d0w
Copy link

@Sh1d0w Sh1d0w commented Nov 7, 2018

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

@Sh1d0w
Copy link

@Sh1d0w Sh1d0w 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
Copy link
Member

@xster xster commented Nov 10, 2018

Deduping #13452

@xster xster closed this as completed Nov 10, 2018
@longsirhero
Copy link

@longsirhero longsirhero commented Nov 13, 2018

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

@allanwolski
Copy link

@allanwolski allanwolski commented Nov 22, 2018

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

@Adrianogba
Copy link

@Adrianogba Adrianogba commented Mar 9, 2019

Still happening on flutter 1.3.4, this was never fixed.

@HuberCui
Copy link

@HuberCui HuberCui 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!

@MazinFlutter
Copy link

@MazinFlutter MazinFlutter commented Oct 19, 2019

Same thing in Flutter 1.9.1 stable channel.

@gcmsg
Copy link

@gcmsg gcmsg commented Oct 24, 2019

image
Please add this to your localizationsDelegates list @MazinFlutter

@MazinFlutter
Copy link

@MazinFlutter MazinFlutter commented Oct 24, 2019

Thanks @acebeing !

@joelbrostrom
Copy link

@joelbrostrom joelbrostrom commented Nov 27, 2019

Just to clarify where to put the code:

MaterialApp(
  localizationsDelegates: const [
    S.delegate,
    GlobalMaterialLocalizations.delegate,
    GlobalCupertinoLocalizations.delegate, //<--- Add this to your localizationsDelegates in your Material App
    GlobalWidgetsLocalizations.delegate,
  ],
  supportedLocales: S.delegate.supportedLocales,
  theme: appTheme,
  home: HomeScreen(),
);

@tarunjain3
Copy link

@tarunjain3 tarunjain3 commented Jun 6, 2020

Just to clarify where to put the code:

MaterialApp(
  localizationsDelegates: const [
    S.delegate,
    GlobalMaterialLocalizations.delegate,
    GlobalCupertinoLocalizations.delegate, //<--- Add this to your localizationsDelegates in your Material App
    GlobalWidgetsLocalizations.delegate,
  ],
  supportedLocales: S.delegate.supportedLocales,
  theme: appTheme,
  home: HomeScreen(),
);

worked for me ..thanks

@github-actions
Copy link

@github-actions github-actions bot commented Aug 14, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
f: cupertino framework severe: crash severe: regression
Projects
No open projects
iOS Framework
  
Done
Development

No branches or pull requests