Skip to content

Commit

Permalink
Merge pull request #252 from Tencent/develop
Browse files Browse the repository at this point in the history
Drawer演示代码修复
  • Loading branch information
Luozf12345 authored Jul 24, 2024
2 parents 97056b2 + cbc5524 commit f6837f6
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Widget _buildBaseSimple(BuildContext context) {
/// 获取navBar尺寸
var renderBox = navBarkey.currentContext!.findRenderObject() as RenderBox;
var renderBox = navBarkey.currentContext?.findRenderObject() as RenderBox?;
return TDButton(
text: '基础抽屉',
isBlock: true,
Expand All @@ -12,7 +12,7 @@ Widget _buildBaseSimple(BuildContext context) {
TDDrawer(
context,
visible: true,
drawerTop: renderBox.size.height,
drawerTop: renderBox?.size.height,
items: List.generate(30, (index) => TDDrawerItem(title: '菜单${_nums[index]}')).toList(),
onItemClick: (index, item) {
print('drawer item被点击,index:$index,title:${item.title}');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Widget _buildBottomSimple(BuildContext context) {
/// 获取navBar尺寸
var renderBox = navBarkey.currentContext!.findRenderObject() as RenderBox;
var renderBox = navBarkey.currentContext?.findRenderObject() as RenderBox?;
return TDButton(
text: '带底部插槽样式',
isBlock: true,
Expand All @@ -12,7 +12,7 @@ Widget _buildBottomSimple(BuildContext context) {
TDDrawer(
context,
visible: true,
drawerTop: renderBox.size.height,
drawerTop: renderBox?.size.height,
title: '标题',
placement: TDDrawerPlacement.left,
items: List.generate(10, (index) => TDDrawerItem(title: '菜单${_nums[index]}')).toList(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Widget _buildIconSimple(BuildContext context) {
/// 获取navBar尺寸
var renderBox = navBarkey.currentContext!.findRenderObject() as RenderBox;
var renderBox = navBarkey.currentContext?.findRenderObject() as RenderBox?;
return TDButton(
text: '带图标抽屉',
isBlock: true,
Expand All @@ -12,7 +12,7 @@ Widget _buildIconSimple(BuildContext context) {
TDDrawer(
context,
visible: true,
drawerTop: renderBox.size.height,
drawerTop: renderBox?.size.height,
items: List.generate(30, (index) => TDDrawerItem(title: '菜单${_nums[index]}', icon: const Icon(TDIcons.app))).toList(),
);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Widget _buildTitleSimple(BuildContext context) {
/// 获取navBar尺寸
var renderBox = navBarkey.currentContext!.findRenderObject() as RenderBox;
var renderBox = navBarkey.currentContext?.findRenderObject() as RenderBox?;
return TDButton(
text: '带图标抽屉',
isBlock: true,
Expand All @@ -12,7 +12,7 @@ Widget _buildTitleSimple(BuildContext context) {
TDDrawer(
context,
visible: true,
drawerTop: renderBox.size.height,
drawerTop: renderBox?.size.height,
title: '标题',
placement: TDDrawerPlacement.left,
items: List.generate(10, (index) => TDDrawerItem(title: '菜单${_nums[index]}')).toList(),
Expand Down
16 changes: 8 additions & 8 deletions tdesign-component/example/lib/page/td_drawer_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class TDDrawerPage extends StatelessWidget {
@Demo(group: 'drawer')
Widget _buildBaseSimple(BuildContext context) {
/// 获取navBar尺寸
var renderBox = navBarkey.currentContext!.findRenderObject() as RenderBox;
var renderBox = navBarkey.currentContext?.findRenderObject() as RenderBox?;
return TDButton(
text: '基础抽屉',
isBlock: true,
Expand All @@ -100,7 +100,7 @@ Widget _buildBaseSimple(BuildContext context) {
TDDrawer(
context,
visible: true,
drawerTop: renderBox.size.height,
drawerTop: renderBox?.size.height,
items: List.generate(30, (index) => TDDrawerItem(title: '菜单${_nums[index]}')).toList(),
onItemClick: (index, item) {
print('drawer item被点击,index:$index,title:${item.title}');
Expand All @@ -113,7 +113,7 @@ Widget _buildBaseSimple(BuildContext context) {
@Demo(group: 'drawer')
Widget _buildIconSimple(BuildContext context) {
/// 获取navBar尺寸
var renderBox = navBarkey.currentContext!.findRenderObject() as RenderBox;
var renderBox = navBarkey.currentContext?.findRenderObject() as RenderBox?;
return TDButton(
text: '带图标抽屉',
isBlock: true,
Expand All @@ -124,7 +124,7 @@ Widget _buildIconSimple(BuildContext context) {
TDDrawer(
context,
visible: true,
drawerTop: renderBox.size.height,
drawerTop: renderBox?.size.height,
items: List.generate(30, (index) => TDDrawerItem(title: '菜单${_nums[index]}', icon: const Icon(TDIcons.app))).toList(),
);
},
Expand All @@ -134,7 +134,7 @@ Widget _buildIconSimple(BuildContext context) {
@Demo(group: 'drawer')
Widget _buildTitleSimple(BuildContext context) {
/// 获取navBar尺寸
var renderBox = navBarkey.currentContext!.findRenderObject() as RenderBox;
var renderBox = navBarkey.currentContext?.findRenderObject() as RenderBox?;
return TDButton(
text: '带图标抽屉',
isBlock: true,
Expand All @@ -145,7 +145,7 @@ Widget _buildTitleSimple(BuildContext context) {
TDDrawer(
context,
visible: true,
drawerTop: renderBox.size.height,
drawerTop: renderBox?.size.height,
title: '标题',
placement: TDDrawerPlacement.left,
items: List.generate(10, (index) => TDDrawerItem(title: '菜单${_nums[index]}')).toList(),
Expand All @@ -157,7 +157,7 @@ Widget _buildTitleSimple(BuildContext context) {
@Demo(group: 'drawer')
Widget _buildBottomSimple(BuildContext context) {
/// 获取navBar尺寸
var renderBox = navBarkey.currentContext!.findRenderObject() as RenderBox;
var renderBox = navBarkey.currentContext?.findRenderObject() as RenderBox?;
return TDButton(
text: '带底部插槽样式',
isBlock: true,
Expand All @@ -168,7 +168,7 @@ Widget _buildBottomSimple(BuildContext context) {
TDDrawer(
context,
visible: true,
drawerTop: renderBox.size.height,
drawerTop: renderBox?.size.height,
title: '标题',
placement: TDDrawerPlacement.left,
items: List.generate(10, (index) => TDDrawerItem(title: '菜单${_nums[index]}')).toList(),
Expand Down
32 changes: 16 additions & 16 deletions tdesign-site/src/drawer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import 'package:tdesign_flutter/tdesign_flutter.dart';
<pre slot="Dart" lang="javascript">
Widget _buildBaseSimple(BuildContext context) {
/// 获取navBar尺寸
var renderBox = navBarkey.currentContext!.findRenderObject() as RenderBox;
var renderBox = navBarkey.currentContext?.findRenderObject() as RenderBox?;
return TDButton(
text: '基础抽屉',
isBlock: true,
Expand All @@ -39,7 +39,7 @@ Widget _buildBaseSimple(BuildContext context) {
TDDrawer(
context,
visible: true,
drawerTop: renderBox.size.height,
drawerTop: renderBox?.size.height,
items: List.generate(30, (index) => TDDrawerItem(title: '菜单${_nums[index]}')).toList(),
onItemClick: (index, item) {
print('drawer item被点击,index:$index,title:${item.title}');
Expand All @@ -58,7 +58,7 @@ Widget _buildBaseSimple(BuildContext context) {
<pre slot="Dart" lang="javascript">
Widget _buildBaseSimple(BuildContext context) {
/// 获取navBar尺寸
var renderBox = navBarkey.currentContext!.findRenderObject() as RenderBox;
var renderBox = navBarkey.currentContext?.findRenderObject() as RenderBox?;
return TDButton(
text: '基础抽屉',
isBlock: true,
Expand All @@ -69,7 +69,7 @@ Widget _buildBaseSimple(BuildContext context) {
TDDrawer(
context,
visible: true,
drawerTop: renderBox.size.height,
drawerTop: renderBox?.size.height,
items: List.generate(30, (index) => TDDrawerItem(title: '菜单${_nums[index]}')).toList(),
onItemClick: (index, item) {
print('drawer item被点击,index:$index,title:${item.title}');
Expand All @@ -90,7 +90,7 @@ Widget _buildBaseSimple(BuildContext context) {
<pre slot="Dart" lang="javascript">
Widget _buildIconSimple(BuildContext context) {
/// 获取navBar尺寸
var renderBox = navBarkey.currentContext!.findRenderObject() as RenderBox;
var renderBox = navBarkey.currentContext?.findRenderObject() as RenderBox?;
return TDButton(
text: '带图标抽屉',
isBlock: true,
Expand All @@ -101,7 +101,7 @@ Widget _buildIconSimple(BuildContext context) {
TDDrawer(
context,
visible: true,
drawerTop: renderBox.size.height,
drawerTop: renderBox?.size.height,
items: List.generate(30, (index) => TDDrawerItem(title: '菜单${_nums[index]}', icon: const Icon(TDIcons.app))).toList(),
);
},
Expand All @@ -117,7 +117,7 @@ Widget _buildIconSimple(BuildContext context) {
<pre slot="Dart" lang="javascript">
Widget _buildIconSimple(BuildContext context) {
/// 获取navBar尺寸
var renderBox = navBarkey.currentContext!.findRenderObject() as RenderBox;
var renderBox = navBarkey.currentContext?.findRenderObject() as RenderBox?;
return TDButton(
text: '带图标抽屉',
isBlock: true,
Expand All @@ -128,7 +128,7 @@ Widget _buildIconSimple(BuildContext context) {
TDDrawer(
context,
visible: true,
drawerTop: renderBox.size.height,
drawerTop: renderBox?.size.height,
items: List.generate(30, (index) => TDDrawerItem(title: '菜单${_nums[index]}', icon: const Icon(TDIcons.app))).toList(),
);
},
Expand All @@ -147,7 +147,7 @@ Widget _buildIconSimple(BuildContext context) {
<pre slot="Dart" lang="javascript">
Widget _buildTitleSimple(BuildContext context) {
/// 获取navBar尺寸
var renderBox = navBarkey.currentContext!.findRenderObject() as RenderBox;
var renderBox = navBarkey.currentContext?.findRenderObject() as RenderBox?;
return TDButton(
text: '带图标抽屉',
isBlock: true,
Expand All @@ -158,7 +158,7 @@ Widget _buildTitleSimple(BuildContext context) {
TDDrawer(
context,
visible: true,
drawerTop: renderBox.size.height,
drawerTop: renderBox?.size.height,
title: '标题',
placement: TDDrawerPlacement.left,
items: List.generate(10, (index) => TDDrawerItem(title: '菜单${_nums[index]}')).toList(),
Expand All @@ -176,7 +176,7 @@ Widget _buildTitleSimple(BuildContext context) {
<pre slot="Dart" lang="javascript">
Widget _buildTitleSimple(BuildContext context) {
/// 获取navBar尺寸
var renderBox = navBarkey.currentContext!.findRenderObject() as RenderBox;
var renderBox = navBarkey.currentContext?.findRenderObject() as RenderBox?;
return TDButton(
text: '带图标抽屉',
isBlock: true,
Expand All @@ -187,7 +187,7 @@ Widget _buildTitleSimple(BuildContext context) {
TDDrawer(
context,
visible: true,
drawerTop: renderBox.size.height,
drawerTop: renderBox?.size.height,
title: '标题',
placement: TDDrawerPlacement.left,
items: List.generate(10, (index) => TDDrawerItem(title: '菜单${_nums[index]}')).toList(),
Expand All @@ -207,7 +207,7 @@ Widget _buildTitleSimple(BuildContext context) {
<pre slot="Dart" lang="javascript">
Widget _buildBottomSimple(BuildContext context) {
/// 获取navBar尺寸
var renderBox = navBarkey.currentContext!.findRenderObject() as RenderBox;
var renderBox = navBarkey.currentContext?.findRenderObject() as RenderBox?;
return TDButton(
text: '带底部插槽样式',
isBlock: true,
Expand All @@ -218,7 +218,7 @@ Widget _buildBottomSimple(BuildContext context) {
TDDrawer(
context,
visible: true,
drawerTop: renderBox.size.height,
drawerTop: renderBox?.size.height,
title: '标题',
placement: TDDrawerPlacement.left,
items: List.generate(10, (index) => TDDrawerItem(title: '菜单${_nums[index]}')).toList(),
Expand All @@ -242,7 +242,7 @@ Widget _buildBottomSimple(BuildContext context) {
<pre slot="Dart" lang="javascript">
Widget _buildBottomSimple(BuildContext context) {
/// 获取navBar尺寸
var renderBox = navBarkey.currentContext!.findRenderObject() as RenderBox;
var renderBox = navBarkey.currentContext?.findRenderObject() as RenderBox?;
return TDButton(
text: '带底部插槽样式',
isBlock: true,
Expand All @@ -253,7 +253,7 @@ Widget _buildBottomSimple(BuildContext context) {
TDDrawer(
context,
visible: true,
drawerTop: renderBox.size.height,
drawerTop: renderBox?.size.height,
title: '标题',
placement: TDDrawerPlacement.left,
items: List.generate(10, (index) => TDDrawerItem(title: '菜单${_nums[index]}')).toList(),
Expand Down

0 comments on commit f6837f6

Please sign in to comment.