使用Flutter1.17

This commit is contained in:
toly
2020-05-07 16:55:18 +08:00
parent 43ad645504
commit 7d065f17e6
6 changed files with 71 additions and 27 deletions

Binary file not shown.

View File

@@ -31,9 +31,7 @@ class _HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin
@override
Widget build(BuildContext context) {
print('-------HomePage-------build-------');
var color = BlocProvider.of<HomeBloc>(context).state.homeColor;
var showBg = BlocProvider.of<GlobalBloc>(context).state.showBackGround;
return Scaffold(
appBar: TolyAppBar(
selectIndex: Cons.tabColors.indexOf(color.value),
@@ -42,7 +40,12 @@ class _HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin
),
body: Stack(
children: <Widget>[
if (showBg) Background(),
BlocBuilder<GlobalBloc, GlobalState>(builder: (_, state) {
if (state.showBackGround) {
return Background();
}
return Container();
}),
BlocBuilder<HomeBloc, HomeState>(builder: _buildContent)
],
),
@@ -69,11 +72,16 @@ class _HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin
Widget _buildHomeItem(
WidgetModel model,
) =>
FeedbackWidget(
duration: const Duration(milliseconds: 200),
onPressed: () => _toDetailPage(model),
child: HomeItemSupport.get(model,
BlocProvider.of<GlobalBloc>(context).state.itemStyleIndex));
BlocBuilder<GlobalBloc, GlobalState>(
condition: (p, c) => (p.itemStyleIndex != c.itemStyleIndex),
builder: (_, state) {
return
FeedbackWidget(
duration: const Duration(milliseconds: 200),
onPressed: () => _toDetailPage(model),
child: HomeItemSupport.get(model, state.itemStyleIndex));
},
);
_updateAppBarHeight() {
if (_ctrl.offset < _limitY * 4) {

View File

@@ -0,0 +1,38 @@
import 'package:flutter/material.dart';
/// create by 张风捷特烈 on 2020/5/3
/// contact me by email 1981462002@qq.com
/// 说明:
// {
// "widgetId": 202,
// "name": 'Builder的使用',
// "priority": 1,
// "subtitle": "【builder】 : 组件构造器 【WidgetBuilder】\n"
// "同一个类中使用`XXX.of(context)`获取某类状态对象方法会存在`上下文滞后`的错误使用Builder解决。",
// }
class BuilderDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
height: 200,
child: Scaffold(
appBar: AppBar(
title: Text('Builder'),
),
floatingActionButton: Builder(
builder: (ctx) => FloatingActionButton(
onPressed: () {
Scaffold.of(ctx)
.showSnackBar(SnackBar(content: Text('hello builder')));
},
child: Icon(Icons.add),
),
),
),
);
}
}

View File

@@ -57,6 +57,7 @@ export '../StatelessWidget/Visibility/node2_replacement.dart';
export '../StatelessWidget/ChoiceChip/node1_base.dart';
export '../StatelessWidget/FilterChip/node1_base.dart';
export '../StatelessWidget/Builder/node1_base.dart';
export '../StatelessWidget/ListTile/node1_base.dart';

View File

@@ -739,6 +739,10 @@ class WidgetsMap {
BuilderListView(),
SeparatedListView(),
];
case "Builder":
return [
BuilderDemo(),
];
case "GridView":
return [
CustomGridView(),

View File

@@ -7,21 +7,21 @@ packages:
name: archive
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.11"
version: "2.0.13"
args:
dependency: transitive
description:
name: args
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.5.2"
version: "1.6.0"
async:
dependency: transitive
description:
name: async
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.4.0"
version: "2.4.1"
bloc:
dependency: transitive
description:
@@ -35,21 +35,21 @@ packages:
name: boolean_selector
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.5"
version: "2.0.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.2"
version: "1.1.3"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.14.11"
version: "1.14.12"
convert:
dependency: transitive
description:
@@ -63,7 +63,7 @@ packages:
name: crypto
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.3"
version: "2.1.4"
cupertino_icons:
dependency: "direct main"
description:
@@ -113,7 +113,7 @@ packages:
name: image
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.4"
version: "2.1.12"
intl:
dependency: "direct main"
description:
@@ -149,13 +149,6 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.6.4"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.8.0+1"
petitparser:
dependency: transitive
description:
@@ -183,7 +176,7 @@ packages:
name: quiver
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.5"
version: "2.1.3"
rxdart:
dependency: transitive
description:
@@ -237,7 +230,7 @@ packages:
name: source_span
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.5.5"
version: "1.7.0"
sqflite:
dependency: "direct main"
description:
@@ -293,7 +286,7 @@ packages:
name: test_api
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.2.11"
version: "0.2.15"
toggle_rotate:
dependency: "direct main"
description:
@@ -349,7 +342,7 @@ packages:
name: xml
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.5.0"
version: "3.6.1"
sdks:
dart: ">=2.7.0 <3.0.0"
flutter: ">=1.12.13+hotfix.4 <2.0.0"