Skip to content

Commit 6594d00

Browse files
author
罗国雄
committed
修复RunApp async问题
1 parent 9371ac1 commit 6594d00

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

lib/main.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import 'package:easy_market/utils/cache.dart';
1313
import 'package:easy_market/page/index.dart';
1414

1515
void main() async {
16+
// * https: //stackoverflow.com/questions/57689492/flutter-unhandled-exception-servicesbinding-defaultbinarymessenger-was-accesse
17+
// 异步获取SpUtil时,版本升级会有问题WidgetsFlutterBinding.ensureInitialized();
18+
WidgetsFlutterBinding.ensureInitialized();
1619
var sq = await SpUtil.getInstance();
1720
var token = sq.getString('token');
1821
var userName = sq.getString('userName');

lib/router/goodsDetail/index.dart

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ class _GoodsDetail extends State<GoodsDetail> {
6868
@override
6969
Widget build(BuildContext context) {
7070
return new Scaffold(
71-
appBar: buildAppBar('母亲节礼物-舒适安睡组合'),
71+
appBar: buildAppBar(
72+
initLoading ? 'loading...' : '${goodsMsgs["info"]['name']}'),
7273
body: Column(
7374
children: <Widget>[
7475
Expanded(
@@ -301,6 +302,9 @@ class _GoodsDetail extends State<GoodsDetail> {
301302
buildOneWidget(
302303
buildGoodsMsg(context),
303304
),
305+
buildOneWidget(
306+
buildSize(context),
307+
),
304308
],
305309
);
306310
}
@@ -450,4 +454,53 @@ class _GoodsDetail extends State<GoodsDetail> {
450454
),
451455
);
452456
}
457+
458+
// 选择规格
459+
Widget buildSize(BuildContext context) {
460+
return Container(
461+
height: Rem.getPxToRem(100),
462+
decoration: BoxDecoration(
463+
color: Colors.white,
464+
border: Border(
465+
top: BorderSide(
466+
color: Colors.grey,
467+
width: .5,
468+
),
469+
),
470+
),
471+
child: Row(
472+
children: <Widget>[
473+
Padding(
474+
padding: EdgeInsets.all(5),
475+
child: Text(
476+
'已选',
477+
style: TextStyle(color: Colors.grey),
478+
),
479+
),
480+
Expanded(
481+
child: Padding(
482+
padding: EdgeInsets.all(5),
483+
child: Row(
484+
children: <Widget>[
485+
Expanded(
486+
child: Text(
487+
'1.5m床垫*1+枕头*2、浅杏粉1.5m',
488+
overflow: TextOverflow.ellipsis,
489+
),
490+
),
491+
Text('x1'),
492+
],
493+
)),
494+
),
495+
Padding(
496+
padding: EdgeInsets.all(5),
497+
child: Icon(
498+
Icons.keyboard_arrow_right,
499+
color: Colors.grey,
500+
),
501+
),
502+
],
503+
),
504+
);
505+
}
453506
}

0 commit comments

Comments
 (0)