Skip to content

Commit

Permalink
4.8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Drawner committed Oct 25, 2023
1 parent 5f7c997 commit 0117fcb
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

## 4.8.2
October 25, 2023
- didUpdateController() in didUpdateWidget() in special cases

## 4.8.1
October 23, 2023
- (state != null && state is StateX) remove necessary cast
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dependencies:
flutter:
sdk: flutter

state_extended: #^0.5.0
state_extended: #^4.0.0
path: ../

# https://pub.dev/packages/http:
Expand Down
22 changes: 22 additions & 0 deletions lib/state_extended.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,28 @@ abstract class StateX<T extends StatefulWidget> extends State<StatefulWidget>
bool remove(StateXController? controller) =>
super.remove(controller); // mixin _ControllersByType

/// Update the 'first' controller if necessary
/// Place in the[didUpdateWidget] function in the special case
/// the StatefulWidget supplies the controller:
/// e.g. didUpdateController(oldWidget.controller, widget.controller);
bool didUpdateController(
StateXController? oldController,
StateXController? newController,
) {
bool update =
oldController != null && newController != null && _controller != null;
// Test if supplied the parameters and there's a 'first' controller, _controller
if (update) {
// Don't bother if it's the same controller instance.
update = _controller!.identifier != oldController.identifier;

if (update) {
_controller = newController;
}
}
return update;
}

/// Add a list of 'Controllers' to be associated with this StatX object.
@override
List<String> addList(List<StateXController>? list) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: state_extended
description: This class extends the capabilities of Flutter's State class and includes a controller.
version: 4.8.1
version: 4.8.2
homepage: https://www.andrioussolutions.com
repository: https://github.com/AndriousSolutions/state_extended

Expand Down

0 comments on commit 0117fcb

Please sign in to comment.