Code Monkey home page Code Monkey logo

Comments (6)

lcuis avatar lcuis commented on July 29, 2024

Hi @Thembelani-M ,

Thanks for reporting this issue.

Is this error a compilation or an execution error?

Is there a line referred to by this error?

from search_choices.

Thembelani-M avatar Thembelani-M commented on July 29, 2024

@lcuis Thank you for the quick response.
This is an execution error.

When the exception was thrown, this was the stack: 
#0      _DropdownDialogState.listWithPagination.<anonymous closure>.<anonymous closure> (package:search_choices/src/dropdown/dropdown_dialog.dart:980:58)
#1      MappedListIterable.elementAt (dart:_internal/iterable.dart:415:31)
#2      ListIterator.moveNext (dart:_internal/iterable.dart:344:26)
#3      new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:189:27)
#4      new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
#5      new List.of (dart:core-patch/array_patch.dart:47:28)
#6      ListIterable.toList (dart:_internal/iterable.dart:214:7)
#7      _DropdownDialogState.listWithPagination.<anonymous closure> (package:search_choices/src/dropdown/dropdown_dialog.dart:981:16)
#8      _FutureBuilderState.build (package:flutter/src/widgets/async.dart:612:55)
#9      StatefulElement.build (package:flutter/src/widgets/framework.dart:5409:27)
#10     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5297:15)
#11     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5462:11)
#12     Element.rebuild (package:flutter/src/widgets/framework.dart:5016:7)
#13     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2779:19)
#14     WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:916:21)
#15     RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:360:5)
#16     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1297:15)
#17     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1227:9)
#18     SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1085:5)
#22     _invoke (dart:ui/hooks.dart:172:10)
#23     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:401:5)
#24     _drawFrame (dart:ui/hooks.dart:140:31)

from search_choices.

faizananwerali avatar faizananwerali commented on July 29, 2024

same issue.

type '_Map<String, String>' is not a subtype of type 'Null'

futureSearchFn: (String? keyword,
    String? orderBy,
    bool? orderAsc,
    List<Tuple2<String, String>>? filters,
    int? pageNb) async {
  try {
    var response = await http
        .get(Uri.parse(
            "${url}countries?page=${pageNb ?? 1}${(keyword == null || keyword.isEmpty) ? "" : "&name=$keyword"}"))
        .timeout(const Duration(seconds: 10));

    if (response.statusCode != 200) {
      throw Exception(
          "Failed to get data from the internet");
    }

    var data = json.decode(response.body);
    int nbResults = data["data"]["total"];
    var records =
        (data["data"]["data"] as List<dynamic>)
            .map((item) {
      return {
        "value": item?["id"].toString() ?? "",
        "name": item?["name"].toString() ?? "",
      };
    }).toList();

    print('records: $records');

    List<DropdownMenuItem> results = records.map<DropdownMenuItem>((item) =>
            DropdownMenuItem(
              value: item,
              child: Card(
                shape: RoundedRectangleBorder(
                  borderRadius:
                      BorderRadius.circular(4),
                  side: BorderSide(
                    color: Colors.blue,
                    width: 1,
                  ),
                ),
                margin: EdgeInsets.all(1),
                child: Padding(
                  padding:
                      const EdgeInsets.all(6),
                  child: Text("${item["name"]}"),
                ),
              ),
            ))
        .toList();
    return (Tuple2<List<DropdownMenuItem>, int>(
        results, nbResults));
  } catch (e) {
    print("Error: $e");
    throw Exception("Failed to fetch data");
  }
},
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following _TypeError was thrown building FutureBuilder<Tuple2<List<DropdownMenuItem<dynamic>>,
int>>(dirty, state: _FutureBuilderState<Tuple2<List<DropdownMenuItem<dynamic>>, int>>#54481):
type '_Map<String, String>' is not a subtype of type 'Null'

The relevant error-causing widget was:
  FutureBuilder<Tuple2<List<DropdownMenuItem<dynamic>>, int>>
  FutureBuilder:file:///Users/faizanrupani/.pub-cache/hosted/pub.dev/search_choices-2.2.7/lib/src/dropdown/dropdown_dialog.dart:941:15

When the exception was thrown, this was the stack:
#0      _DropdownDialogState.listWithPagination.<anonymous closure>.<anonymous closure>
(package:search_choices/src/dropdown/dropdown_dialog.dart:980:58)
#1      MappedListIterable.elementAt (dart:_internal/iterable.dart:425:31)
#2      ListIterator.moveNext (dart:_internal/iterable.dart:354:26)
#3      new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:189:27)
#4      new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
#5      new List.of (dart:core-patch/array_patch.dart:39:18)
#6      ListIterable.toList (dart:_internal/iterable.dart:224:7)
#7      _DropdownDialogState.listWithPagination.<anonymous closure> (package:search_choices/src/dropdown/dropdown_dialog.dart:981:16)
#8      _FutureBuilderState.build (package:flutter/src/widgets/async.dart:609:55)
#9      StatefulElement.build (package:flutter/src/widgets/framework.dart:5583:27)
#10     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5471:15)
#11     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5634:11)
#12     Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
#13     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2895:19)
#14     WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:984:21)
#15     RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:457:5)
#16     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1325:15)
#17     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1255:9)
#18     SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1113:5)
#19     _invoke (dart:ui/hooks.dart:312:13)
#20     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:383:5)
#21     _drawFrame (dart:ui/hooks.dart:283:31)

════════════════════════════════════════════════════════════════════════════════════════════════════

Tried

    DropdownMenuItem(
        value: item['value'],

got error.
type 'String' is not a subtype of type 'Null'

got the same error with this also.

var records =
        (data["data"]["data"] as List<dynamic>)
            .map((item) {
      return {
        "id": item?["id"].toString() ?? "",
        "name": item?["name"].toString() ?? "",
      };
    }).toList();
    DropdownMenuItem(
        value: item['id'],

from search_choices.

lcuis avatar lcuis commented on July 29, 2024

Hi @faizananwerali and @Thembelani-M ,

Sorry for the delay and the lack of answer. It is difficult for me to investigate this issue. At first sight, it looks like you have at least one DropdownMenuItem value that is not as expected (likely null).

Are your queries always behaving as intended?
Do you see circumstances when the error does not occur?

from search_choices.

faizananwerali avatar faizananwerali commented on July 29, 2024

I was never able to run it. None of the values were null. I spent hours then I switched to other library so I can show client something.

from search_choices.

lcuis avatar lcuis commented on July 29, 2024

I understand @faizananwerali and I am really sorry about that. I wish I had all the information necessary to investigate.

I never encountered such case myself and CI with Flutster never showed any issue.

I will now close this issue.

Feel free to reopen this issue in case anyone can share a full example.

from search_choices.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.