flutter 莫名其妙错误集锦

时间:2020-07-12
本文章向大家介绍flutter 莫名其妙错误集锦,主要包括flutter 莫名其妙错误集锦使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

1、回调函数的时候,报错:

════════ Exception caught by gesture ═══════════════════════════════════════════════════════════════
The following NoSuchMethodError was thrown while handling a gesture:
The method 'call' was called on null.
Receiver: null
Tried calling: call()

When the exception was thrown, this was the stack: 
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1      _BillAddPageState.build.<anonymous closure>.<anonymous closure> (package:flutter_bcd/pages/bill/bill_add_page.dart:139:19)
#2      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:706:14)
#3      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:789:36)
#4      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
...
Handler: "onTap"

  

       return InkWell(
                onTap: () {
                  setState(() {
                    _selectedIndex = index;
                  });
                  print(_scaffoldKey);
                  // 调用 回调函数必须加括号
                  _showBottomSheetCallback();
                },
                child: Container(
                  alignment: Alignment.center,
                  padding: EdgeInsets.only(bottom: 10),
                  color: flag ? Colors.amber : Colors.transparent,
                  child: Column(
                    children: <Widget>[
                      Expanded(child: categoryList[index].icon),
                      Text(
                        categoryList[index].title,
                        style: TextStyle(
                          fontSize: 14,
                          color: Color(0xFF333333),
                        ),
                      ),
                    ],
                  ),
                ));

  

原文地址:https://www.cnblogs.com/hoge66/p/13286929.html