Horje
Flutter: remove item doesn't reflect on UI Code Example
Flutter: remove item doesn't reflect on UI
class MyList extends StatefulWidget {
  @override
  _MyListState createState() => _MyListState();
}

class _MyListState extends State<MyList> {
  List<String> list = List.generate(100, (i) => i.toString());

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
      itemCount: list.length,
      itemBuilder: (context, index) {
        return MyItem(list[index], onDelete: () => removeItem(index));
      },
    );
  }

  void removeItem(int index) {
    setState(() {
      list = List.from(list)
        ..removeAt(index);
    });
  }
}

class MyItem extends StatelessWidget {
  final String title;
  final VoidCallback onDelete;

  MyItem(this.title, {this.onDelete});

  @override
  Widget build(BuildContext context) {
    return ListTile(
      title: Text(this.title),
      onTap: this.onDelete,
    );
  }
}




Whatever

Related
upload file  check the file type Code Example upload file check the file type Code Example
hypercorn initiate Code Example hypercorn initiate Code Example
Uncaught Error: Class 'NOOP_Translations' not found Code Example Uncaught Error: Class 'NOOP_Translations' not found Code Example
How to put water while falling like dream Code Example How to put water while falling like dream Code Example
geth terminology Code Example geth terminology Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7