基础组件库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mine_header.dart 1.2 KiB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:provider/provider.dart';
  4. import 'package:zhiying_base_widget/widgets/mine/mine_header/mine_header_bloc.dart';
  5. import 'package:zhiying_base_widget/widgets/mine/mine_header/mine_header_container.dart';
  6. import 'package:zhiying_base_widget/widgets/mine/mine_header/mine_header_static_container.dart';
  7. import 'package:zhiying_comm/util/base_bloc.dart';
  8. import 'package:zhiying_comm/zhiying_comm.dart';
  9. class MineHeader extends StatefulWidget {
  10. final Map<String, dynamic> data;
  11. const MineHeader(this.data, {Key key}) : super(key: key);
  12. @override
  13. _MineHeaderState createState() => _MineHeaderState();
  14. }
  15. class _MineHeaderState extends State<MineHeader> {
  16. UserInfoModel user;
  17. @override
  18. void didChangeDependencies() {
  19. user = Provider.of<UserInfoNotifier>(context).userInfo;
  20. super.didChangeDependencies();
  21. }
  22. @override
  23. Widget build(BuildContext context) {
  24. if (user == null || user.token == null || user.token == '') {
  25. // 未登录
  26. return MineStaticContainer(widget.data);
  27. }
  28. return BlocProvider<MineHeaderBloc>(
  29. bloc: MineHeaderBloc(),
  30. child: MineHeaderContainer(widget.data),
  31. );
  32. }
  33. }