-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Implemented the Custom Error Screen (#183)
* adding the error svg asset * implementing the custom error screen * adding the builder function to material app * adding the title showing that error has occurred * changing the fromLTRB to all
- Loading branch information
1 parent
03bc8a1
commit 224d5e2
Showing
3 changed files
with
119 additions
and
3 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_svg/svg.dart'; | ||
import 'package:get/get.dart'; | ||
import 'package:ultimate_alarm_clock/app/modules/settings/controllers/theme_controller.dart'; | ||
import 'package:ultimate_alarm_clock/app/utils/constants.dart'; | ||
|
||
class CustomErrorScreen extends StatefulWidget { | ||
const CustomErrorScreen({ | ||
super.key, | ||
required this.errorDetails, | ||
}); | ||
|
||
final FlutterErrorDetails? errorDetails; | ||
|
||
@override | ||
State<CustomErrorScreen> createState() => _CustomErrorScreenState(); | ||
} | ||
|
||
class _CustomErrorScreenState extends State<CustomErrorScreen> { | ||
ThemeController themeController = Get.put<ThemeController>(ThemeController()); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
var height = Get.height; | ||
var width = Get.width; | ||
return Scaffold( | ||
backgroundColor: themeController.isLightMode.value | ||
? kLightPrimaryBackgroundColor | ||
: kprimaryBackgroundColor, | ||
body: SafeArea( | ||
child: SingleChildScrollView( | ||
child: Padding( | ||
padding: const EdgeInsets.all(16), | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
Text( | ||
'Error Occurred', | ||
style: Theme.of(context).textTheme.titleLarge!.copyWith( | ||
color: themeController.isLightMode.value | ||
? kLightPrimaryTextColor | ||
: kprimaryTextColor, | ||
), | ||
), | ||
SizedBox( | ||
height: height * 0.18, | ||
), | ||
SvgPicture.asset( | ||
'assets/images/warning.svg', | ||
height: height * 0.3, | ||
width: width * 0.8, | ||
), | ||
const SizedBox( | ||
height: 30, | ||
), | ||
Text( | ||
kDebugMode | ||
? widget.errorDetails!.summary.toString() | ||
: 'Something went wrong! Don\'t worry we\'re' | ||
'working on it!', | ||
textAlign: TextAlign.center, | ||
style: Theme.of(context).textTheme.bodyMedium!.copyWith( | ||
color: themeController.isLightMode.value | ||
? kLightPrimaryTextColor | ||
: kprimaryTextColor, | ||
), | ||
), | ||
const SizedBox( | ||
height: 30, | ||
), | ||
OutlinedButton( | ||
onPressed: () { | ||
Get.offNamedUntil( | ||
'/home', | ||
(route) => route.settings.name == '/splash-screen', | ||
); | ||
}, | ||
style: OutlinedButton.styleFrom( | ||
side: const BorderSide( | ||
color: kprimaryColor, | ||
width: 1, | ||
), | ||
), | ||
child: Text( | ||
'Navigate to Home', | ||
style: Theme.of(context).textTheme.bodyMedium!.copyWith( | ||
color: kprimaryColor, | ||
), | ||
), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters