@@ -8,6 +8,7 @@ import 'package:scouting_dashboard_app/pages/team_lookup/edit_team_lookup_flag.d
88import 'package:scouting_dashboard_app/pages/team_lookup/tabs/team_lookup_breakdowns.dart' ;
99import 'package:scouting_dashboard_app/pages/team_lookup/tabs/team_lookup_categories.dart' ;
1010import 'package:scouting_dashboard_app/pages/team_lookup/tabs/team_lookup_notes.dart' ;
11+ import 'package:scouting_dashboard_app/reusable/debouncer.dart' ;
1112import 'package:scouting_dashboard_app/reusable/flag_models.dart' ;
1213import 'package:scouting_dashboard_app/reusable/page_body.dart' ;
1314import 'package:shared_preferences/shared_preferences.dart' ;
@@ -22,6 +23,7 @@ class TeamLookupPage extends StatefulWidget {
2223}
2324
2425class _TeamLookupPageState extends State <TeamLookupPage > {
26+ final debouncer = Debouncer (delay: const Duration (milliseconds: 200 ));
2527 String teamFieldValue = "" ;
2628 TextEditingController ? teamFieldController;
2729 int ? teamNumberForAnalysis;
@@ -70,12 +72,16 @@ class _TeamLookupPageState extends State<TeamLookupPage> {
7072 ),
7173 keyboardType: TextInputType .number,
7274 onChanged: (value) {
73- setState (() {
74- teamFieldValue = value;
75- if (int .tryParse (value) != null ) {
76- teamNumberForAnalysis = int .parse (value);
77- }
78- updateIncrement++ ;
75+ debouncer.run (() {
76+ setState (() {
77+ teamFieldValue = value;
78+ if (int .tryParse (value) != null ) {
79+ teamNumberForAnalysis = int .parse (value);
80+ } else {
81+ teamNumberForAnalysis = null ;
82+ }
83+ updateIncrement++ ;
84+ });
7985 });
8086 },
8187 controller: teamFieldController,
@@ -201,15 +207,18 @@ class _TeamLookupFlagState extends State<TeamLookupFlag> {
201207 Widget build (BuildContext context) {
202208 if (loadingTeam != widget.team) load ();
203209
204- return prefs == null || int .tryParse (widget.team) == null
205- ? Container ()
206- : NetworkFlag (
207- team: int .parse (widget.team),
208- flag: FlagConfiguration .fromJson (
209- jsonDecode (
210- prefs! .getString ('team_lookup_flag' )! ,
211- ),
212- ),
213- );
210+ if (prefs == null ||
211+ int .tryParse (widget.team) == null ||
212+ prefs! .getString ('team_lookup_flag' ) == null ) {
213+ return Container ();
214+ }
215+ return NetworkFlag (
216+ team: int .parse (widget.team),
217+ flag: FlagConfiguration .fromJson (
218+ jsonDecode (
219+ prefs! .getString ('team_lookup_flag' )! ,
220+ ),
221+ ),
222+ );
214223 }
215224}
0 commit comments