(Flutter)消息滑块
CODE
import 'package:flutter/material.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
void main() {
return runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MyHomePage(),
debugShowCheckedModeBanner: false,
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key}) : super(key: key);
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: ListView(
children: [
Slidable(
startActionPane: ActionPane(
motion: ScrollMotion(),
children: [
SlidableAction(
onPressed: (context) {
// call number
},
icon: Icons.phone,
),
],
),
endActionPane: ActionPane(
motion: ScrollMotion(),
children: [
SlidableAction(
onPressed: (context) {
// call number
},
icon: Icons.delete,
),
],
),
child: Container(
color: Colors.grey,
child: ListTile(
title: Text('Hello World'),
//trailing: Icon(Icons.delete),
subtitle: Text('Hello World'),
leading: Icon(Icons.star),
),
),
),
],
),
);
}
}
预览

License:
CC BY 4.0