Skip to content

Commit be484ec

Browse files
committed
5.7.4
1 parent f443c96 commit be484ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+284
-326
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11

2+
## 5.7.4
3+
December 30, 2024
4+
- Correctly cast the Fluttery Framework version of StateX; not state_extended version.
5+
getter appState gets Fluttery version; getter rootState gets state_extended version.
6+
StateX get state in app_statex_controller.dart
7+
StateX? get firstState, StateX? get lastState in app_statex_controller.dart
8+
StateX? stateOf<T extends StatefulWidget>() in app_statex_controller.dart
9+
stateOf<T extends StatefulWidget>() in app_statex_controller.dart
10+
- Corrected changeApp() in example_controller.dart
11+
212
## 5.7.3
313
December 29, 2024
414
- Recognize only 'Testing Errors' in app_statex.dart
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//
2+
export '../test/src/_test_imports.dart';
3+
4+
// Individual Tests
5+
export 'src/animals_test.dart';
6+
export 'src/counter_test.dart';
7+
export 'src/words_test.dart';
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2022 Andrious Solutions Ltd. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import '../_test_imports.dart';
6+
7+
const _location = '========================== animals_test.dart';
8+
9+
Future<void> animalsTest(WidgetTester tester) async {
10+
/// New Dogs
11+
await tester.tap(find.byKey(const Key('New Dogs')));
12+
await tester.pumpAndSettle(const Duration(seconds: 2));
13+
14+
/// New Cats
15+
await tester.tap(find.byKey(const Key('New Cats')));
16+
await tester.pumpAndSettle(const Duration(seconds: 2));
17+
18+
/// New Foxes
19+
await tester.tap(find.byKey(const Key('New Foxes')));
20+
await tester.pumpAndSettle(const Duration(seconds: 2));
21+
22+
/// New Birds
23+
await tester.tap(find.byKey(const Key('New Birds')));
24+
await tester.pumpAndSettle(const Duration(seconds: 2));
25+
}
File renamed without changes.

example/integration_test/src/tests/unit/wordpairs_model.dart

Lines changed: 0 additions & 19 deletions
This file was deleted.
File renamed without changes.

example/integration_test/widget_test.dart

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
import 'src/_test_imports.dart';
1+
//
2+
// Test files
3+
import '_test_imports.dart';
24

35
import 'package:integration_test/integration_test.dart'
46
show IntegrationTestWidgetsFlutterBinding;
57

68
void main() => integrationTestFlutteryFramework();
79

810
void integrationTestFlutteryFramework() {
11+
// Call this function instead of using the 'default' TestWidgetsFlutterBinding
912
// Allow for Integration testing
1013
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
1114

1215
// Define a test. The TestWidgets function also provides a WidgetTester
1316
// to work with. The WidgetTester allows you to build and interact
1417
// with widgets in the test environment.
1518
testWidgets('testing example app', (WidgetTester tester) async {
16-
//
17-
1819
// Flutter won’t automatically rebuild your widget in the test environment.
1920
// Use pump() or pumpAndSettle() to ask Flutter to rebuild the widget.
2021
await tester.pumpWidget(FlutteryExampleApp());
@@ -48,6 +49,11 @@ void integrationTestFlutteryFramework() {
4849
// Test dialog windows
4950
await dialogTests(tester);
5051

52+
break;
53+
case 'Inherited':
54+
55+
await animalsTest(tester);
56+
5157
break;
5258
}
5359

@@ -95,9 +101,6 @@ void integrationTestFlutteryFramework() {
95101

96102
reportTestErrors();
97103

98-
// // WordPairs App Model Unit Testing
99-
// await wordPairsModelTest(tester);
100-
//
101-
// return;
104+
return;
102105
});
103106
}

example/lib/src/app/controller/example_controller.dart

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,6 @@ class ExampleAppController extends AppStateXController {
118118
_appCount = _appNames.indexOf(appName.trim());
119119
}
120120

121-
// Possibly running in a test and can't run the Contacts app
122-
// There's no sqlite in the test environment
123-
if (App.inFlutterTest && _appCount == 2) {
124-
_appCount = 0;
125-
}
126-
127121
await Prefs.setBool('words', _appNames[_appCount] == 'Word');
128122

129123
// Rerun the whole app with App.setState(() {})
@@ -135,11 +129,11 @@ class ExampleAppController extends AppStateXController {
135129
///
136130
Future<void> changeLocale() async {
137131
///
138-
final appState = rootState!;
132+
final app = appState!;
139133

140-
final locale = appState.locale!;
134+
final locale = app.locale!;
141135

142-
final locales = appState.supportedLocales;
136+
final locales = app.supportedLocales;
143137

144138
// record selected locale
145139
Locale? appLocale;
@@ -159,7 +153,7 @@ class ExampleAppController extends AppStateXController {
159153
);
160154

161155
await DialogBox(
162-
context: appState.lastContext!,
156+
context: app.lastContext!,
163157
title: 'Current Language'.tr,
164158
body: [spinner],
165159
press01: () {},
@@ -259,10 +253,7 @@ class ExampleAppController extends AppStateXController {
259253
//
260254
final init = await super.initAsync();
261255

262-
// Demonstrating ways to retrieve the StatefulWidget
263-
// ignore: unused_local_variable
264-
var widget = firstState!.widget as FlutteryExampleApp;
265-
widget = rootState!.widget as FlutteryExampleApp;
256+
final widget = appState!.widget as FlutteryExampleApp;
266257

267258
// Don't delay if in testing for example
268259
if (App.inWidgetsFlutterBinding) {
@@ -278,9 +269,6 @@ class ExampleAppController extends AppStateXController {
278269
throw Exception('Error in initAsync()!');
279270
}
280271

281-
//
282-
state?.add(MaterialController());
283-
284272
if (inDebugMode) {
285273
debugPrint('############ Event: initAsync() in $this');
286274
}

example/lib/src/app/controller/word_pair_timer.dart

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import '/src/view.dart';
88
import 'package:fluttery_framework/controller.dart';
99

1010
import 'package:english_words/english_words.dart';
11-
11+
///
1212
class WordPairsTimer extends StateXController {
1313
/// Only one instance of the class is necessary and desired.
1414
factory WordPairsTimer({
@@ -26,15 +26,21 @@ class WordPairsTimer extends StateXController {
2626
super(state);
2727

2828
static WordPairsTimer? _this;
29+
///
2930
final int? seconds;
31+
///
3032
final Duration? duration;
33+
///
3134
final void Function()? callback;
35+
///
3236
final int? count;
37+
///
3338
final WordPairsModel model;
34-
39+
///
3540
Timer? timer;
36-
41+
///
3742
final suggestions = <WordPair>[];
43+
///
3844
int index = 0;
3945

4046
@override
@@ -152,7 +158,7 @@ class WordPairsTimer extends StateXController {
152158
/// Change dataObject will rebuild the InheritedWidget
153159
/// Changing the 'dataObject' will call the SetState class implemented above
154160
/// and only that widget.
155-
rootState?.dataObject = _wordPair;
161+
appState?.dataObject = _wordPair;
156162
} catch (ex) {
157163
/// Stop the timer.
158164
/// Something is not working. Don't have the timer repeat it over and over.

example/lib/src/app/view/menu/app_menu.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ import '/src/view.dart';
77
class AppMenu extends AppPopupMenu {
88
/// Only one instance of the class
99
factory AppMenu() => _this ??= AppMenu._();
10-
static AppMenu? _this;
11-
1210
AppMenu._()
1311
: _con = ExampleAppController(),
1412
super(
1513
key: const Key('appMenuButton'),
1614
controller: AppMenuController(),
1715
);
16+
static AppMenu? _this;
1817

1918
/// The App's controller
2019
final ExampleAppController _con;
@@ -66,7 +65,7 @@ class AppMenu extends AppPopupMenu {
6665

6766
/// When an menu item is selected
6867
@override
69-
void onSelected(String value) async {
68+
Future<void> onSelected(String value) async {
7069
switch (value) {
7170
case 'interface':
7271
_con.changeUI();
@@ -75,10 +74,10 @@ class AppMenu extends AppPopupMenu {
7574
await _con.changeApp();
7675
break;
7776
case 'locale':
78-
_con.changeLocale();
77+
await _con.changeLocale();
7978
break;
8079
case 'color':
81-
_con.changeColor();
80+
await _con.changeColor();
8281
break;
8382
case 'about':
8483
_con.aboutApp();
@@ -90,7 +89,8 @@ class AppMenu extends AppPopupMenu {
9089

9190
/// Uses the String type as menu options
9291
class AppMenuController extends AppPopupMenuController {
92+
///
9393
factory AppMenuController() => _this ??= AppMenuController._();
94-
static AppMenuController? _this;
9594
AppMenuController._();
95+
static AppMenuController? _this;
9696
}

0 commit comments

Comments
 (0)