Skip to content

Commit

Permalink
4.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Drawner committed Jan 24, 2024
1 parent f10d1d5 commit d2e27d7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@

## 4.10.0
January 24, 2023
- StateX({StateXController? controller, bool? runAsync, bool? useInherited}) {
A new optional parameter, runAsync, to run built-in FutureBuilder with every build
- abstract class StateF<T extends StatefulWidget> extends StateX<T>
A State class to run built-in FutureBuilder with every build

## 4.9.0
December 14, 2023
- getter buildOverridden & buildFOverridden set when 'build' functions are overwritten
Expand Down
24 changes: 22 additions & 2 deletions lib/state_extended.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ abstract class StateX<T extends StatefulWidget> extends State<StatefulWidget>
implements
StateListener {
//
/// With an optional StateXController parameter and built-in InheritedWidget use
StateX({StateXController? controller, bool? useInherited}) {
/// With an optional StateXController parameter and built-in FutureBuilder & InheritedWidget use
StateX({StateXController? controller, bool? runAsync, bool? useInherited}) {
// Add to the list of StateX objects present in the app!
_addToMapOfStates(this);
// A flag whether the built-in FutureBuilder runs with every setState() call.
_runAsync = runAsync ?? false;
// A flag determining whether the built-in InheritedWidget is used or not.
_useInherited = useInherited ?? false;
// Associate the controller to this State object
Expand All @@ -63,6 +65,9 @@ abstract class StateX<T extends StatefulWidget> extends State<StatefulWidget>

StateXController? _controller;

/// Run the built-in FutureBuilder with every setState() call
late bool _runAsync;

/// Use this function instead of build() to use the built-in InheritedWidget.
@override
@protected
Expand Down Expand Up @@ -1169,6 +1174,11 @@ abstract class StateX<T extends StatefulWidget> extends State<StatefulWidget>
/// Refresh the interface by 'rebuilding' the Widget Tree
/// Call the State object's setState() function.
super.setState(fn);

if (_ranAsync && _runAsync) {
// Run the FutureBuilder again and again
_ranAsync = false;
}
}
_setStateAllowed = true;
} else {
Expand All @@ -1190,6 +1200,16 @@ abstract class StateX<T extends StatefulWidget> extends State<StatefulWidget>
}
}

/// A State object the runs its built-in FutureBuilder with every setState()
///
/// dartdoc:
/// {@category StateX class}
abstract class StateF<T extends StatefulWidget> extends StateX<T> {
///
StateF({StateXController? controller})
: super(controller: controller, runAsync: true);
}

/// A State object that explicitly implements a built-in InheritedWidget
///
/// dartdoc:
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.9.0
version: 4.10.0
homepage: https://www.andrioussolutions.com
repository: https://github.com/AndriousSolutions/state_extended

Expand Down

0 comments on commit d2e27d7

Please sign in to comment.