Skip to content

Commit

Permalink
4.22.0
Browse files Browse the repository at this point in the history
Took 2 hours 32 minutes
  • Loading branch information
Drawner committed Jun 7, 2024
1 parent 1f57cd7 commit 37a662e
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 148 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

## 4.22.0
June 05, 2024
- Use buildIn() to work with the built-in InheritedWidget like 'useInherited: true'
- getter builder renamed transitBuilder

## 4.21.0
May 27, 2024
- Updated sdk: '>=3.0.0 <4.0.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class InheritCat extends StatefulWidget {

/// Supply an InheritedWidget to a StateX object: InheritedStateX
class _InheritCatState extends StateX<InheritCat> {
_InheritCatState() : super(controller: CatController(), useInherited: true);
_InheritCatState() : super(controller: CatController());

/// Use buildIn() or builder() instead of build() to call the built-in InheritedWidget
@override
Expand Down
10 changes: 5 additions & 5 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ packages:
path: ".."
relative: true
source: path
version: "4.21.0"
version: "4.22.0"
fuchsia_remote_debug_protocol:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -668,10 +668,10 @@ packages:
dependency: transitive
description:
name: state_extended
sha256: "1b32e4db5b5086fc6af164f721639689175a5da9d4c5b11a7b5a1c0c7f359f53"
sha256: "6c95f09e6007eb71b79c4b85e8fcb0ea3617aad5cd29a85924f31c644d0dba08"
url: "https://pub.dev"
source: hosted
version: "4.16.0"
version: "4.16.1"
stream_channel:
dependency: transitive
description:
Expand Down Expand Up @@ -756,10 +756,10 @@ packages:
dependency: transitive
description:
name: url_launcher
sha256: "6ce1e04375be4eed30548f10a315826fd933c1e493206eab82eed01f438c8d2e"
sha256: "21b704ce5fa560ea9f3b525b43601c678728ba46725bab9b01187b4831377ed3"
url: "https://pub.dev"
source: hosted
version: "6.2.6"
version: "6.3.0"
url_launcher_android:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion lib/view/app/app_appstate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ extension AppStateExtension on AppObject {
appState?.navigatorObservers;

/// if neither [routes], or [onGenerateRoute] was passed.
TransitionBuilder? get builder => appState?.builder;
TransitionBuilder? get builder => appState?.transitBuilder;

/// Returns the title for the App's View.
String get title => appState?.title ?? '';
Expand Down
149 changes: 13 additions & 136 deletions lib/view/app_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

import '/controller.dart' show AppController, StateXController;

import 'package:state_extended/state_extended.dart' as s
show StateX, StateXInheritedWidget;
import 'package:state_extended/state_extended.dart' as s show StateX;

import '/view.dart';

Expand Down Expand Up @@ -197,7 +196,7 @@ class AppState<T extends StatefulWidget> extends _AppState<T>
_onUnknownRoute = onUnknownRoute;
_onNavigationNotification = onNavigationNotification;
_navigatorObservers = navigatorObservers;
_builder = builder;
_transitBuilder = builder;
_onGenerateTitle = onGenerateTitle;
_color = color;
_theme = theme;
Expand Down Expand Up @@ -452,7 +451,7 @@ class AppState<T extends StatefulWidget> extends _AppState<T>
onUnknownRoute: onUnknownRoute,
onNavigationNotification: onNavigationNotification,
navigatorObservers: _onNavigatorObservers(),
builder: builder,
builder: transitBuilder,
// not needed title: , // Used instead in _onOnGenerateTitle()
onGenerateTitle: onGenerateTitle,
color: color,
Expand Down Expand Up @@ -483,7 +482,7 @@ class AppState<T extends StatefulWidget> extends _AppState<T>
backButtonDispatcher: _backButtonDispatcher,
routerConfig: routerConfig,
theme: _setiOSThemeData(context),
builder: builder,
builder: transitBuilder,
// not needed title: , // Used instead in _onOnGenerateTitle()
onGenerateTitle: onGenerateTitle,
onNavigationNotification: onNavigationNotification,
Expand Down Expand Up @@ -522,7 +521,7 @@ class AppState<T extends StatefulWidget> extends _AppState<T>
onUnknownRoute: onUnknownRoute,
onNavigationNotification: onNavigationNotification,
navigatorObservers: _onNavigatorObservers(),
builder: builder,
builder: transitBuilder,
// not needed title: , // Used instead in _onOnGenerateTitle()
onGenerateTitle: onGenerateTitle,
color: color,
Expand Down Expand Up @@ -561,7 +560,7 @@ class AppState<T extends StatefulWidget> extends _AppState<T>
routerDelegate: _routerDelegate,
routerConfig: routerConfig,
backButtonDispatcher: _backButtonDispatcher,
builder: builder,
builder: transitBuilder,
// not needed title: , // Used instead in _onOnGenerateTitle()
onGenerateTitle: onGenerateTitle,
onNavigationNotification: onNavigationNotification,
Expand Down Expand Up @@ -897,8 +896,8 @@ abstract class _AppState<T extends StatefulWidget> extends AppStateX<T> {
List<NavigatorObserver>? get navigatorObservers => _onNavigatorObservers();
List<NavigatorObserver>? _navigatorObservers;

TransitionBuilder? get builder => _builder ?? onBuilder();
TransitionBuilder? _builder;
TransitionBuilder? get transitBuilder => _transitBuilder ?? onBuilder();
TransitionBuilder? _transitBuilder;

String get title => _appTitle;
String _appTitle = ''; // actual title
Expand Down Expand Up @@ -1667,85 +1666,22 @@ class StateX<T extends StatefulWidget> extends s.StateX<T>
with NavigatorStateMethodsMixin, RxStates, StateXRouteAware {
/// Default useInherited to false
StateX(
{super.controller, super.runAsync, bool? useInherited, bool? routeAware})
: routeAware = routeAware ?? false,
super(useInherited: useInherited ?? false);
{super.controller, super.runAsync, super.useInherited, bool? routeAware})
: routeAware = routeAware ?? false;

@override
void initState() {
super.initState();
_appSubscribe();
// Supply an identifier to the InheritedWidget
_key = ValueKey<StateX>(this as StateX);
}

AppState? _appState;

late Key _key;

// Widget passed to the InheritedWidget.
Widget? _child;

/// A flag. Note if buildF() function was overridden or not.
@override
bool get buildFOverridden => _buildFOverridden;
bool _buildFOverridden = true;

/// If you don't use it, use the buildAndroid() or buildiOS() function.
/// dartdoc:
/// {@category StateX class}
@override
Widget buildF(BuildContext context) {
//
_buildFOverridden = false;
//
if (!buildInOverridden) {
if (useInherited) {
_child ??= builder(context);
} else {
_child = builder(context);
}
} else {
bool firstPass;
if (_child == null) {
firstPass = true;
} else {
firstPass = false;
}
// First case: buildInOverridden is always true
_child ??= buildIn(context);

if (!buildInOverridden) {
if (useInherited) {
if (firstPass) {
_child = builder(context);
}
} else {
_child = builder(context);
}
}
}
// If buildIn() function is being used, always use InheritedWidget
return useInherited || buildInOverridden
? s.StateXInheritedWidget(
key: _key,
state: this as StateX,
child: _child!,
)
: _child!;
}

/// This function is wrapped in a Builder widget.
/// If you don't use it, use the buildAndroid() or buildiOS() function.
Widget builder(BuildContext context) {
// Although buildAndroid() might be overridden
_builderOverridden = false;
return App.useMaterial ? buildAndroid(context) : buildiOS(context);
}

/// A flag. Note if builder() function was overridden or not.
bool get builderOverridden => _builderOverridden;
bool _builderOverridden = true;
@override
Widget builder(BuildContext context) =>
App.useMaterial ? buildAndroid(context) : buildiOS(context);

/// A flag.Is this State aware of changes in route or not.
final bool routeAware;
Expand Down Expand Up @@ -1778,65 +1714,6 @@ class StateX<T extends StatefulWidget> extends s.StateX<T>
_appUnsubscribe();
}

/// Called when the State's InheritedWidget is called again
/// This 'widget function' will be called again.
@override
Widget state(WidgetBuilder? widgetFunc) {
final widget = super.state(widgetFunc);
assert(() {
_debugTestBuiltInInheritedWidget(
'Note, this state() function call will never work properly.');
return true;
}());
return widget;
}

///
/// Set the specified widget (through its context) as a dependent of the InheritedWidget
///
/// Return false if not configured to use the InheritedWidget
@override
bool dependOnInheritedWidget(BuildContext? context) {
final depend = super.dependOnInheritedWidget(context);
assert(() {
if (!depend) {
_debugTestBuiltInInheritedWidget(
'Note, this dependOnInheritedWidget() function call will never work properly.');
}
return true;
}());
return depend;
}

/// In harmony with Flutter's own API there's also a notifyClients() function
/// Rebuild the InheritedWidget of the 'closes' InheritedStateX object if any.
@override
bool notifyClients() {
final notify = super.notifyClients();
assert(() {
if (!notify) {
_debugTestBuiltInInheritedWidget(
'Note, this notifyClients() function call will never work properly.');
}
return true;
}());
return notify;
}

// Notify the class is under utilized. InheritedWidget is not fully used.
void _debugTestBuiltInInheritedWidget(String? line) {
//
if (buildInOverridden && !useInherited) {
debugPrint('▀▀▀▀▀ StateX Warning ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀');
if (line != null) {
debugPrint(line.trim());
}
debugPrint('The class, $this, uses the buildIn() function, '
"but its 'useInherited' parameter is not true.");
debugPrint('▀' * 40);
}
}

/// Make a reference to the App's State object
bool _appSubscribe() {
// Subscribe to a Navigator observer
Expand Down
8 changes: 4 additions & 4 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -668,10 +668,10 @@ packages:
dependency: "direct main"
description:
name: state_extended
sha256: "1b32e4db5b5086fc6af164f721639689175a5da9d4c5b11a7b5a1c0c7f359f53"
sha256: "6c95f09e6007eb71b79c4b85e8fcb0ea3617aad5cd29a85924f31c644d0dba08"
url: "https://pub.dev"
source: hosted
version: "4.16.0"
version: "4.16.1"
stream_channel:
dependency: transitive
description:
Expand Down Expand Up @@ -756,10 +756,10 @@ packages:
dependency: "direct main"
description:
name: url_launcher
sha256: "6ce1e04375be4eed30548f10a315826fd933c1e493206eab82eed01f438c8d2e"
sha256: "21b704ce5fa560ea9f3b525b43601c678728ba46725bab9b01187b4831377ed3"
url: "https://pub.dev"
source: hosted
version: "6.2.6"
version: "6.3.0"
url_launcher_android:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ homepage: https://www.andrioussolutions.com
repository: https://github.com/AndriousSolutions/fluttery_framework
issue_tracker: https://github.com/AndriousSolutions/fluttery_framework/issues?q=is%3Aissue+is%3Aopen

version: 4.21.0
version: 4.22.0

environment:
# sdk: '>=2.19.0 <4.0.0'
Expand Down

0 comments on commit 37a662e

Please sign in to comment.