Files
FlutterUnit/lib/views/widgets/ProxyWidget/MaterialBannerTheme/node1_base.dart
2020-07-22 15:50:04 +08:00

67 lines
2.2 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter/material.dart';
/// create by 张风捷特烈 on 2020/7/22
/// contact me by email 1981462002@qq.com
/// 说明: 327 MaterialBannerTheme 主要用于为后代的MaterialBanner组件统一设置默认属性,也可以通过该组件获取默认MaterialBanner的属性。
// {
// "widgetId": 327,
// "name": "MaterialBannerTheme基本使用",
// "priority": 1,
// "subtitle": "可指定MaterialBannerThemeData数据属性为【后代】的MaterialBanner组件设置默认样式如背景色、边距、文字样式等。也可以用MaterialBannerTheme.of获取MaterialBanner的主题数据。",
// }
class MaterialBannerThemeDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialBannerTheme(
data: MaterialBannerTheme.of(context).copyWith(
backgroundColor: Colors.purple,
padding: EdgeInsetsDirectional.only(start: 16.0, top: 2.0,end: 2),
leadingPadding:EdgeInsetsDirectional.only(end: 16.0) ,
contentTextStyle: TextStyle(color: Colors.white),
),
child: _MaterialBannerDemo(),
);
}
}
class _MaterialBannerDemo extends StatelessWidget {
final info =
'A banner displays an important, succinct message, and provides actions for users to address. '
'A user action is required for itto be dismissed.';
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[MaterialBanner(
content: Text(info),
leading: Icon(Icons.warning, color: Colors.yellow),
actions: <Widget>[
RaisedButton(
color: Colors.white,
onPressed: () {},
child: Text(
'I KNOW',
style: TextStyle(
color: Colors.purple,
fontWeight: FontWeight.bold,
fontSize: 14),
),
),
RaisedButton(
color: Colors.white,
onPressed: () {},
child: Text(
'I IGNORE',
style: TextStyle(
color: Colors.purple,
fontWeight: FontWeight.bold,
fontSize: 14),
),
),
],
)],
);
}
}