flutterapp Geç cevap verdiğim için kusura bakmayın
aşağıdaki gibi kullanırsanız çalışır hocam
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(home: HomePage()));
}
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
final _scaffoldKey = GlobalKey<ScaffoldState>();
final _list = List<String>();
int i = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
key: _scaffoldKey,
body: ListView.builder(
itemCount: _list.length,
itemBuilder: (ctx, index) {
return Dismissible(
resizeDuration: Duration(seconds: 1),
background: Container(
color: Colors.green,
),
onDismissed: (d) {
setState(() {
_displaySnackBar(context);
_list.removeAt(index);
});
},
key: ValueKey(_list.elementAt(index)),
child: ListTile(
title: Text(_list.elementAt(index)),
));
}),
floatingActionButton: FloatingActionButton(
onPressed: () {
setState(() {
++i;
_list.add("item $i");
});
},
),
);
}
_displaySnackBar(BuildContext context) {
final snackBar = SnackBar(content: Text('Are you talkin\' to me?'));
_scaffoldKey.currentState.showSnackBar(snackBar);
}
}
@flutterapp#2448