Adeeb Fekri
Adeeb Fekri

Reputation: 11

Error: The operator '<' isn't defined for the class 'Object'

*Error: The operator '<' isn't defined for the class 'Object'.

  • 'Object' is from 'dart:core'. Try correcting the operator to an existing operator, or defining a '<' operator.
title: Text((snapshot.hasData&&snapshot.data !<10)? "${snapshot.data}":'Demo'),
                                                       

Upvotes: 1

Views: 430

Answers (2)

Delwinn
Delwinn

Reputation: 1019

if you want to check the length of number of data, it is snapshot.data!.docs().length < 10

if its the text value of data,

var data = snapshot.data!.doc() as Map<String, dynamic>;
int.tryParse(data['<data_field_for_validation>']) < 10

Upvotes: 0

Ivo
Ivo

Reputation: 23232

You have to indicate what type the snapshot is, you can do that by indicating it in <> at the StreamBuilder, like

StreamBuilder<int>(

Also note that even though

snapshot.hasData&&snapshot.data !<10

works, it's highly unconventional and you should space it like

snapshot.hasData && snapshot.data! < 10

Upvotes: 2

Related Questions