Skip to content

Commit 2d28348

Browse files
committed
Added mixin for stateful widgets
1 parent e78db35 commit 2d28348

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

lib/computed_flutter.dart

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,22 @@ mixin ComputedFlutterMixin on StatelessWidget {
4646
StatelessElement createElement() => ComputedFlutterElement(this);
4747
}
4848

49+
/// Allows Computed to track reactive dependencies of the build method.
50+
mixin ComputedFlutterStatefulMixin on StatefulWidget {
51+
@override
52+
StatefulElement createElement() => ComputedFlutterStatefulElement(this);
53+
}
54+
4955
/// A [StatelessWidget] the build method of which is tracked by Computed.
50-
abstract class ComputedWidget extends StatelessWidget {
56+
abstract class ComputedWidget extends StatelessWidget
57+
with ComputedFlutterMixin {
5158
const ComputedWidget({super.key});
52-
53-
@override
54-
StatelessElement createElement() => ComputedFlutterElement(this);
5559
}
5660

5761
/// A [StatefulWidget] the build method of which is tracked by Computed.
58-
abstract class ComputedStatefulWidget extends StatefulWidget {
62+
abstract class ComputedStatefulWidget extends StatefulWidget
63+
with ComputedFlutterStatefulMixin {
5964
const ComputedStatefulWidget({super.key});
60-
61-
@override
62-
StatefulElement createElement() => ComputedFlutterStatefulElement(this);
6365
}
6466

6567
/// As [Builder], but the builder is tracked by Computed.

0 commit comments

Comments
 (0)