import 'package:flutter/material.dart'; class SharePopup extends StatelessWidget { List nameItems = [ '微信', '朋友圈', 'QQ', 'QQ空间', '微博', 'FaceBook', '邮件', '链接' ]; List urlItems = [ 'icon_wechat.png', 'icon_wechat_moments.png', 'icon_qq.png', 'icon_qzone.png', 'icon_sina.png', 'icon_facebook.png', 'icon_email.png', 'icon_copylink.png' ]; SharePopup({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return _shareWidget(context); // Scaffold( // appBar: AppBar( // title: const Text("分享页面"), // ), // body: _shareWidget(context) /* Center( child: Builder(builder: (BuildContext context) { return ElevatedButton( onPressed: () { showModalBottomSheet( context: context, builder: (BuildContext context) { return _shareWidget(context); }); }, child: const Text("我要分享"), // color: Colors.blue ); }), ) */ // ); } Widget _shareWidget(BuildContext context) { return SizedBox( height: 250.0, child: Column( children: [ Padding( padding: const EdgeInsets.fromLTRB(0.0, 10.0, 0.0, 0.0), child: SizedBox( height: 190.0, child: GridView.builder( gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 4, mainAxisSpacing: 5.0, childAspectRatio: 1.0), itemBuilder: (BuildContext context, int index) { return Column( children: [ Padding( padding: const EdgeInsets.fromLTRB(0.0, 6.0, 0.0, 6.0), child: Image.asset( 'images/${urlItems[index]}', width: 50.0, height: 50.0, fit: BoxFit.fill, )), Text(nameItems[index]) ], ); }, itemCount: nameItems.length, ), ), ), Container( height: 0.5, color: Colors.blueGrey, ), const Center( child: Padding( padding: EdgeInsets.fromLTRB(0.0, 8.0, 0.0, 8.0), child: Text( '取 消', style: TextStyle(fontSize: 18.0, color: Colors.blueGrey), )), ) ], ), ); } }