ffix: move theme and screen to widgetsBinding

This commit is contained in:
jantunesmessias 2024-11-18 16:58:27 -03:00
parent e67b643b47
commit cf0e17662e
4 changed files with 9 additions and 8 deletions

View File

@ -25,7 +25,7 @@ class _SignInPageWidgetState extends State<SignInPageWidget> {
void initState() {
super.initState();
_model = createModel(context, () => SignInPageModel());
DeepLinkService().initDeepLinks();
DeepLinkService().ensureInitialization();
}
@override

View File

@ -26,7 +26,7 @@ class _SignUpPageWidgetState extends State<SignUpPageWidget> {
void initState() {
super.initState();
_model = createModel(context, () => SignUpPageModel());
DeepLinkService().initDeepLinks();
DeepLinkService().ensureInitialization();
}
@override

View File

@ -43,7 +43,7 @@ class _WelcomePageWidgetState extends State<WelcomePageWidget> {
setState(() {});
}
});
DeepLinkService().initDeepLinks();
DeepLinkService().ensureInitialization();
}
@override

View File

@ -12,11 +12,12 @@ class DeepLinkService {
DeepLinkService._internal();
late final AppLinks _appLinks;
StreamSubscription<Uri>? _linkSubscription;
bool _isInitialized = false;
Future<void> initDeepLinks() async {
Future<void> ensureInitialization() async {
if (_isInitialized) return;
try {
_appLinks = AppLinks();
print('initDeepLinks');
@ -25,6 +26,7 @@ class DeepLinkService {
await _handleDeepLink(uri);
}
});
_isInitialized = true;
} catch (e) {
print('Error initializing deep links: $e');
}
@ -45,10 +47,9 @@ class DeepLinkService {
}
Future<void> _showForgotPasswordScreen(String email, String token) async {
final theme = FlutterFlowTheme.of(StorageHelper().context!);
final screen = ForgotPasswordScreen(email: email, token: token);
WidgetsBinding.instance.addPostFrameCallback((_) async {
final theme = FlutterFlowTheme.of(StorageHelper().context!);
final screen = ForgotPasswordScreen(email: email, token: token);
await showModalBottomSheet(
context: StorageHelper().context!,
builder: (context) => Padding(