fix: replace snackbar method with extension method
This commit is contained in:
@@ -3,6 +3,58 @@ import 'package:flutter/material.dart';
|
||||
const smallGap = SizedBox(height: 20);
|
||||
const largeGap = SizedBox(height: 40);
|
||||
|
||||
final appTheme = ThemeData.dark().copyWith(
|
||||
scaffoldBackgroundColor: Colors.black,
|
||||
outlinedButtonTheme: OutlinedButtonThemeData(
|
||||
style: OutlinedButton.styleFrom(
|
||||
primary: Colors.white,
|
||||
side: const BorderSide(color: Colors.white, width: 2),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
padding: const EdgeInsets.all(16),
|
||||
),
|
||||
),
|
||||
elevatedButtonTheme: ElevatedButtonThemeData(
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: Colors.white,
|
||||
onPrimary: Colors.black,
|
||||
textStyle: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
padding: const EdgeInsets.all(16),
|
||||
),
|
||||
),
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
labelStyle: const TextStyle(color: Colors.white),
|
||||
focusColor: Colors.green,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(
|
||||
color: Colors.white,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(
|
||||
color: Colors.green,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
textTheme: const TextTheme(
|
||||
bodyText1: TextStyle(color: Colors.white),
|
||||
bodyText2: TextStyle(color: Colors.white),
|
||||
),
|
||||
);
|
||||
|
||||
Future<void> displayTextInputDialog(
|
||||
BuildContext context,
|
||||
Function()? onTab,
|
||||
@@ -44,13 +96,15 @@ Future<void> displayTextInputDialog(
|
||||
});
|
||||
}
|
||||
|
||||
ScaffoldFeatureController<SnackBar, SnackBarClosedReason> snackbarAlert(
|
||||
{required BuildContext context, required String message}) {
|
||||
return ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(message),
|
||||
duration: const Duration(seconds: 2),
|
||||
extension ShowSnackBar on BuildContext {
|
||||
/// Extention method to easily display error snack bar.
|
||||
void showErrorSnackbar(String text) {
|
||||
ScaffoldMessenger.of(this).showSnackBar(SnackBar(
|
||||
content: Text(
|
||||
text,
|
||||
style: const TextStyle(color: Color(0xFFFFFFFF)),
|
||||
),
|
||||
backgroundColor: Colors.red,
|
||||
),
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,57 +22,7 @@ class MyApp extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: ThemeData.dark().copyWith(
|
||||
scaffoldBackgroundColor: Colors.black,
|
||||
outlinedButtonTheme: OutlinedButtonThemeData(
|
||||
style: OutlinedButton.styleFrom(
|
||||
primary: Colors.white,
|
||||
side: const BorderSide(color: Colors.white, width: 2),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
padding: const EdgeInsets.all(16),
|
||||
),
|
||||
),
|
||||
elevatedButtonTheme: ElevatedButtonThemeData(
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: Colors.white,
|
||||
onPrimary: Colors.black,
|
||||
textStyle: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
padding: const EdgeInsets.all(16),
|
||||
),
|
||||
),
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
labelStyle: const TextStyle(color: Colors.white),
|
||||
focusColor: Colors.green,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(
|
||||
color: Colors.white,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(
|
||||
color: Colors.green,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
textTheme: const TextTheme(
|
||||
bodyText1: TextStyle(color: Colors.white),
|
||||
bodyText2: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
theme: appTheme,
|
||||
initialRoute:
|
||||
AuthSupabase.client.auth.currentSession != null ? "/todo" : "/",
|
||||
routes: {
|
||||
|
||||
@@ -65,9 +65,8 @@ class _SignInPageState extends State<SignInPage> {
|
||||
if (value != null) {
|
||||
Navigator.pushReplacementNamed(context, '/todo');
|
||||
} else {
|
||||
snackbarAlert(
|
||||
context: context,
|
||||
message: "Invalid Email or Password");
|
||||
context
|
||||
.showErrorSnackbar('Invalid Email or Password');
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
@@ -11,7 +11,7 @@ class TodoPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _TodoPageState extends State<TodoPage> {
|
||||
String userName = "";
|
||||
String userName = '';
|
||||
bool loading = true;
|
||||
List<dynamic> todos = [];
|
||||
final TextEditingController _taskEditingController = TextEditingController();
|
||||
|
||||
Reference in New Issue
Block a user