Extending store class in Mobx Flutter

Viewed 623

What is the correct way to extend a store class in Mobx in flutter? Wherever I try to put 'extends' i get a compilation error.


class Booking = _Booking with _$Booking;

abstract class _Booking with Store {}


class FlightBooking  = _FlightBooking with _$FlightBooking ;

abstract class _FlightBooking with Store {}
2 Answers

You can achieve that by making _FlightBooking extend Booking:

class FlightBooking  = _FlightBooking with _$FlightBooking ;


abstract class _FlightBooking extends Booking with Store {}

Store of mobx is a mixin, not a class. Mixins cannot be used to extend. You might want to look more into the documentation.

Related