This file contains hidden or 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
{ | |
"search.followSymlinks": false, | |
/// CUSTOMIZATION | |
"editor.fontSize": 13.5, | |
"terminal.integrated.fontSize": 13.5, | |
"debug.console.fontSize": 13.5, | |
// "editor.fontSize": 20, | |
// "terminal.integrated.fontSize": 20, | |
// "debug.console.fontSize": 20, | |
"editor.fontWeight": "600", |
This file contains hidden or 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
return ElevatedButton( | |
onPressed: () { | |
context.read<TodoCubit>().addTodo(Todo(todoText: _controller.text.trim(), createdAt: Timestamp.now())); | |
_controller.text = ''; | |
}, | |
child: Text(_addButtonText), | |
); | |
return Dismissible( | |
key: UniqueKey(), |
This file contains hidden or 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
child: BlocBuilder<TodoCubit, TodoState>( | |
builder: (context, state) { | |
if (state is TodoLoading) { | |
return const Center(child: CircularProgressIndicator()); | |
} else if (state is TodoInitial) { | |
return Center(child: Text(_initialText)); | |
} else if (state is TodoSuccess) { | |
var todoList = state.todos ?? dummyList; | |
return ListView.builder( | |
itemCount: todoList.length, |
This file contains hidden or 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
TodoCubit({ITodoRepository? todoRepository}) | |
: _todoRepository = todoRepository ?? TodoRepository(), | |
super(TodoInitial()); | |
final ITodoRepository _todoRepository; |
This file contains hidden or 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
class TodoCubit extends Cubit<TodoState> { | |
TodoCubit({ITodoRepository? todoRepository}) | |
: _todoRepository = todoRepository ?? TodoRepository(), | |
super(TodoInitial()); | |
final ITodoRepository _todoRepository; | |
Future<void> getAllTodo() async { | |
emit(TodoLoading()); | |
final results = await _todoRepository.getAllTodos(); |
This file contains hidden or 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
abstract class TodoState { | |
TodoState(); | |
} | |
class TodoInitial extends TodoState { | |
TodoInitial(); | |
} | |
class TodoLoading extends TodoState { | |
TodoLoading(); |
This file contains hidden or 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
@override | |
Future<void> addTodo(Todo todo) async { | |
await firestore.collection(_collectionPath).add(todo.toJson()); | |
} | |
@override | |
Future<void> removeTodo(Todo todo) async { | |
await firestore.collection(_collectionPath).doc(todo.id).delete(); | |
} |
This file contains hidden or 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
Todo todoFromJson(String str) => Todo.fromJson(json.decode(str)); | |
String todoToJson(Todo data) => json.encode(data.toJson()); | |
class Todo { | |
String? id; | |
final String todoText; | |
final Timestamp createdAt; | |
Todo({required this.todoText, required this.createdAt, this.id}); |
This file contains hidden or 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
Future<List<Todo>> getAllTodos() async { | |
List<Todo> todos = []; | |
final results = await firestore.collection(_collectionPath).orderBy(_orderField).get(); | |
for (var snapshot in results.docs) { | |
Todo newTodo = Todo.fromJson(snapshot.data()); | |
newTodo.id = snapshot.id; | |
todos.add(newTodo); | |
} | |
return todos; | |
} |
This file contains hidden or 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'; | |
import 'dart:io'; | |
import 'package:fl_chart/fl_chart.dart'; | |
import 'package:flutter/material.dart'; | |
class CSVLineChart extends StatefulWidget { | |
@override | |
State<StatefulWidget> createState() => CSVLineChartState(); | |
} |
NewerOlder