Flutter UI组件插件flutter_kingmed_ui的使用
Flutter UI组件插件flutter_kingmed_ui的使用
Features
TODO: 列出您的包可以做什么。也许可以包含图片、动图或视频。
Getting started
请参阅示例代码。
示例代码
以下是使用 flutter_kingmed_ui
插件的完整示例代码:
示例代码:example/lib/main.dart
import 'package:example/page/drop_down_page.dart'; // 引入下拉弹框页面
import 'package:example/page/step_page.dart'; // 引入步骤条页面
import 'package:example/page/tab_test.dart'; // 引入自定义TabBar页面
import 'package:flutter/material.dart';
import 'package:flutter_kingmed_ui/flutter_kingmed_ui.dart'; // 引入flutter_kingmed_ui插件
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
[@override](/user/override)
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
[@override](/user/override)
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
GlobalKey key1 = new GlobalKey();
[@override](/user/override)
void initState() {
super.initState();
}
[@override](/user/override)
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Container(
padding: EdgeInsets.all(12),
child: Column(
children: [
SizedBox(height: 20),
// 按钮组
Wrap(
children: [
TextButton(
onPressed: () => showSwitchHiintDialog(),
child: Text('不再提示弹窗'),
),
TextButton(
onPressed: () => showLoading(),
child: Text('loading'),
),
TextButton(
onPressed: () => showSpinLoading(),
child: Text('loading spin'),
),
TextButton(
onPressed: () => showLoadingText(),
child: Text('页面加载带文字'),
),
// 状态小部件
StatusWidget(),
// 部分加载视图
PartLoadView(
loadWidth: 100,
child: Container(
alignment: Alignment.center,
child: Icon(Icons.local_shipping, size: 50,),
),
isLoad: true,
),
// 信息展示弹窗按钮
TextButton(
onPressed: () => showIconHintDialog(),
child: Text('信息展示弹窗'),
),
// 自定义TabBar页面跳转按钮
TextButton(
onPressed: () => pageToTabBar(),
child: Text('自定义tabbar'),
),
// 下拉弹框页面跳转按钮
TextButton(
onPressed: () => pageToDrodown(),
child: Text('下拉弹框'),
),
// 步骤条页面跳转按钮
TextButton(
onPressed: () => pageToStepView(),
child: Text('步骤条'),
),
// 不同类型的消息提示按钮
Row(
children: [
TextButton(
onPressed: () =>
MessageSnackBar.showMessage(
context, MessageType.success, '西域带风湿透黄昏街市', backgroundColor: Colors.teal),
child: Text('成功'),
),
TextButton(
onPressed: () =>
MessageSnackBar.showMessage(
context, MessageType.warn, '西域带风湿透黄昏街市'),
child: Text('警告'),
),
TextButton(
onPressed: () =>
MessageSnackBar.showMessage(
context, MessageType.info, '西域带风湿透黄昏街市'),
child: Text('消息'),
),
TextButton(
onPressed: () =>
MessageSnackBar.showMessage(
context, MessageType.error, '西域带风湿透黄昏街市'),
child: Text('错误'),
),
],
),
// MessageDialog示例
Row(
children: [
Text('MessageDialog'),
TextButton(
onPressed: () => MessageDialog.show(
context,
MessageType.warn,
"清除所有缓存",
'所有将会被充值,请注意此项操作,请务必确定,请注意此项操作,请务必确定请注意此项操作,请务必确定请注意此项操作,请务必确定',
),
child: Text('警告'),
),
TextButton(
onPressed: () => MessageDialog.show(
context,
MessageType.info,
"清除所有缓存",
'所有将会被充值,请注意此项操作,请务必确定,请注意此项操作,请务必确定请注意此项操作,请务必确定请注意此项操作,请务必确定',
),
child: Text('消息'),
),
TextButton(
onPressed: () => MessageDialog.show(
context,
MessageType.error,
"清除所有缓存",
'所有将会被充值,请注意此项操作,请务必确定,请注意此项操作,请务必确定请注意此项操作,请务必确定请注意此项操作,请务必确定',
),
child: Text('错误'),
),
],
),
// 成功动画示例
SuccessAnimationWidget(),
],
),
],
),
),
);
}
// 弹窗示例
showSwitchHiintDialog() {
SwitchHintDialog switchHintDialog = new SwitchHintDialog(
context,
actionkeyText: "actionkeysss",
comfirmStyle: TextStyle(color: Colors.red),
checkColor: Colors.red,
content: "是否确定提交数据进行条码管理吗试试?",
executeCall: () {
print('onConfirm');
},
);
switchHintDialog.show();
}
// 带文字的加载对话框
showLoadingText() {
LoadingDialogText loadingDialogText = new LoadingDialogText(
context,
title: '全力加载中',
);
loadingDialogText.show();
}
// 信息提示弹窗
showIconHintDialog() {
NormalHintDialog iconHintDialog = new NormalHintDialog(
context,
confirmTextStyle: new TextStyle(
fontSize: 18,
decoration: TextDecoration.none,
color: Colors.white,
),
contentTextStyle: new TextStyle(
fontSize: 18,
decoration: TextDecoration.none,
),
content: "使用红外扫描条码可以快速接收标本箱",
);
iconHintDialog.show();
}
// 加载旋转对话框
showSpinLoading() {
LoadingSpinDialog loadingSpinDialog = new LoadingSpinDialog(
context,
showBg: false,
);
loadingSpinDialog.show();
}
// 普通加载对话框
showLoading() {
LoadingDialog loadingDialog = new LoadingDialog(context);
loadingDialog.show();
}
// 跳转到自定义TabBar页面
pageToTabBar() {
Navigator.of(context).push(new MaterialPageRoute(builder: (buildContext) {
return TabTest();
}));
}
// 跳转到下拉弹框页面
pageToDrodown() {
Navigator.of(context).push(new MaterialPageRoute(builder: (buildContext) {
return DropDownPage();
}));
}
// 跳转到步骤条页面
pageToStepView() {
Navigator.of(context).push(new MaterialPageRoute(builder: (buildContext) {
return StepPage();
}));
}
// 显示提示消息
showTips() {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
margin: EdgeInsets.fromLTRB(12, 0, 12, 24),
behavior: SnackBarBehavior.floating,
backgroundColor: Colors.blue,
content: Container(
child: Row(
children: [
Icon(Icons.check_circle, color: Colors.white),
SizedBox(width: 12),
Text(
'恭喜你,提交标本箱成功',
style: new TextStyle(
fontSize: 14,
color: Colors.white,
),
),
],
),
),
));
}
}
更多关于Flutter UI组件插件flutter_kingmed_ui的使用的实战教程也可以访问 https://www.itying.com/category-92-b0.html
更多关于Flutter UI组件插件flutter_kingmed_ui的使用的实战系列教程也可以访问 https://www.itying.com/category-92-b0.html
flutter_kingmed_ui
是一个自定义的 Flutter UI 组件库,通常包含了一些预定义的 UI 组件和样式,可以帮助开发者快速构建美观且功能丰富的应用程序。要使用 flutter_kingmed_ui
插件,通常需要按照以下步骤进行:
1. 添加依赖
首先,你需要在 pubspec.yaml
文件中添加 flutter_kingmed_ui
的依赖项。打开 pubspec.yaml
文件,并在 dependencies
部分添加以下内容:
dependencies:
flutter:
sdk: flutter
flutter_kingmed_ui: ^1.0.0 # 请使用最新版本
然后运行 flutter pub get
来获取依赖包。
2. 导入包
在你的 Dart 文件中导入 flutter_kingmed_ui
包:
import 'package:flutter_kingmed_ui/flutter_kingmed_ui.dart';
3. 使用组件
flutter_kingmed_ui
提供了许多自定义的 UI 组件,你可以直接在代码中使用这些组件。以下是一些常见的组件示例:
按钮组件
KingMedButton(
onPressed: () {
// 处理按钮点击事件
},
text: '点击我',
);
输入框组件
KingMedTextField(
hintText: '请输入内容',
onChanged: (value) {
// 处理输入内容变化
},
);
卡片组件
KingMedCard(
child: Text('这是一个卡片组件'),
);
对话框组件
KingMedDialog.show(
context: context,
title: '提示',
content: '这是一个对话框示例',
actions: [
KingMedDialogAction(
text: '确定',
onPressed: () {
// 处理确定按钮点击事件
},
),
],
);
4. 自定义主题
flutter_kingmed_ui
可能还提供了一些自定义主题和样式,你可以在 MaterialApp
中应用这些主题:
MaterialApp(
theme: KingMedTheme.light(), // 使用 light 主题
home: MyHomePage(),
);
5. 其他组件
flutter_kingmed_ui
可能还包含其他组件,如加载指示器、列表项、图标等。你可以查阅插件的文档或源代码来了解更多组件的使用方法。
6. 运行项目
完成上述步骤后,你可以运行你的 Flutter 项目,查看 flutter_kingmed_ui
组件的效果。
flutter run