DraggableScrollableSheet:
import 'package:flutter/material.dart';
// import 'package:ui_flutter/core/res/utils.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: MyHome(),
);
}
}
class MyHome extends StatefulWidget {
@override _MyHomeState createState() => _MyHomeState();
}
class _MyHomeState extends State<MyHome> {
@override Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('DraggableScrollableSheet'),
backgroundColor: Colors.black12,
),
body: Stack(
children: <Widget>[
SizedBox.expand(
child: Container(
color: Colors.yellow[300],
),
),
_buildDraggableScrollableSheet(),
],
),
);
}
DraggableScrollableSheet _buildDraggableScrollableSheet() {
return DraggableScrollableSheet(
initialChildSize: 0.2,
minChildSize: 0.2,
maxChildSize: 0.8,
builder: (BuildContext context, ScrollController scrollController) {
return Container(
decoration: BoxDecoration(
color: Colors.blue[100],
// border: Border.all(color: Colors.blue, width: 2), borderRadius: BorderRadius.only(
topLeft: Radius.circular(15),
topRight: Radius.circular(15),
),
),
child: Scrollbar(
child: ListView.builder(
controller: scrollController,
itemCount: 25,
itemBuilder: (BuildContext context, int index) {
return ListTile(
leading: Icon(Icons.restaurant_menu),
title: Text('Item $index'),
);
},
),
),
);
},
);
}
}
Comments
Post a Comment