1
resposta

Erro method push e type MAterialPageRoute flutter 2.0.3

error: Missing type arguments for generic method 'push<T extends Object?>'. (implicit_dynamic_method at [bytebank_contacts] lib\screens\contacts_list.dart:51)

error: Missing type arguments for generic type 'MaterialPageRoute'. (implicit_dynamic_type at [bytebank_contacts] lib\screens\contacts_list.dart:52)

error: Missing parameter type for 'newContact'. (implicit_dynamic_parameter at [bytebank_contacts] lib\screens\contacts_list.dart:56)

import 'package:bytebank_contacts/database/app_database.dart';
import 'package:bytebank_contacts/models/contact.dart';
import 'package:bytebank_contacts/screens/contact_form.dart';
import 'package:flutter/material.dart';

class ContactsList extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Contacts'),
      ),
      body: FutureBuilder<List<Contact>>(
        initialData: List(),
        future: findAll(),
        builder: (context, snapshot) {
          switch (snapshot.connectionState) {
            case ConnectionState.none:
              break;
            case ConnectionState.waiting:
              return Center(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    CircularProgressIndicator(),
                    Text('Loading')
                  ],
                ),
              );
              break;
            case ConnectionState.active:
              break;
            case ConnectionState.done:
              final List<Contact> contacts = snapshot.data;
              return ListView.builder(
                itemBuilder: (context, index) {
                  final Contact contact = contacts[index];
                  return _ContactItem(contact);
                },
                itemCount: contacts.length,
              );
              break;
          }
          return Text('Unknown error');
        },
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          Navigator.of(context)
              .push(
                MaterialPageRoute(
                  builder: (context) => ContactForm(),
                ),
              )
              .then( (newContact) => debugPrint(newContact.toString()),
              );
        },
        child: Icon(
          Icons.add,
        ),
      ),
    );
  }
}

class _ContactItem extends StatelessWidget {
  final Contact contact;

  _ContactItem(this.contact);

  @override
  Widget build(BuildContext context) {
    return Card(
      child: ListTile(
        title: Text(
          contact.name,
          style: TextStyle(
            fontSize: 24.0,
          ),
        ),
        subtitle: Text(
          contact.accountNumber.toString(),
          style: TextStyle(
            fontSize: 16.0,
          ),
        ),
      ),
    );
  }
}
1 resposta

Oi Wodeglei, tudo bem?

Realmente, muito estranho esse erro. Consegue upar o projeto todo para eu dar uma olhada por favor? Pode ser no github ou google drive e manda o link aqui :). Só com a classe ContactsList não consegui sacar exatamente a razão desse problema.

Abração e bom estudo!