djointster djointster - 2 years ago 99
Dart Question

Extending 3rd party Dart Component

I'm trying to use a

to show some info about some users. I've been able to do that and it works, but i have a problem with the
null values
, as all cell data is resolved by reflection, the table displays
. I've been trying to find a way to replace this
by aan empty String by as the code is from a 3rd party lib i can't edit it.

I thought about extending the
class so i could override the method that resolves the cell data, but i haven't been able to diplay any info with it, and i'm not getting any error either.

This is the code i tried so far, but it doesn't show me the table and i have data to show.

selector: 'bs-table-custom',
template: <ommited for brevity>
directives: const [BsColumnDirective])
class BsTableCustomComponent extends BsTableComponent {
String getData(dynamic row, String fieldName) =>
fieldName.split('.').fold(row, (prev, String curr) {
var prevValue = prev is Map
? prev[curr]
: serializable.reflect(prev).invokeGetter(curr);

if(prevValue == null || (prevValue is List && prevValue.isEmpty)) {
return "";

return prevValue;

I'm not sure how to extend a 3rd party lib in Dart or if there's a simpler way to achieve what i need.

Any help would be appretiated.
Thank you

Answer Source

I was able to solve my problem by copying the files and editing them as needed.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download