provider_persist icon indicating copy to clipboard operation
provider_persist copied to clipboard

infinite CircularProgressIndicator

Open xai1983kbu opened this issue 5 years ago • 0 comments

We start from an empty list of tasks so that we always see CircularProgressIndicator() in action.

I think would be nice to comment out related part of code as I did below.

class TasksScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Flutter Task Manager'),
      ),
      body: Consumer<TaskProvider>(
        builder: (context, model, child) {
          if (model?.tasks == null) {
            return Center(
              child: CircularProgressIndicator(),
            );
          }
         //if (model.tasks.isEmpty) {
         // return Center(
         //   child: Text('No Tasks Found'),
         // );
         // }
          return ListView.separated(
            separatorBuilder: (context, index) => Divider(),
            itemCount: model.tasks.length,
            itemBuilder: (context, index) {
              final _item = model.tasks[index];
              return ListTile(
                title: Text(_item.name),
                trailing: IconButton(
                  icon: Icon(Icons.delete),
                  onPressed: () => model.deleteTask(index),
                ),
                onTap: () => _editTask(context, _item, index),
              );
            },
          );
        },
      ),

xai1983kbu avatar Jan 31 '20 18:01 xai1983kbu