返回顶部
首页 > 资讯 > 精选 >Flutter中怎么实现一个微信朋友圈功能
  • 911
分享到

Flutter中怎么实现一个微信朋友圈功能

2023-06-20 18:06:55 911人浏览 独家记忆
摘要

这篇文章给大家介绍Flutter中怎么实现一个微信朋友圈功能,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。import 'package:dio/dio.dart';import &

这篇文章给大家介绍Flutter中怎么实现一个微信朋友圈功能,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

import 'package:dio/dio.dart';import 'package:flutter/cupertino.dart';import 'package:flutter/material.dart';import 'package:nursery_school_gardener/view/main/dynamic/FriendView/FriendCell.dart';  class Dynamic extends StatefulWidget {  @override  _DynamicState createState() => _DynamicState();} class _DynamicState extends State<Dynamic> {  // 朋友圈信息数据  List<Result> cachesData;  @override  void initState() {    super.initState();  }   @override  Widget build(BuildContext context) {    return CustomScaffold(      contentWidget: Expanded(          flex: 1,          child: ListView.builder(// 朋友圈列表          itemBuilder: (BuildContext context, int index) {            // 每一条的朋友圈            return FriendCell(              result: cachesData[index],//将数据传入每一条列表中            );          },          itemCount: cachesData.length(),        ),      ),    );  } }

上面就是列表,下面是列表中的每一个样式

import 'dart:math';import 'package:flutter/material.dart';import 'package:nursery_school_gardener/util/ColorUtils.dart';  class FriendCell extends StatefulWidget {  // 上一页传过来的数据  Result result;  FriendCell({this.result, Key key}) : super(key: key);  @override  _FriendCellState createState() => _FriendCellState();} class _FriendCellState extends State<FriendCell> {  TextEditinGController editingController = new TextEditingController();  // 照片展示样式,1张、2|4张、或者其他  Widget makePictureCount(List<KgPhotosList> pics) {    if (pics.length == 1) {      return GestureDetector(        onTap: () {          //点击图片        },        child: Container(          margin: EdgeInsets.fromLTRB(0, 10, 50, 10),          width: MediaQuery.of(context).size.width - 164,          height: (MediaQuery.of(context).size.width - 164) / 2,          decoration: BoxDecoration(            image: DecorationImage(              image: AssetImage("images/hsf2.jpg"),//展示的图片根据需求展示不同类型              fit: BoxFit.cover,            ),            borderRadius: BorderRadius.circular(8),          ),        ),      );    } else if (pics.length == 4 || pics.length == 2) {      return Container(        margin: EdgeInsets.fromLTRB(0, 10, 0, 10),        child: Wrap(          spacing: 5,          runSpacing: 5,          alignment: WrapAlignment.start,          children: pics              .map(                (p) => GestureDetector(                  onTap: () {                    //点击图片                  },                  child: Container(                    width: (MediaQuery.of(context).size.width - 164) / 2.2,                    height: (MediaQuery.of(context).size.width - 164) / 2.2,                    decoration: BoxDecoration(                      image: DecorationImage(                        image: AssetImage("images/hsf2.jpg"),//展示的图片根据需求展示不同类型                        fit: BoxFit.cover,                      ),                      borderRadius: BorderRadius.circular(8),                    ),                  ),                ),              )              .toList(),        ),      );    } else if (pics.length == 3 || pics.length > 4) {            return Container(        margin: EdgeInsets.fromLTRB(0, 10, 0, 10),        child: Wrap(          spacing: 5,          runSpacing: 5,          alignment: WrapAlignment.start,          children: pics              .map(                (p) => GestureDetector(                  onTap: () {                    //点击图片                  },                  child: Container(                     width: (MediaQuery.of(context).size.width - 164) / 3,                     height: (MediaQuery.of(context).size.width - 164) / 3,                     decoration: BoxDecoration(                        image: DecorationImage(                           image:AssetImage("images/hsf2.jpg"),//展示的图片根据需求展示                         fit: BoxFit.cover,                       ),                        borderRadius: BorderRadius.circular(8),                     ),                  ),                ),              )              .toList(),        ),      );    } else {      return Container();    }  }   bool _isshow = true;   @override  Widget build(BuildContext context) {    bool deleteStatus = widget.result.addTeacher !=        Variable.share().loginData.result.userInfo.id;    return Container(      margin: new EdgeInsets.only(left: 12, right: 12, bottom: 12),      decoration: BoxDecoration(        borderRadius: BorderRadius.circular(10),        color: ColorUtils.WHITE,        boxShadow: [          BoxShadow(              color: ColorUtils.MAIN_BG, blurRadius: 10.0, spreadRadius: 1.0),        ],      ),      child: Stack(        children: [          Container(            child: Column(              children: <Widget>[                Flex(                  direction: Axis.horizontal,                  mainAxisAlignment: MainAxisAlignment.start,                  crossAxisAlignment: CrossAxisAlignment.start,                  children: <Widget>[                    //头像                    Container(                      width: 40,                      height: 40,                      margin: EdgeInsets.fromLTRB(15, 20, 15, 0),                      decoration: BoxDecoration(                        image: DecorationImage(                          image: AssetImage("images/hsf2.jpg"),//用户头像                          fit: BoxFit.cover,                        ),                        borderRadius: BorderRadius.circular(8),                      ),                    ),                    Expanded(                      child: Container(                        margin: EdgeInsets.fromLTRB(0, 20, 60, 0),                        child: Column(                          mainAxisAlignment: MainAxisAlignment.start,                          crossAxisAlignment: CrossAxisAlignment.start,                          children: <Widget>[                            //姓名                            Text(                              "姓名",                              style: TextStyle(                                  fontSize: 17,                                  color: Color(0XFF4D6CAB),                                  fontWeight: FontWeight.w500),                            ),                            SizedBox(                              height: 5,                            ),                            //动态内容                            Text(                              "内容",                              style: TextStyle(fontSize: 15),                            ),                            SizedBox(                              height: 5,                            ),                            //发表的图片,上一页面传递来的属性                            makePictureCount(widget.result.kgPhotosList),                          ],                        ),                      ),                    ),                  ],                ),Stack(     children: [             Flex(                 direction: Axis.horizontal,                 mainAxisAlignment: MainAxisAlignment.start,                 children: <Widget>[      //发布的时间                 Container(                     margin: EdgeInsets.only(left: 70, bottom: 5),                        child: Text(                            "时间",                            style: TextStyle(                                fontSize: 12, color: Color(0XFFB2B2B2)),                          ),                        ),        //删除朋友圈按钮 deleteStatus代表是否是自己的朋友圈,是可以删除,                Offstage(                          offstage: deleteStatus,                          child: GestureDetector(                            onTap: () {                              CustomDialog.show(context,                                  title: "动态删除",                                  message: "你确定要删除当前动态吗?", callBack: (flag) {                                if (flag) {                                  delteDynamic();                                }                              });                            },                            child: Container(                              margin: EdgeInsets.only(left: 5, bottom: 5),                              child: Text(                                "删除",                                style: TextStyle(                                    fontSize: 12,                                    color: ColorUtils.BLUE_NORMAL),                              ),                            ),                          ),                        ),    //管理员驳回按钮,看是否是管理员,可以通过和驳回朋友圈                   Offstage(                      offstage: ToolUtils.isContainsElement(                              Variable.share().USER_DYNAMIC_TYPE),                          child: GestureDetector(                            onTap: () {                              CustomDialog.show(                                context,                                title: "动态通过",                                message: "你确定要通过当前动态吗?",                                callBack: (flag) {                                  if (flag) {}                                },                              );                            },                            child: Container(                              margin: EdgeInsets.only(left: 5, bottom: 5),                              child: Text(                                "通过",                                style: TextStyle(                                    fontSize: 12,                                    color: ColorUtils.BLUE_NORMAL),                              ),                            ),                          ),                        ),                        //管理员驳回按钮,看是否是管理员,可以通过和驳回朋友圈                        Offstage(                          offstage: ToolUtils.isContainsElement(                              Variable.share().USER_DYNAMIC_TYPE),                          child: GestureDetector(                            onTap: () {                              CustomInputDialog.show(context,                                  title: "动态驳回",                                  message: "你确定要驳回当前动态吗?", callBack: (flag) {                                if (flag) {}                              });                            },                            child: Container(                              margin: EdgeInsets.only(left: 5, bottom: 5),                              child: Text(                                "驳回",                                style: TextStyle(                                    fontSize: 12,                                    color: ColorUtils.BLUE_NORMAL),                              ),                            ),                          ),                        ),                      ],                    ),                    Container(                      margin: EdgeInsets.only(right: 20),                      child: Row(                        mainAxisAlignment: MainAxisAlignment.end,                        children: <Widget>[                          Offstage(                            offstage: _isShow,                            child: AnimatedContainer(                              decoration: BoxDecoration(                                  borderRadius: BorderRadius.circular(5),                                  color: Color(0XFF4C5154)),                              duration: Duration(milliseconds: 100),                              width: 130,                              height: 30,                              child: Flex(                                direction: Axis.horizontal,                                children: <Widget>[                                  // 点赞模块                                  Expanded(                                    flex: 1,                                    child: Row(                                      mainAxisAlignment:                                          MainAxisAlignment.center,                                      children: <Widget>[                                        Icon(                                          Icons.favorite_border,                                          color: Colors.white,                                          size: 15,                                        ),                                        SizedBox(                                          width: 5,                                        ),                                        InkWell(                                          onTap: () {                                            // 点赞功能                                            setState(                                              () {                                                isShow();                                                addPraise();                                              },                                            );                                          },                                          child: Text(                                            "赞",                                            style: TextStyle(                                                color: Colors.white,                                                fontSize: 12),                                          ),                                        ),                                      ],                                    ),                                  ),                                  // 评论模块                                  Expanded(                                    flex: 1,                                    child: Row(                                      mainAxisAlignment:                                          MainAxisAlignment.center,                                      children: <Widget>[                                        Icon(                                          Icons.sms,                                          color: Colors.white,                                          size: 15,                                        ),                                        SizedBox(                                          width: 5,                                        ),                                        InkWell(                                          onTap: () {                                            setState(                                              () {                                                isShow();                                                aDDDiscuss("我是评论内容");                                              },                                            );                                          },                                          child: Text(                                            "评论",                                            style: TextStyle(                                                color: Colors.white,                                                fontSize: 12),                                          ),                                        ),                                      ],                                    ),                                  ),                                ],                              ),                            ),                          ),                          SizedBox(                            width: 10,                          ),                          InkWell(                            onTap: () {                              isShow();                            },                            child: Image.asset(                              "images/button.png",                              width: 22,                              height: 18,                            ),                          ),                        ],                      ),                    ),                  ],                ),                //评论模块                Offstage(                  offstage:                      widget.result.kgPraiseList.length == 0 ? true : false,                  child: Container(                    constraints: BoxConstraints(minWidth: double.infinity),                    margin: EdgeInsets.fromLTRB(70, 10, 15, 0),                    padding:                        EdgeInsets.only(top: 5, bottom: 5, left: 10, right: 10),                //因为点赞和评论是两个控件,所以当他俩存在的时候需要设置对应的圆角,保证UI                    decoration: BoxDecoration(                      borderRadius: BorderRadius.only(                          topLeft: Radius.circular(8),                          topRight: Radius.circular(8),                          bottomLeft: Radius.circular(                              widget.result.kgDiscussList.length == 0 ? 8 : 0),                          bottomRight: Radius.circular(                              widget.result.kgDiscussList.length == 0 ? 8 : 0)),                      color: Color(0XFFF3F3F5),                    ),                    child: Wrap(                        alignment: WrapAlignment.start,                        runSpacing: 5,                        spacing: 5,                        children: likeView(widget.result.kgPraiseList.length)),                  ),                ),                //点赞模块                Offstage(                  offstage:                      widget.result.kgDiscussList.length == 0 ? true : false,                  child: Container(                    constraints: BoxConstraints(minWidth: double.infinity),                    margin: EdgeInsets.fromLTRB(70, 0, 15, 0),                    padding:                        EdgeInsets.only(top: 5, bottom: 5, left: 10, right: 10),                    //因为点赞和评论是两个控件,所以当他俩存在的时候需要设置对应的圆角,保证UI                    decoration: BoxDecoration(                      borderRadius: BorderRadius.only(                          topLeft: Radius.circular(                              widget.result.kgPraiseList.length == 0 ? 8 : 0),                          topRight: Radius.circular(                              widget.result.kgPraiseList.length == 0 ? 8 : 0),                          bottomLeft: Radius.circular(8),                          bottomRight: Radius.circular(8)),                      color: Color(0XFFF3F3F5),                    ),                    child: Wrap(                        alignment: WrapAlignment.start,                        runSpacing: 5,                        spacing: 5,                        children: talkView(widget.result.kgDiscussList.length)),                  ),                ),                SizedBox(                  height: 10,                ),              ],            ),          ),          Offstage(            offstage: true,            child: Container(              margin: new EdgeInsets.only(                  left: MediaQuery.of(context).size.width - 50, top: 20),              child: Image.asset(                "images/ic_no_network.png",                width: 18,                height: 18,              ),            ),          ),        ],      ),    );  }   // 点赞和评论模块是否显示  void isShow() {    setState(() {      _isShow = !_isShow;    });  }     void delteDynamic() {    // 删除朋友圈  }     void addDiscuss(String discuss) {    // 发布评论  }     void addPraise() {    // 点赞  }      //点赞  List<Widget> likeView(int count) {    List<Widget> result = [];    // TODO: 这里不要删除,后期肯定会改回改版本,这个是展示所有点赞人的信息,因为项目需要这里注释了,只用下面的方式        // 点赞数量    if (widget.result.kgPraiseList.length > 0) {      result.add(        Container(          child: Row(            mainAxisSize: MainAxisSize.min,            children: <Widget>[              Icon(                Icons.favorite,                size: 16,                color: Color(0XFF4D6CAB),              ),              SizedBox(width: 5),              Container(                child: Text(                  "${widget.result.kgPraiseList.length}人赞过",                  style: TextStyle(                      color: Color(0XFF4D6CAB),                      fontSize: 14,                      fontWeight: FontWeight.w500),                ),              )            ],          ),        ),      );    }    return result;  }  //评论  List<Widget> talkView(int count) {    List<Widget> result = [];    for (int i = 0; i < count; i++) {      var discuss = widget.result.kgDiscussList[i];      var rng = new Random();      result.add(        Container(          child: Flex(            direction: Axis.vertical,            children: [              Container(                child: Row(                  children: <Widget>[                    Expanded(                      child: Text.rich(                        TextSpan(                            style: TextStyle(                              fontSize: 15,                              color: Color(0xFF333333),                            ),                            children: [                              TextSpan(                                text: ToolUtils.isEmptyOrNull(                                        discuss.discussPerson) +                                    ':',                                style: TextStyle(                                  fontWeight: FontWeight.w500,                                  color: Color(0XFF4D6CAB),                                ),                              ),                              TextSpan(                                  text: ToolUtils.isEmptyOrNull(                                      discuss.discuSSMessage)),                            ]),                        textAlign: TextAlign.start,                      ),                    ),                  ],                ),              ),              Container(),            ],          ),        ),      );    }    return result;  }}

关于Flutter中怎么实现一个微信朋友圈功能就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

--结束END--

本文标题: Flutter中怎么实现一个微信朋友圈功能

本文链接: https://lsjlt.com/news/299043.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
  • Flutter中怎么实现一个微信朋友圈功能
    这篇文章给大家介绍Flutter中怎么实现一个微信朋友圈功能,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。import 'package:dio/dio.dart';import &...
    99+
    2023-06-20
  • Flutter实现微信朋友圈功能
    本文实例为大家分享了Flutter实现微信朋友圈功能的具体代码,供大家参考,具体内容如下 今天给大家实现一下微信朋友圈的效果,下面是效果图 下面还是老样子,还是以代码的方式进行讲解...
    99+
    2024-04-02
  • Android中怎么实现微信朋友圈拍照上传功能
    Android中怎么实现微信朋友圈拍照上传功能,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。1. PhotoPicker的使用这是一个支持选择多张图片,点击图片放大,图片之间左...
    99+
    2023-05-30
  • android实现微信朋友圈发布动态功能
    本文实例为大家分享了android仿微信朋友圈发布动态功能的具体代码,供大家参考,具体内容如下 效果图: 本文概述 用到的开源库:仿照微信的图片选择器,Luban压缩图片,g...
    99+
    2022-06-06
    朋友圈 动态 Android
  • Android 实现微信,微博,微信朋友圈,QQ分享的功能
    Android 实现微信,微博,微信朋友圈,QQ分享的功能 一、去各自所在的开发者平台注册相应的Key值;引入相关jar包、权限等 二、ShareUtil工具类 impor...
    99+
    2022-06-06
    朋友圈 Android
  • Android开发中怎么实现一个朋友圈分享功能
    本篇文章为大家展示了Android开发中怎么实现一个朋友圈分享功能,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。先下载微信分享的jar包放在lib目录下,并且添加依赖,清单文件添加<activ...
    99+
    2023-05-31
    android roi
  • Android实现微信朋友圈发本地视频功能
    一、前言 前一篇文章已经详细介绍了如何使用Xposed框架编写第一个微信插件:摇骰子和猜拳作弊器 本文继续来介绍如何使用Xposed框架编写第二个微信插件,可以将本地小视频发布...
    99+
    2022-06-06
    朋友圈 Android
  • 微信小程序实现分享到朋友圈的功能
    分享朋友圈官方API:分享到朋友圈 1、分享到朋友圈接口设置事项  2、onShareTimeline()注意事项  3、分享朋友圈后,测试发现,没有数据请求。 用户在朋友圈打开分享的小程序页面,并不会真正打开小程序,而是进入一...
    99+
    2023-09-03
    微信小程序 小程序
  • 关于Android实现简单的微信朋友圈分享功能
    1.先下载微信分享的jar包放在lib目录下,并且添加依赖, 清单文件添加 <activity android:name=".wxapi.WXEntryA...
    99+
    2022-06-06
    朋友圈 Android
  • Android如何实现仿微信朋友圈全文、收起功能
    小编给大家分享一下Android如何实现仿微信朋友圈全文、收起功能,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!效果图具体代码(详细解释在代码注释中都有,这里就省...
    99+
    2023-05-30
    android
  • 微信小程序如何开发朋友圈功能
    这篇“微信小程序如何开发朋友圈功能”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“微信小程序如何开发朋友圈功能”文章吧。一、开...
    99+
    2023-06-26
  • Java如何实现微信公众平台朋友圈分享功能
    这篇文章将为大家详细讲解有关Java如何实现微信公众平台朋友圈分享功能,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。  其实分享的方法在微信官网有较为详细的文档说明,现就其中一些比较绕的步骤进行总结,有问...
    99+
    2023-05-30
    java
  • HTML5怎么实现分享到微信好友朋友圈QQ好友QQ空间微博二维码功能
    小编给大家分享一下HTML5怎么实现分享到微信好友朋友圈QQ好友QQ空间微博二维码功能,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!这是分享按钮:<button onclick="call()&q...
    99+
    2023-06-09
  • Android PraiseTextView实现朋友圈点赞功能
    PraiseTextView 说明 我是将朋友圈分成了几个独立模块单独自定义的View,通过回调完成交互,耦合性算是非常低了,主要有以下及部分: 1.评论布局(自定义TextV...
    99+
    2022-06-06
    朋友圈 Android
  • HTML5如何实现微信聊天界面、微信朋友圈
    这篇文章主要介绍HTML5如何实现微信聊天界面、微信朋友圈,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!html代码片段:<!--BEGIN 打赏--> <...
    99+
    2024-04-02
  • 使用uniapp实现发布朋友圈功能
    效果图如下图,样式可根据需求自行调整 template部分 <view class="flex flex-wrap"> <view v-for="(item...
    99+
    2024-04-02
  • android怎么实现多图文分享朋友圈功能
    小编给大家分享一下android怎么实现多图文分享朋友圈功能,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!很多安卓程序员都在寻找如何调用系统分享可以实现朋友圈多图...
    99+
    2023-05-30
    android
  • 3年前发的微信朋友圈怎么删?微信自带搜一搜清理功能,一键删除
    微信作为一款我们使用多年的社交工具,伴随着我们走过很多光阴,我们也通过微信朋友圈记录了一些我们曾经的故事,随着年龄的增长,我们也开始否定了我们之前的自己,那么3年前发的微信朋友圈内容怎么删?其实微信自带搜一...
    99+
    2024-04-02
  • Android仿微信朋友圈点击加号添加图片功能
    本文为大家分享了类似微信朋友圈,点击+号图片,可以加图片功能,供大家参考,具体内容如下 xml: <?xml version="1.0" encoding=...
    99+
    2022-06-06
    图片 朋友圈 Android
  • Android 仿微信朋友圈点赞和评论弹出框功能
    贡献/下载源码:https://github.com/mmlovesyy/PopupWindowDemo 本文简单模仿微信朋友圈的点赞和评论弹出框,布局等细节请忽略,着重实现弹...
    99+
    2022-06-06
    仿微信 朋友圈 Android
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作