当前位置: 首页 > news >正文

flutter 底部弹窗和中间弹窗

底部弹窗

import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';class GameHub extends StatefulWidget {GameHub({Key? key}) : super(key: key);@overrideState<StatefulWidget> createState() => GameHubState();
}class GameHubState extends State<GameHub> {@overridevoid initState() {super.initState();}@overridevoid dispose() {super.dispose();}mySetState(callBack) {if (mounted) {setState(() {callBack();});}}@overrideWidget build(BuildContext context) {return Container();}
}//显示游戏中心弹窗
showGameHubDialog(BuildContext context) {showModalBottomSheet(shape: const RoundedRectangleBorder(borderRadius: BorderRadius.only(topLeft: Radius.circular(16), topRight: Radius.circular(16))),isScrollControlled: true,enableDrag: false,context: context,builder: (context) => GameHub());
}

中间弹窗

import 'dart:convert';import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:base_utils/base_utils.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import '../../../router.dart';
import '../../common/Global.dart';
import '../../common/backgroundWall.dart';
import '../../http/api.dart';
import '../../http/net_callback.dart';
import '../../http/rxhttp.dart';
import '../../http/utils/NetUtils.dart';
import '../../http/utils/response.dart';
import '../../models/country_list_model.dart';///首页列表筛选地区弹窗
class FirstSelectCountry extends StatefulWidget {FirstSelectCountry({Key? key}) : super(key: key);@overrideState<StatefulWidget> createState() => FirstSelectCountryState();
}class FirstSelectCountryState extends State<FirstSelectCountry> {List<CountryItem> countryListData = [];String selectCountryShortCode = '';@overridevoid initState() {getCountryList();super.initState();}@overridevoid dispose() {super.dispose();}//国家地区列表getCountryList() {RxHttp<Response>()..init()..setBaseUrl(Api.BUSINESS_BASE_API)..setPath(Api.COUNTRY_INFO_LIST)..setCacheMode(CacheMode.FIRST_CACHE_THEN_REQUEST)..setJsonTransFrom((p0) => Response.fromJson(json.decoder.convert(p0)))..setParams({})..call(NetCallback(onNetFinish: (response) {if (response.code == 200) {CountryListModel countryListModel =CountryListModel.fromJson(response.data);handleCountryList(countryListModel);}},onCacheFinish: (response) {if (response.code == 200) {CountryListModel countryListModel =CountryListModel.fromJson(response.data);handleCountryList(countryListModel);}},onNetError: (errorCode, error) {}),server: Servers.businessServer);}handleCountryList(CountryListModel countryListModel) {if (countryListModel.countryList != null) {if (countryListModel.countryList!.isNotEmpty) {countryListData = countryListModel.countryList ?? [];mySetState(() {});}}}mySetState(callBack) {if (mounted) {setState(() {callBack();});}}@overrideWidget build(BuildContext context) {return Center(child: Container(decoration: BoxDecoration(color: Colors.white,borderRadius: BorderRadius.circular(8)),width: WidgetAdaptation.getWidth(305),height: WidgetAdaptation.getWidth(305),child: Wrap(spacing: 8,alignment: WrapAlignment.start,children: List.generate(countryListData.length, (index) {return RawChip(showCheckmark: false,label: Row(mainAxisSize: MainAxisSize.min,children: [BackgroundWall(avatarUrl: countryListData[index].country_icon ?? '',width: WidgetAdaptation.getWidth(17),height: WidgetAdaptation.getWidth(12),radius: 15,),Text(countryListData[index].country_name ?? ''),],),labelStyle: TextStyle(color: Color(selectCountryShortCode ==countryListData[index].country_short_code!?0xFF666666:0xFF0CE6E2), fontSize: 12),selected: countryListData[index].country_short_code ==selectCountryShortCode,selectedColor: Color(0xFF0CE6E2),onSelected: (v) {if (countryListData[index].country_short_code != null) {selectCountryShortCode =countryListData[index].country_short_code ?? '';mySetState(() {});}},side:BorderSide(width: 1,color: selectCountryShortCode ==countryListData[index].country_short_code!?Colors.blue:Colors.yellow),backgroundColor: Colors.white,shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16.0)),padding: const EdgeInsets.only(left: 3, right: 3, top: 5, bottom: 5));}).toList())),);}
}//首页地区筛选弹窗
showFirstSelectCountryDialog(context) {showDialog(context: context,builder: (context) {return FirstSelectCountry();});
}

相关文章:

  • 分布式搜索引擎02
  • at least 1 bean which qualifies as autowire candidate
  • Jenkins的几种安装方式以及邮件配置
  • 基于深度学习的yolov5入侵检测系统
  • 微服务1 springcloud学习笔记P1-P40
  • C++ 设计模式 Forward Declaration Pimpl
  • C++基础——STL初识
  • 力扣第 119 场双周赛(Java)
  • hook其他调试技巧
  • 重构第一章:引言
  • HTML中使用JavaScript实现一个简单的鼠标悬停特效。
  • Softmax回归
  • Redis持久化机制 RDB 和 AOF 的选择
  • Nmap脚本未来的发展趋势
  • 深入解析Java中的String:特点、重要方法及源码分析
  • 收藏网友的 源程序下载网
  • [分享]iOS开发-关于在xcode中引用文件夹右边出现问号的解决办法
  • 【划重点】MySQL技术内幕:InnoDB存储引擎
  • 【刷算法】求1+2+3+...+n
  • Android系统模拟器绘制实现概述
  • CSS 三角实现
  • HashMap ConcurrentHashMap
  • If…else
  • JavaWeb(学习笔记二)
  • java第三方包学习之lombok
  • Java方法详解
  • leetcode46 Permutation 排列组合
  • React-生命周期杂记
  • Sass Day-01
  • SegmentFault 社区上线小程序开发频道,助力小程序开发者生态
  • Vue官网教程学习过程中值得记录的一些事情
  • webpack+react项目初体验——记录我的webpack环境配置
  • 闭包--闭包作用之保存(一)
  • 从零开始的无人驾驶 1
  • 搭建gitbook 和 访问权限认证
  • 基于Mobx的多页面小程序的全局共享状态管理实践
  • 京东美团研发面经
  • 普通函数和构造函数的区别
  • 小程序开发之路(一)
  • 【运维趟坑回忆录 开篇】初入初创, 一脸懵
  • Java性能优化之JVM GC(垃圾回收机制)
  • ​​​​​​​sokit v1.3抓手机应用socket数据包: Socket是传输控制层协议,WebSocket是应用层协议。
  • ​Kaggle X光肺炎检测比赛第二名方案解析 | CVPR 2020 Workshop
  • ​软考-高级-系统架构设计师教程(清华第2版)【第1章-绪论-思维导图】​
  • (26)4.7 字符函数和字符串函数
  • (31)对象的克隆
  • (附源码)spring boot火车票售卖系统 毕业设计 211004
  • (论文阅读32/100)Flowing convnets for human pose estimation in videos
  • (转)LINQ之路
  • (转)拼包函数及网络封包的异常处理(含代码)
  • (轉貼) 2008 Altera 亞洲創新大賽 台灣學生成果傲視全球 [照片花絮] (SOC) (News)
  • ***利用Ms05002溢出找“肉鸡
  • .apk 成为历史!
  • .net core 微服务_.NET Core 3.0中用 Code-First 方式创建 gRPC 服务与客户端
  • .NET Micro Framework初体验(二)