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
import 'package:flutter_supabase_yt_1/models/models.dart'; // this is being used to import the todo.dart from models file. | |
import 'package:supabase_flutter/supabase_flutter.dart'; | |
class SupabaseDataManager { | |
// create function which takes one argument of Todo | |
Future<PostgrestResponse<dynamic>> createData(Todo todo) async { | |
PostgrestResponse<dynamic> res = await Supabase.instance.client | |
.from('todos') | |
// here 👇 you need to make todo.toMap() because we need to make Todo model to map --> eg Todo(title: 'This is first todo') -> {'title': 'This is first todo'} | |
.insert(todo.toMap()) |
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
import 'dart:convert'; | |
class Todo { | |
final int? | |
id; // we are keeping the id to be nullable because we will use Todo type object as argument in create function. | |
// So there, we will not pass any id but the supabase will automatically generate it for us. | |
final String title; | |
Todo({ | |
this.id, | |
required this.title, |
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
import 'package:flutter/material.dart'; | |
import 'package:flutter_supabase_yt_1/models/models.dart'; | |
import 'package:flutter_supabase_yt_1/utils/utils.dart'; | |
import 'package:supabase_flutter/supabase_flutter.dart'; | |
class CreateScreen extends StatefulWidget { | |
const CreateScreen({Key? key}) : super(key: key); | |
@override | |
State<CreateScreen> createState() => _CreateScreenState(); |
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
import 'package:flutter/material.dart'; | |
import 'package:flutter_supabase_yt_1/models/models.dart'; | |
import 'package:flutter_supabase_yt_1/utils/utils.dart'; | |
import 'package:supabase_flutter/supabase_flutter.dart'; | |
class ReadScreen extends StatelessWidget { | |
const ReadScreen({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { |
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
import 'package:flutter/material.dart'; | |
import 'package:flutter_dotenv/flutter_dotenv.dart'; | |
import 'package:flutter_supabase_yt_1/screens/screens.dart'; | |
import 'package:supabase_flutter/supabase_flutter.dart'; | |
Future<void> main() async { | |
WidgetsFlutterBinding.ensureInitialized(); | |
// load env | |
await dotenv.load(); |
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
export 'create_screen.dart'; | |
export 'read_screen.dart'; |
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
import 'package:flutter_supabase_yt_1/models/models.dart'; // this is being used to import the todo.dart from models file. | |
import 'package:supabase_flutter/supabase_flutter.dart'; | |
class SupabaseDataManager { | |
// create function which takes one argument of Todo | |
Future<PostgrestResponse<dynamic>> createData(Todo todo) async { | |
PostgrestResponse<dynamic> res = await Supabase.instance.client | |
.from('todos') | |
// here 👇 you need to make todo.toMap() because we need to make Todo model to map --> eg Todo(title: 'This is first todo') -> {'title': 'This is first todo'} | |
.insert(todo.toMap()) |
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
import 'package:flutter/material.dart'; | |
import 'package:flutter_supabase_yt_1/models/models.dart'; | |
import 'package:flutter_supabase_yt_1/screens/create_screen.dart'; | |
import 'package:flutter_supabase_yt_1/screens/home_screen.dart'; | |
import 'package:flutter_supabase_yt_1/screens/screens.dart'; | |
import 'package:flutter_supabase_yt_1/utils/utils.dart'; | |
import 'package:supabase_flutter/supabase_flutter.dart'; | |
class ReadScreen extends StatelessWidget { | |
const ReadScreen({Key? key}) : super(key: key); |
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
import 'package:flutter/material.dart'; | |
import 'package:supabase_flutter/supabase_flutter.dart'; | |
import 'package:flutter_supabase_yt_1/models/models.dart'; | |
import 'package:flutter_supabase_yt_1/utils/utils.dart'; | |
class EditScreen extends StatefulWidget { | |
const EditScreen({ | |
Key? key, | |
required this.todo, |
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
{ | |
"name": [YOUR-PROJECT-NAME-HERE], | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"dev": "nodemon src/index.ts", | |
"build": "tsc -p ." | |
}, |
OlderNewer