Silent Roar
Silent Roar

Reputation: 29

The argument type 'String' can't be assigned to the parameter type 'bool'

                        return Column(
                            children: snapshot.data.docs
                                .map<Widget>(
                                  (e) => QCard(
                                    'nama : ' + e.data()['nama'],
                                    'preseptor : ' + e.data()['preseptor'],
                                    e.data()['asal'],
                                    'status : ' +
                                        (e.data()['online']) != null ? 'online' : 'gak ada',
                                    onUpdate: () {},
                                  ),
                                )
                                .toList(),
                          );

Nah, the compiler said error: The argument type 'String' can't be assigned to the parameter type 'bool'. (argument_type_not_assignable at [proj_2] lib\select_qq.dart:168) on this line

(e.data()['online']) != null ? 'online' : 'gak ada',

how do i fix this ? plis deadline coming close

Upvotes: 0

Views: 241

Answers (1)

Alex Radzishevsky
Alex Radzishevsky

Reputation: 3768

This is due to "+" has higher priority than "?". Change to this:

...
'status : ' + ((e.data()['online']) != null ? 'online' : 'gak ada'),
...

Upvotes: 1

Related Questions