Skip to content

Commit

Permalink
migrate brn_loading to null safety (#32)
Browse files Browse the repository at this point in the history
* migrate brn_loading to null safety

* mv loading content to brnString constants
  • Loading branch information
laiiihz authored Jan 4, 2022
1 parent 974e0da commit 3ef1aa2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
24 changes: 11 additions & 13 deletions lib/src/components/loading/brn_loading.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @dart=2.9

import 'package:bruno/src/constants/brn_strings_constants.dart';
import 'package:flutter/material.dart';

/// 页面或者弹窗中间的圆形加载框,左侧是可定制的加载文案[content],比如:加载中、提交中等等
Expand Down Expand Up @@ -31,7 +30,7 @@ import 'package:flutter/material.dart';
class BrnPageLoading extends StatelessWidget {
final String content;

BrnPageLoading({this.content});
const BrnPageLoading({this.content = BrnStrings.loadingContent});

@override
Widget build(BuildContext context) {
Expand All @@ -40,9 +39,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,
Expand All @@ -58,7 +55,7 @@ class BrnPageLoading extends StatelessWidget {
Container(
margin: EdgeInsets.only(left: 8),
child: Text(
content ?? "加载中...",
content,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w600,
Expand All @@ -80,7 +77,8 @@ class BrnLoadingDialog extends Dialog {
/// 加载时的提示文案,默认为 `加载中...`
final String content;

BrnLoadingDialog({Key key, this.content = "加载中..."}) : super(key: key);
const BrnLoadingDialog({Key? key, this.content = BrnStrings.loadingContent})
: super(key: key);

@override
Widget build(BuildContext context) {
Expand All @@ -94,13 +92,13 @@ class BrnLoadingDialog extends Dialog {
/// * [barrierDismissible] 点击蒙层背景是否关闭弹窗,默认为 true,可关闭,详见 [showDialog] 中的 [barrierDismissible]
/// * [useRootNavigator] 把弹窗添加到 [context] 中的 rootNavigator 还是最近的 [Navigator],默认为 true,添加到
/// rootNavigator,详见 [showDialog] 中的 [useRootNavigator]
static void show(
static Future<T?> show<T>(
BuildContext context, {
String content,
String content = BrnStrings.loadingContent,
bool barrierDismissible = true,
bool useRootNavigator = true,
}) {
showDialog(
return showDialog<T>(
context: context,
barrierDismissible: barrierDismissible,
useRootNavigator: useRootNavigator,
Expand All @@ -112,7 +110,7 @@ class BrnLoadingDialog extends Dialog {
/// 关闭弹窗。
///
/// * [context] 上下文。
static void dismiss(BuildContext context) {
Navigator.pop(context);
static void dismiss<T extends Object?>(BuildContext context, [T? result]) {
Navigator.pop(context, result);
}
}
1 change: 1 addition & 0 deletions lib/src/constants/brn_strings_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ class BrnStrings {
static const String noData = "暂无数据";
static const String noSearchData = "暂无搜索结果";
static const String clickPageRetry = "请点击页面重试";
static const String loadingContent = '加载中...';
}

0 comments on commit 3ef1aa2

Please sign in to comment.