From 9a06d9f50e00028d4a1be2af57b42b851451a7c7 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Wed, 22 Dec 2021 14:37:55 +0800 Subject: [PATCH 1/2] migrate brn_loading to null safety --- lib/src/components/loading/brn_loading.dart | 26 ++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/src/components/loading/brn_loading.dart b/lib/src/components/loading/brn_loading.dart index 20691aee..6675e6c0 100644 --- a/lib/src/components/loading/brn_loading.dart +++ b/lib/src/components/loading/brn_loading.dart @@ -1,7 +1,8 @@ -// @dart=2.9 - import 'package:flutter/material.dart'; +/// 加载组件默认的加载文案 +const String kLoadingContent = '加载中...'; + /// 页面或者弹窗中间的圆形加载框,左侧是可定制的加载文案[content],比如:加载中、提交中等等 /// /// 该组件 并不支持获取 指定时刻的动画值 @@ -31,7 +32,7 @@ import 'package:flutter/material.dart'; class BrnPageLoading extends StatelessWidget { final String content; - BrnPageLoading({this.content}); + const BrnPageLoading({this.content = kLoadingContent}); @override Widget build(BuildContext context) { @@ -40,9 +41,7 @@ class BrnPageLoading extends StatelessWidget { height: 50, width: 130, decoration: BoxDecoration( - color: Color(0xff222222), - border: null, - borderRadius: BorderRadius.circular(5)), + color: Color(0xff222222), borderRadius: BorderRadius.circular(5)), child: Center( child: Row( mainAxisSize: MainAxisSize.min, @@ -58,7 +57,7 @@ class BrnPageLoading extends StatelessWidget { Container( margin: EdgeInsets.only(left: 8), child: Text( - content ?? "加载中...", + content, style: TextStyle( fontSize: 15, fontWeight: FontWeight.w600, @@ -80,7 +79,8 @@ class BrnLoadingDialog extends Dialog { /// 加载时的提示文案,默认为 `加载中...` final String content; - BrnLoadingDialog({Key key, this.content = "加载中..."}) : super(key: key); + const BrnLoadingDialog({Key? key, this.content = kLoadingContent}) + : super(key: key); @override Widget build(BuildContext context) { @@ -94,13 +94,13 @@ class BrnLoadingDialog extends Dialog { /// * [barrierDismissible] 点击蒙层背景是否关闭弹窗,默认为 true,可关闭,详见 [showDialog] 中的 [barrierDismissible] /// * [useRootNavigator] 把弹窗添加到 [context] 中的 rootNavigator 还是最近的 [Navigator],默认为 true,添加到 /// rootNavigator,详见 [showDialog] 中的 [useRootNavigator]。 - static void show( + static Future show( BuildContext context, { - String content, + String content = kLoadingContent, bool barrierDismissible = true, bool useRootNavigator = true, }) { - showDialog( + return showDialog( context: context, barrierDismissible: barrierDismissible, useRootNavigator: useRootNavigator, @@ -112,7 +112,7 @@ class BrnLoadingDialog extends Dialog { /// 关闭弹窗。 /// /// * [context] 上下文。 - static void dismiss(BuildContext context) { - Navigator.pop(context); + static void dismiss(BuildContext context, [T? result]) { + Navigator.pop(context, result); } } From 418327da024f122b1de0fead6da0d2cfbc932dd8 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Thu, 30 Dec 2021 16:02:47 +0800 Subject: [PATCH 2/2] mv loading content to brnString constants --- lib/src/components/loading/brn_loading.dart | 10 ++++------ lib/src/constants/brn_strings_constants.dart | 1 + 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/src/components/loading/brn_loading.dart b/lib/src/components/loading/brn_loading.dart index 6675e6c0..9e83fdd7 100644 --- a/lib/src/components/loading/brn_loading.dart +++ b/lib/src/components/loading/brn_loading.dart @@ -1,8 +1,6 @@ +import 'package:bruno/src/constants/brn_strings_constants.dart'; import 'package:flutter/material.dart'; -/// 加载组件默认的加载文案 -const String kLoadingContent = '加载中...'; - /// 页面或者弹窗中间的圆形加载框,左侧是可定制的加载文案[content],比如:加载中、提交中等等 /// /// 该组件 并不支持获取 指定时刻的动画值 @@ -32,7 +30,7 @@ const String kLoadingContent = '加载中...'; class BrnPageLoading extends StatelessWidget { final String content; - const BrnPageLoading({this.content = kLoadingContent}); + const BrnPageLoading({this.content = BrnStrings.loadingContent}); @override Widget build(BuildContext context) { @@ -79,7 +77,7 @@ class BrnLoadingDialog extends Dialog { /// 加载时的提示文案,默认为 `加载中...` final String content; - const BrnLoadingDialog({Key? key, this.content = kLoadingContent}) + const BrnLoadingDialog({Key? key, this.content = BrnStrings.loadingContent}) : super(key: key); @override @@ -96,7 +94,7 @@ class BrnLoadingDialog extends Dialog { /// rootNavigator,详见 [showDialog] 中的 [useRootNavigator]。 static Future show( BuildContext context, { - String content = kLoadingContent, + String content = BrnStrings.loadingContent, bool barrierDismissible = true, bool useRootNavigator = true, }) { diff --git a/lib/src/constants/brn_strings_constants.dart b/lib/src/constants/brn_strings_constants.dart index e075e8ec..5928c255 100644 --- a/lib/src/constants/brn_strings_constants.dart +++ b/lib/src/constants/brn_strings_constants.dart @@ -9,4 +9,5 @@ class BrnStrings { static const String noData = "暂无数据"; static const String noSearchData = "暂无搜索结果"; static const String clickPageRetry = "请点击页面重试"; + static const String loadingContent = '加载中...'; }