Created
October 4, 2021 16:58
-
-
Save brasizza/b57b299a6704cc9aa7508dd8eb2ec4e5 to your computer and use it in GitHub Desktop.
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:get/get.dart'; | |
import 'package:hive_tutorial/app/data/models/todo_model.dart'; | |
import '../controllers/home_controller.dart'; | |
class HomeView extends GetView<HomeController> { | |
const HomeView({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: const Text('Another todo project (but with Getx+ Hive)'), | |
centerTitle: true, | |
), | |
body: Obx(() => ListView.separated( | |
itemCount: controller.todoList.length, | |
itemBuilder: (_, index) { | |
final TodoModel _todo = controller.todoList[index]; | |
return ListTile( | |
title: Text(_todo.title), | |
subtitle: Text(_todo.descritpion ?? ''), | |
); | |
}, | |
separatorBuilder: (_, __) => const Divider(), | |
)), | |
floatingActionButtonLocation: FloatingActionButtonLocation.endFloat, | |
floatingActionButton: ElevatedButton( | |
onPressed: () { | |
controller.fakeTodo(); | |
}, | |
child: const Icon( | |
Icons.add, | |
size: 30, | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment