Skip to content

Commit

Permalink
4.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Drawner committed Feb 18, 2024
1 parent d2e27d7 commit 8aabd37
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 23 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@

## 4.11.0
February 18, 2023
- Deprecated
Set<StateX> get states - Set of States is too accessible
- Introduced these getters instead:
StateX? get startState
StateX? get endState

## 4.10.0
January 24, 2023
- StateX({StateXController? controller, bool? runAsync, bool? useInherited}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class InheritController extends StateXController {
/// The InheritedWidget is the first State object it registered with.
@override
bool dependOnInheritedWidget(BuildContext? context) =>
states.first.dependOnInheritedWidget(context);
startState?.dependOnInheritedWidget(context) ?? false;

/// Rebuild the InheritedWidget to also rebuild its dependencies.
void newAnimals() => states.first.notifyClients();
void newAnimals() => startState?.notifyClients();
}
2 changes: 1 addition & 1 deletion example/test/test_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void testsController(WidgetTester tester) {
expect(con, isA<Controller>(), reason: location);

// The Set of State objects
con.states;
// con.states; // Deprecated

// Continuing the testing coverage
con.notifyClients();
Expand Down
31 changes: 17 additions & 14 deletions lib/state_extended.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1206,8 +1206,7 @@ abstract class StateX<T extends StatefulWidget> extends State<StatefulWidget>
/// {@category StateX class}
abstract class StateF<T extends StatefulWidget> extends StateX<T> {
///
StateF({StateXController? controller})
: super(controller: controller, runAsync: true);
StateF({super.controller}) : super(runAsync: true);
}

/// A State object that explicitly implements a built-in InheritedWidget
Expand All @@ -1216,8 +1215,7 @@ abstract class StateF<T extends StatefulWidget> extends StateX<T> {
/// {@category StateX class}
abstract class StateIn<T extends StatefulWidget> extends StateX<T> {
///
StateIn({StateXController? controller})
: super(controller: controller, useInherited: true);
StateIn({super.controller}) : super(useInherited: true);
}

/// Collects Controllers of various types.
Expand Down Expand Up @@ -1687,11 +1685,18 @@ mixin SetStateMixin {
return state == null ? null : state as T;
}

// /// Return a 'copy' of the Set of State objects.
// Set<StateX> get states => Set.from(_stateXSet.whereType<StateX>());
/// Return a 'copy' of the Set of State objects.
// Set<StateX> get states => Set.from(_stateXSet?.whereType<StateX>());

/// The Set of State objects.
@Deprecated('Set states is too accessible')
Set<StateX> get states => _stateXSet;

/// Return the first State object
StateX? get startState => _stateXSet.isEmpty ? null : _stateXSet.first;

/// Return the 'latest' State object
StateX? get endState => _stateXSet.isEmpty ? null : _stateXSet.last;
}

/// Used to explicitly return the 'type' indicated.
Expand Down Expand Up @@ -2388,10 +2393,9 @@ class _StateXInheritedWidget extends InheritedWidget {
/// Supply a widget to depend upon a StateX's InheritedWidget
class _SetStateWidget extends StatelessWidget {
const _SetStateWidget({
Key? key,
required this.stateX,
required this.widgetFunc,
}) : super(key: key);
});
final StateX stateX;
final WidgetBuilder widgetFunc;
@override
Expand All @@ -2415,12 +2419,11 @@ abstract class AppStateX<T extends StatefulWidget> extends StateX<T>
/// Optionally supply as many State Controllers as you like to work with this App.
/// Optionally supply a 'data object' to to be accessible to the App's InheritedWidget.
AppStateX({
StateXController? controller,
super.controller,
List<StateXController>? controllers,
Object? object,
// Save the current error handler
}) : _currentErrorFunc = FlutterError.onError,
super(controller: controller) {
}) : _currentErrorFunc = FlutterError.onError {
//Record this as the 'root' State object.
setRootStateX(this);
_dataObj = object;
Expand Down Expand Up @@ -2687,9 +2690,9 @@ abstract class AppStateX<T extends StatefulWidget> extends StateX<T>
/// Pass a State object as a parameter to this StatefulWidget
class _StateStatefulWidget extends StatefulWidget {
const _StateStatefulWidget({
Key? key,
super.key,
required this.state,
}) : super(key: key);
});
final State<StatefulWidget> state;
@override
//ignore: no_logic_in_create_state
Expand Down Expand Up @@ -2945,7 +2948,7 @@ mixin _ControllersById<T extends StatefulWidget> on StateX<T> {
@protected
class SetState extends StatelessWidget {
/// Supply a 'builder' passing in the App's 'data object' and latest BuildContext object.
const SetState({Key? key, required this.builder}) : super(key: key);
const SetState({super.key, required this.builder});

/// This is called with every rebuild of the App's inherited widget.
final Widget Function(BuildContext context, Object? object) builder;
Expand Down
8 changes: 4 additions & 4 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ packages:
dependency: "direct dev"
description:
name: flutter_lints
sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04
sha256: e2a421b7e59244faef694ba7b30562e489c2b489866e505074eb005cd7060db7
url: "https://pub.dev"
source: hosted
version: "2.0.3"
version: "3.0.1"
flutter_localizations:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -130,10 +130,10 @@ packages:
dependency: transitive
description:
name: lints
sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452"
sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "3.0.0"
matcher:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions 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.10.0
version: 4.11.0
homepage: https://www.andrioussolutions.com
repository: https://github.com/AndriousSolutions/state_extended

Expand Down Expand Up @@ -32,7 +32,7 @@ dev_dependencies:
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^2.0.0
flutter_lints: ^3.0.0

# Needed here as well for testing
flutter_test:
Expand Down

0 comments on commit 8aabd37

Please sign in to comment.