In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to achieve the bottom drawer effect of flutter, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to understand it!
The details are as follows
Android: showModalBottomSheet
IOS:showCupertinoModalPopup
Effect picture
Complete code
Author: Q.L package:flutter/cupertino.dart';import package:flutter/material.dart';///@ author: Q.L const ActionSheetPage const ActionSheetPage @ creation date: 2021-09-09 10 bank 55 const ActionSheetPage @ description: {bottom drawer} const ActionSheetPage ({Key? Key}): super (key: key); @ override _ ActionSheetPageState createState () = > _ ActionSheetPageState () } class _ ActionSheetPageState extends State {@ override Widget build (BuildContext context) {return Scaffold (appBar: AppBar (title: Text ('bottom drawer pops'),), body: Center (child: Column (mainAxisAlignment: MainAxisAlignment.center, children: [ElevatedButton (onPressed: () {_ showModalBottomSheet () }, child: Text ('Android pop'), ElevatedButton (onPressed: () {_ showCupertinoModalPopup ();}, child: Text ('IOS pop')),],),)) } _ showModalBottomSheet () async {var _ result = await showModalBottomSheet (context: context, backgroundColor: Colors.greenAccent, / / background color / / elevation: 500, / / Shadow shape: RoundedRectangleBorder (/ / borderRadius: BorderRadius.all (Radius.circular (10)), / / all fillet borders borderRadius: BorderRadius.only (topLeft: Radius.circular (10)) TopRight: Radius.circular (10)), isScrollControlled: false, / / whether it is full screen or half screen True full screen. Default false half screen isDismissible: true, / / whether the outside can be clicked, false can not be clicked, true can click Click and disappear builder: (BuildContext context) {return Column (mainAxisSize: MainAxisSize.min, / / set the smallest pop-up children: [ListTile (leading: Icon (Icons.photo_camera), title: Text ("photo")) OnTap: () {Navigator.of (context) .pop ('photo') },), ListTile (leading: Icon (Icons.photo_library), title: Text ("album"), onTap: () {Navigator.of (context) .pop ("album") },),],);}); print ('Android = = > > ${_ result?? 'clicked on the screen to cancel'}';} _ showCupertinoModalPopup () async {var result = await showCupertinoModalPopup (context: context, builder: (context) {return CupertinoActionSheet (title: Text ('prompt'), message: Text ('do you want to edit the current item?') , actions: [CupertinoActionSheetAction (child: Text ('edit'), onPressed: () {Navigator.of (context) .pop ('edit') }, isDefaultAction: true,), CupertinoActionSheetAction (child: Text ('delete'), onPressed: () {Navigator.of (context) .pop ('delete') }, isDestructiveAction: true,], cancelButton: CupertinoActionSheetAction (child: Text ('cancel'), onPressed: () {Navigator.of (context) .pop ('cancel');},)) ); print ('selected IOS== > > ${result?? Click on the screen to cancel'}');}} above is all the content of the article "how to achieve the bottom drawer effect in flutter". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.