buttonsrtoys / mvvm_plus

State management package for Flutter that implements MVVM
MIT License
26 stars 3 forks source link

abstract class ViewWidget<T extends ViewModel> is not const #47

Open JCKodel opened 1 week ago

JCKodel commented 1 week ago

On src.dart, line 32:

abstract class ViewWidget<T extends ViewModel> extends StatefulWidget {
  ViewWidget({
    required T Function() builder,
    String? name,
    Location? location,
    super.key,
  })  : assert(T != ViewModel,
            _missingGenericError('ViewWidget constructor', 'ViewModel')),
        assert(location != Location.tree || name == null,
            'ViewWidget cannot name a ViewModel that is not registered'),
        _name = name,
        _builder = builder,
        _location = location;
}

Is there any reason why ViewWidget is not const? EVERY widget in Flutter must be const (even StatefulWidget, only the state is mutable).

This will have huge performance implications in memory consumption and GC collection, especially when using it in common components that are used more than once (for instance, in a list).