2023-07-29 02:17:26 +00:00
|
|
|
import 'package:connectivity_plus/connectivity_plus.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:freezer/translations.i18n.dart';
|
|
|
|
|
|
|
|
int counter = 0;
|
|
|
|
|
|
|
|
class ErrorScreen extends StatefulWidget {
|
|
|
|
final String? message;
|
2023-10-12 22:09:37 +00:00
|
|
|
final VoidCallback? refreshPage;
|
|
|
|
const ErrorScreen({this.message, this.refreshPage, Key? key})
|
|
|
|
: super(key: key);
|
2023-07-29 02:17:26 +00:00
|
|
|
|
|
|
|
@override
|
2023-10-12 22:09:37 +00:00
|
|
|
State<ErrorScreen> createState() => _ErrorScreenState();
|
2023-07-29 02:17:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class _ErrorScreenState extends State<ErrorScreen> {
|
|
|
|
bool checkArl = false;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
Connectivity().checkConnectivity().then((connectivity) {
|
|
|
|
if (connectivity != ConnectivityResult.none && counter > 3) {
|
|
|
|
setState(() {
|
|
|
|
checkArl = true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
counter += 1;
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Center(
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: <Widget>[
|
2023-10-12 22:09:37 +00:00
|
|
|
const Icon(
|
2023-07-29 02:17:26 +00:00
|
|
|
Icons.error,
|
|
|
|
color: Colors.red,
|
|
|
|
size: 64.0,
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
height: 4.0,
|
|
|
|
),
|
|
|
|
Text(widget.message ??
|
|
|
|
'Please check your connection and try again later...'.i18n),
|
|
|
|
if (checkArl)
|
|
|
|
Padding(
|
2023-10-12 22:09:37 +00:00
|
|
|
padding:
|
|
|
|
const EdgeInsets.symmetric(vertical: 8.0, horizontal: 32.0),
|
2023-07-29 02:17:26 +00:00
|
|
|
child: Text(
|
|
|
|
"Your ARL might be expired, try logging out and logging back in using new ARL or browser."
|
|
|
|
.i18n,
|
|
|
|
textAlign: TextAlign.center,
|
2023-10-12 22:09:37 +00:00
|
|
|
style: const TextStyle(
|
2023-07-29 02:17:26 +00:00
|
|
|
fontSize: 12.0,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|