1
resposta

NoSuchMethodError was thrown while handling a gesture

Eu tive esse erro e não consegui achar uma solução no Stack Overflow ou GitHub. Quero entender e resolver o erro.

import 'package:bytebank/screens/contacts/list.dart';
import 'package:flutter/material.dart';

class Dashboard extends StatelessWidget {
  const Dashboard({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Dashboard'),
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Padding(
            padding: const EdgeInsets.all(8.0),
            child: Image.asset('images/bytebank_logo.png'),
          ),
          Container(
            height: 120,
            child: ListView(
              scrollDirection: Axis.horizontal,
              children: [
                _FeatureItem(
                  'Transfer',
                  Icons.monetization_on,
                  (context) {
                    _goToContactsList(context);
                  },
                ),
                _FeatureItem(
                  'Transaction feed',
                  Icons.description,
                  (context) {
                    debugPrint('Transaction feed was clicked');
                  },
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }

 void _goToContactsList(BuildContext context) {
    Navigator.of(context)
        .push(MaterialPageRoute(builder: (context) => ContactsList()));
  }
}

class _FeatureItem extends StatelessWidget {
  final String title;
  final IconData icon;
  final Function onClick;

  _FeatureItem(this.title, this.icon, this.onClick);

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.all(8.0),
      child: Material(
        color: Theme.of(context).primaryColor,
        child: InkWell(
          onTap: () => onClick(),
          child: Container(
            padding: EdgeInsets.all(8.0),
            width: 150,
            child: Column(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Icon(
                  icon,
                  color: Colors.white,
                  size: 24,
                ),
                Text(
                  title,
                  style: TextStyle(
                    fontSize: 16,
                    color: Colors.white,
                  ),
                )
              ],
            ),
          ),
        ),
      ),
    );
  }
}

*Tive esse retorno: *

Performing hot restart... Syncing files to device sdk gphone x86 arm... Restarted application in 877ms.

======== Exception caught by gesture =============================================================== The following NoSuchMethodError was thrown while handling a gesture: Closure call with mismatched arguments: function 'Dashboard.build.' Receiver: Closure: (dynamic) => Null Tried calling: Dashboard.build.() Found: Dashboard.build.(dynamic) => Null

When the exception was thrown, this was the stack:

#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)

#1 _FeatureItem.build. (package:bytebank/screens/dashboard.dart:70:31)

#2 InkResponseState.handleTap (package:flutter/src/material/ink_well.dart:991:20)

#3 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)

#4 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:607:11) ... Handler: "onTap" Recognizer: TapGestureRecognizer#17b48 debugOwner: GestureDetector state: possible won arena finalPosition: Offset(121.4, 720.3) finalLocalPosition: Offset(113.4, 73.1) button: 1 sent tap down ====================================================================================================

1 resposta

Olá Luiz, tudo bom?

Você chegou a baixar o código que o professor pede em aula? Da lista de transferência?

nesse link aqui.

Qualquer dúvida, estamos a disposição.