Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: using outlinedButton instead of a custom button

dshukertjr9f1fb8005990
diff --git a/examples/todo-list/flutter-todo-list/lib/constant.dart b/examples/todo-list/flutter-todo-list/lib/constant.dart
index 9570c7f0dee..cda82944267 100644
--- a/examples/todo-list/flutter-todo-list/lib/constant.dart
+++ b/examples/todo-list/flutter-todo-list/lib/constant.dart
@@ -1,37 +1,7 @@
import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
-boxSmall() => const SizedBox(height: 20);
-boxLarge() => const SizedBox(height: 40);
-
-Widget buttonCustom(
- {required String text,
- required Function() onPressed,
- required bool filled}) {
- return GestureDetector(
- onTap: onPressed,
- child: Container(
- height: 50,
- width: 300,
- decoration: BoxDecoration(
- color: filled ? Colors.white : Colors.transparent,
- border: Border.all(
- color: Colors.white,
- width: 2,
- ),
- borderRadius: BorderRadius.circular(20),
- ),
- child: Center(
- child: Text(
- text,
- style: TextStyle(
- color: filled ? Colors.black : Colors.white,
- fontWeight: FontWeight.bold),
- ),
- ),
- ),
- );
-}
+const smallGap = SizedBox(height: 20);
+const largeGap = SizedBox(height: 40);
Widget textFeildCustom(String hintText, TextEditingController ctlr) {
return SizedBox(
@@ -74,7 +44,7 @@ Future<void> displayTextInputDialog(
context: context,
builder: (context) {
return AlertDialog(
- title: Text('Add a todo'),
+ title: const Text('Add a todo'),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
@@ -89,7 +59,7 @@ Future<void> displayTextInputDialog(
decoration:
const InputDecoration(hintText: "Add Due Date in DD/MM"),
),
- boxSmall(),
+ smallGap,
MaterialButton(
onPressed: onTab,
child: const Text("Add Task",
@@ -97,7 +67,7 @@ Future<void> displayTextInputDialog(
color: Colors.white,
fontWeight: FontWeight.bold,
)),
- color: Color(0xff33b27b),
+ color: const Color(0xff33b27b),
)
],
),
diff --git a/examples/todo-list/flutter-todo-list/lib/main.dart b/examples/todo-list/flutter-todo-list/lib/main.dart
index 19d00d10e7c..3080e75fd38 100644
--- a/examples/todo-list/flutter-todo-list/lib/main.dart
+++ b/examples/todo-list/flutter-todo-list/lib/main.dart
@@ -25,6 +25,16 @@ class MyApp extends StatelessWidget {
theme: ThemeData.dark(),
darkTheme: ThemeData(
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),
+ ),
+ ),
textTheme: const TextTheme(
bodyText1: TextStyle(color: Colors.white),
bodyText2: TextStyle(color: Colors.white),
@@ -61,20 +71,20 @@ class MyHomePageState extends State<MyHomePage> {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SvgPicture.asset("assets/supabase-dark.svg", width: 200),
- boxLarge(),
- buttonCustom(
- text: "Sign In",
- onPressed: () {
- Navigator.pushNamed(context, "/signin");
- },
- filled: false),
- boxSmall(),
- buttonCustom(
- text: "Sign Up",
- onPressed: () {
- Navigator.pushNamed(context, "/signup");
- },
- filled: false)
+ largeGap,
+ OutlinedButton(
+ child: const Text("Sign In"),
+ onPressed: () {
+ Navigator.pushNamed(context, "/signin");
+ },
+ ),
+ smallGap,
+ OutlinedButton(
+ child: const Text("Sign Up"),
+ onPressed: () {
+ Navigator.pushNamed(context, "/signup");
+ },
+ )
],
),
),
diff --git a/examples/todo-list/flutter-todo-list/lib/screens/signin.dart b/examples/todo-list/flutter-todo-list/lib/screens/signin.dart
index 5ae1120a81f..e187080c2d6 100644
--- a/examples/todo-list/flutter-todo-list/lib/screens/signin.dart
+++ b/examples/todo-list/flutter-todo-list/lib/screens/signin.dart
@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:todosupabase/constant.dart';
import 'package:todosupabase/functions/auth.dart';
-import 'package:todosupabase/functions/crud.dart';
class SignInPage extends StatefulWidget {
const SignInPage({Key? key}) : super(key: key);
@@ -26,17 +25,17 @@ class _SignInPageState extends State<SignInPage> {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SvgPicture.asset("assets/supabase-dark.svg", width: 200),
- boxLarge(),
+ largeGap,
textFeildCustom(
"Email",
_emailController,
),
- boxSmall(),
+ smallGap,
textFeildCustom(
"Password",
_passwordController,
),
- boxSmall(),
+ smallGap,
loading
? Container(
height: 50,
@@ -49,8 +48,8 @@ class _SignInPageState extends State<SignInPage> {
child: CircularProgressIndicator(),
),
)
- : buttonCustom(
- text: "Sign In",
+ : OutlinedButton(
+ child: const Text("Sign In"),
onPressed: () async {
setState(() {
loading = true;
@@ -69,7 +68,7 @@ class _SignInPageState extends State<SignInPage> {
message: "Invalid Email or Password");
}
},
- filled: true)
+ )
],
),
),
diff --git a/examples/todo-list/flutter-todo-list/lib/screens/signup.dart b/examples/todo-list/flutter-todo-list/lib/screens/signup.dart
index 8c3ef1e3d11..f185e473d2f 100644
--- a/examples/todo-list/flutter-todo-list/lib/screens/signup.dart
+++ b/examples/todo-list/flutter-todo-list/lib/screens/signup.dart
@@ -26,40 +26,38 @@ class _SignUpPageState extends State<SignUpPage> {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SvgPicture.asset("assets/supabase-dark.svg", width: 200),
- boxLarge(),
+ largeGap,
textFeildCustom(
"Full Name",
_nameController,
),
- boxSmall(),
+ smallGap,
textFeildCustom(
"Email",
_emailController,
),
- boxSmall(),
+ smallGap,
textFeildCustom(
"Password",
_passwordController,
),
- boxSmall(),
- buttonCustom(
- text: "Sign Up",
- onPressed: () async {
- var value = await AuthSupabase.createAccount(
- email: _emailController.text,
- password: _passwordController.text);
- if (value == true) {
- CrudSupabase.addUser(
- name: _nameController.text,
- email: _emailController.text);
- Navigator.pushReplacementNamed(context, "/signin");
- }
- },
- filled: true)
+ smallGap,
+ OutlinedButton(
+ child: const Text("Sign Up"),
+ onPressed: () async {
+ var value = await AuthSupabase.createAccount(
+ email: _emailController.text,
+ password: _passwordController.text);
+ if (value == true) {
+ CrudSupabase.addUser(
+ name: _nameController.text, email: _emailController.text);
+ Navigator.pushReplacementNamed(context, "/signin");
+ }
+ },
+ )
],
),
),
);
- ;
}
}