当前位置:网站首页>[shutter -- geTx] pop up - dialog, snackBar, bottomsheet
[shutter -- geTx] pop up - dialog, snackBar, bottomsheet
2022-07-26 21:50:00 【Kevin-Dev】

List of articles
Preface
This article is based on the latest official stable version get: ^4.5.1 To develop .
By reading this article , You will learn the following :
- Will use Dialog
- Will use Snackbar
- Will use BottomSheet
GetX Integrate
1. stay pubspec.yaml Add... To the file GetX Dependence , as follows :
dependencies:
flutter:
sdk: flutter
get: ^4.5.1
2. Need to be right GetX To initialize , Default MaterialApp Replace with GetMaterialApp that will do , as follows :
class MyApp extends StatelessWidget {
const MyApp({
Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return GetMaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: HomePage(),
);
}
}
Dialog
1. brief introduction
Dialog The bottom is actually right AlertDialog It was packaged , The pop-up box is generally used for secondary confirmation , For example, when you click a button to submit data , User's second confirmation is required , To prevent misoperation .
2. attribute


3. Use
- design sketch

- Code
import 'package:flutter/material.dart';
import 'package:get/get.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({
Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return GetMaterialApp(
title: 'Flutter Demo',
home: Scaffold(
appBar: AppBar(
title: Text('GetX The dialog box basically uses '),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
ElevatedButton(
onPressed: (){
Get.defaultDialog(onConfirm: () => print("Ok"), middleText: "Dialog made in 3 lines of code");
},
child: Text(" Show Dialog"),
),
],
),
)
)
);
}
}
Snackbar
1. brief introduction
If you want to trigger certain events in the application , Need to pop up a shortcut message , So use Snackbar It's the best choice , Let's take a look GetX How to conduct joint commissioning Snackbar To use .
2. attribute



3. Use
design sketch

Code
import 'package:flutter/material.dart';
import 'package:get/get.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({
Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return GetMaterialApp(
title: 'Flutter Demo',
home: Scaffold(
appBar: AppBar(
title: Text('GetX The dialog box basically uses '),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
ElevatedButton(
onPressed: (){
Get.snackbar("Snackbar title ", " Welcome to use Snackbar");
},
child: Text(" Show Snackbar"),
),
],
),
)
)
);
}
}
BottomSheet
1. brief introduction
BottomSheet Is a component that pops up at the bottom , It is often used for single selection 、 Verification code secondary verification pop-up window, etc ,GetX Of BottomSheet The bottom pop-up is a custom route push The method realizes an effect of pop-up window at the bottom .
2. attribute

3. Use
- design sketch

- Code
import 'package:flutter/material.dart';
import 'package:get/get.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({
Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return GetMaterialApp(
title: 'Flutter Demo',
home: Scaffold(
appBar: AppBar(
title: Text('GetX The dialog box basically uses '),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
ElevatedButton(
onPressed: (){
Get.bottomSheet(
Container(
child: Wrap(
children: <Widget>[
ListTile(leading: Icon(Icons.music_note), title: Text('Music'), onTap: () => {
}),
ListTile(
leading: Icon(Icons.videocam),
title: Text('Video'),
onTap: () => {
},
),
],
),
),
backgroundColor: Colors.white);
},
child: Text("BottomSheets"),
),
],
),
)
)
);
}
}
边栏推荐
- 获取文本选择的方向
- Pytorch torch.add() torch.add_() 用法
- 25 cool interactive charts, one entry plotly
- 彻底搞通服务发现的原理和实现
- Supplement - nonlinear programming
- Search eBay product API by keyword
- The United States once again challenged: Forbidding contractors to purchase the equipment and technology of these five Chinese companies
- If you do not add waitkey() function after imshow() function, it will not be displayed
- Uncover the secrets of Xiaomi 100million pixel camera: 1/1.3 inch COMS sensor, resolution 12032 × nine thousand and twenty-four
- 测试员:“我有五年测试经验”HR: “不,你只是把一年的工作经验用了五年”
猜你喜欢

VI and VIM text editors

A new technical director asked me to do an IP territorial function~

day07-

(C语言)文件的基本操作

《暑假每日一题》Week 7:7.18 - 7.24

Type assertion in typescript

Can I view the history in the "stealth" mode of the secure browser?

从手动测试,到自动化测试老司机,只用了几个月,我的薪资翻了一倍

七、微信小程序运行报错:Error: AppID 不合法,invalid appid

Pytoch uses RNN model to build person name classifier
随机推荐
Resume in 2022 is dead in the sea. Don't vote. Software testing positions are saturated
六、微信小程序发布流程
What to do if the browser home page is tampered with, and how to recover if the home page is tampered with
技术分享 | 服务端接口自动化测试, Requests 库的这些功能你了解吗?
TypeScript中的类型断言
A unified label space for entity relationship extraction
day07-
从手动测试,到自动化测试老司机,只用了几个月,我的薪资翻了一倍
Flash source code startup phase
三星发布1.08亿像素图像传感器ISOCELL Bright HMX,小米将首发
Keyword maintenance of dream weaving document doesn't work
CMake 的使用
event.preventDefault VS return false
Cmake compiling obs-studio-27.2.0
ansible安装及使用
(C语言)文件的基本操作
Pytorch torch. add() torch. add_ () usage
Show load indicator when loading iframe
Devops has been practiced for many years. What is the most painful thing?
Search eBay product API by keyword