fix: late initialization in pets and selection local bug
This commit is contained in:
parent
b2fcc1cfca
commit
ce6e0b4950
|
@ -14,8 +14,8 @@ import '/backend/api_requests/api_calls.dart';
|
|||
import '/flutter_flow/flutter_flow_theme.dart';
|
||||
|
||||
class BottomArrowLinkedLocalsComponentWidget extends StatefulWidget {
|
||||
const BottomArrowLinkedLocalsComponentWidget({super.key, required this.response});
|
||||
final ApiCallResponse? response;
|
||||
BottomArrowLinkedLocalsComponentWidget({super.key, required this.response});
|
||||
ApiCallResponse? response;
|
||||
|
||||
@override
|
||||
State<BottomArrowLinkedLocalsComponentWidget> createState() => _BottomArrowLinkedLocalsComponentWidgetState();
|
||||
|
@ -72,6 +72,7 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State<BottomArrowLink
|
|||
Future<ApiCallResponse?> _fetchLocals() async {
|
||||
try {
|
||||
setState(() => _loading = true);
|
||||
widget.response = await PhpGroup.getLocalsCall.call();
|
||||
final bool isError = widget.response?.jsonBody['error'];
|
||||
|
||||
if (isError) {
|
||||
|
@ -198,7 +199,8 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State<BottomArrowLink
|
|||
await StorageHelper().set(SQLiteStorageKey.clientName.value, local['CLI_NOME'], Storage.SQLiteStorage);
|
||||
await StorageHelper().set(SQLiteStorageKey.ownerUUID.value, local['CLU_OWNER_ID'], Storage.SQLiteStorage);
|
||||
|
||||
context.pop();
|
||||
context.pop(true);
|
||||
return true;
|
||||
} else if (local['CLU_STATUS'] == 'B') {
|
||||
String message = FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Local Bloqueado para Acesso, Entre em Contato com Administração',
|
||||
|
|
|
@ -12,7 +12,6 @@ import 'package:hub/shared/utils/log_util.dart';
|
|||
|
||||
class PetsHistoryScreen extends StatefulWidget {
|
||||
const PetsHistoryScreen({super.key, required this.model});
|
||||
|
||||
final PetsPageModel model;
|
||||
|
||||
@override
|
||||
|
@ -34,9 +33,7 @@ class _PetsHistoryScreenState extends State<PetsHistoryScreen> with TickerProvid
|
|||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_petsFuture = _fetchVisits();
|
||||
|
||||
_petsFuture = _fetch();
|
||||
_scrollController = ScrollController()
|
||||
..addListener(() {
|
||||
if (_scrollController.position.atEdge && _scrollController.position.pixels != 0) {
|
||||
|
@ -51,7 +48,7 @@ class _PetsHistoryScreenState extends State<PetsHistoryScreen> with TickerProvid
|
|||
super.dispose();
|
||||
}
|
||||
|
||||
Future<ApiCallResponse?> _fetchVisits() async {
|
||||
Future<ApiCallResponse?> _fetch() async {
|
||||
try {
|
||||
setState(() => _loading = true);
|
||||
|
||||
|
@ -96,7 +93,7 @@ class _PetsHistoryScreenState extends State<PetsHistoryScreen> with TickerProvid
|
|||
if (_hasData == true) {
|
||||
_pageNumber++;
|
||||
|
||||
_petsFuture = _fetchVisits();
|
||||
_petsFuture = _fetch();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,27 +149,10 @@ class _PetsHistoryScreenState extends State<PetsHistoryScreen> with TickerProvid
|
|||
shrinkWrap: true,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
controller: _scrollController,
|
||||
itemCount: _petsWrap.length + 1,
|
||||
itemCount: _petsWrap.length,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 0) {
|
||||
// Add your item here
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(right: 30, top: 10),
|
||||
child: Text(
|
||||
widget.model.petAmountRegister == '0'
|
||||
? FFLocalizations.of(context).getVariableText(ptText: "Ilimitado", enText: "Unlimited")
|
||||
: "${FFLocalizations.of(context).getVariableText(ptText: "Quantidade de Pets: ", enText: "Amount of Pets: ")}$count/${widget.model.petAmountRegister}",
|
||||
textAlign: TextAlign.right,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Nunito',
|
||||
fontSize: limitedBodyTextSize,
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
final item = _petsWrap[index - 1];
|
||||
return _item(context, item);
|
||||
}
|
||||
final item = _petsWrap[index];
|
||||
return _item(context, item);
|
||||
});
|
||||
},
|
||||
)),
|
||||
|
@ -274,7 +254,7 @@ class _PetsHistoryScreenState extends State<PetsHistoryScreen> with TickerProvid
|
|||
safeSetState(() {
|
||||
_pageNumber = 1;
|
||||
_petsWrap = [];
|
||||
_petsFuture = _fetchVisits().then((value) => value!.jsonBody['pets'] ?? []);
|
||||
_petsFuture = _fetch().then((value) => value!.jsonBody['pets'] ?? []);
|
||||
});
|
||||
}).catchError((e, s) {
|
||||
DialogUtil.errorDefault(context);
|
||||
|
|
|
@ -20,10 +20,10 @@ import 'package:hub/shared/utils/limited_text_size.dart';
|
|||
import 'package:hub/shared/utils/validator_util.dart';
|
||||
|
||||
class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||
late final String devUUID;
|
||||
late final String userUUID;
|
||||
late final String cliUUID;
|
||||
late final String petAmountRegister;
|
||||
late String devUUID = '';
|
||||
late String userUUID = '';
|
||||
late String cliUUID = '';
|
||||
late String petAmountRegister = '0';
|
||||
dynamic item;
|
||||
|
||||
late final TabController tabBarController;
|
||||
|
@ -111,13 +111,17 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
|||
);
|
||||
dropDownValueController1 = FormFieldController<String>(dropDownValue1 ??= defaultDropDownText);
|
||||
dropDownValueController2 = FormFieldController<String>(dropDownValue2 ??= defaultDropDownText);
|
||||
log('() => ): $devUUID');
|
||||
|
||||
devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
|
||||
userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
|
||||
cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
|
||||
petAmountRegister = (await StorageHelper().get(SQLiteStorageKey.petAmount.value, Storage.SQLiteStorage)) ?? '';
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
devUUID = await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage) ?? '';
|
||||
userUUID = await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage) ?? '';
|
||||
cliUUID = await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage) ?? '';
|
||||
petAmountRegister = await StorageHelper().get(SQLiteStorageKey.petAmount.value, Storage.SQLiteStorage) ?? '';
|
||||
});
|
||||
|
||||
safeSetState?.call();
|
||||
log('() => ): $devUUID');
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -35,6 +35,7 @@ class _PetsPageWidgetState extends State<PetsPageWidget> with SingleTickerProvid
|
|||
void initState() {
|
||||
super.initState();
|
||||
_model = createModel(context, () => PetsPageModel());
|
||||
|
||||
_model.updateOnChange = true;
|
||||
|
||||
_model.onUpdatePet = () {
|
||||
|
|
|
@ -131,19 +131,23 @@ class LocalizationService {
|
|||
static Future<bool> processData(BuildContext context) async {
|
||||
try {
|
||||
final GetDadosCall callback = PhpGroup.getDadosCall;
|
||||
var response = await callback.call();
|
||||
ApiCallResponse? response = await callback.call();
|
||||
final bool? isError = response.jsonBody['error'];
|
||||
|
||||
if (isError == true || isError == 'true') {
|
||||
if (isError == true) {
|
||||
final GetLocalsCall callback = PhpGroup.getLocalsCall;
|
||||
response = await callback.call();
|
||||
final String errorMsg = response.jsonBody['error_msg'];
|
||||
DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response));
|
||||
await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response));
|
||||
return false;
|
||||
} else if (response.jsonBody == null) {
|
||||
final GetLocalsCall callback = PhpGroup.getLocalsCall;
|
||||
response = await callback.call();
|
||||
final String errorMsg = FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Verify your connection',
|
||||
ptText: 'Verifique sua conexão',
|
||||
);
|
||||
DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response));
|
||||
await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response));
|
||||
return false;
|
||||
} else {
|
||||
await _updateStorageUtil(response.jsonBody);
|
||||
|
@ -337,4 +341,3 @@ class LocalizationService {
|
|||
await StorageHelper().set(SQLiteStorageKey.userName.value, jsonBody['visitado']['VDO_NOME'], Storage.SQLiteStorage);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue