codegrue / flutter_material_pickers

A flutter package for displaying common picker dialogs.
https://pub.dev/packages/flutter_material_pickers
MIT License
98 stars 61 forks source link

Exception thrown with showDivider property #10

Closed fernando-s97 closed 4 years ago

fernando-s97 commented 4 years ago

With the following code

showMaterialScrollPicker(
      context: context,
      maxLongSide: 350,
      title: 'Pick a language'.tr(),
      selectedItem: getSupportedLanguage(
        nameOrLocale: Right(context.locale),
      ).name,
      items: kSupportedLanguages.map((e) => e.name).toList(),
      onChanged: (value) {
        context.locale = getSupportedLanguage(
          nameOrLocale: Left(value),
        ).locale;
      },
      // showDivider: false,
    )

I'm receiving the following exception:

═══════════════════════════════════════════════════════ The following assertion was thrown building LayoutBuilder: Failed assertion: boolean expression must not be null

The relevant error-causing widget was: MaterialApp file:..../lib/presentation/core/app_widget.dart:61:14 When the exception was thrown, this was the stack:

0 _ScrollPickerState.build. (package:flutter_material_pickers/pickers/scroll_picker.dart:92:34)

1 _LayoutBuilderElement._layout. (package:flutter/src/widgets/layout_builder.dart:121:33)

2 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2620:19)

3 _LayoutBuilderElement._layout (package:flutter/src/widgets/layout_builder.dart:117:11)

4 RenderObject.invokeLayoutCallback. (package:flutter/src/rendering/object.dart:1868:58)

... ═══════════════════════════════════════════════════════

I need to manually set showDivider to either true or false. The default true value isn't working

OBS: version 1.7.3

fernando-s97 commented 4 years ago

As per my debug, the ScrollPicker class constructor should be

ScrollPicker({
    Key key,
    @required this.items,
    @required this.initialValue,
    @required this.onChanged,
    **bool showDivider,**
  })  : assert(items != null),
        **showDivider = showDivider ?? true,**
        super(key: key);

instead of

ScrollPicker({
    Key key,
    @required this.items,
    @required this.initialValue,
    @required this.onChanged,
    this.showDivider: true,
  })  : assert(items != null),
        super(key: key);
codegrue commented 4 years ago

Fixed in 1.7.4