Asma'a نشر 25 أغسطس 2021 أرسل تقرير مشاركة نشر 25 أغسطس 2021 import 'package:flutter/material.dart'; import 'package:logindesign/modules/archivedtask.dart'; import 'package:logindesign/modules/donetask.dart'; import 'package:logindesign/modules/newtask.dart'; import 'package:sqflite/sqflite.dart'; class HomeLayot extends StatefulWidget { @override _HomeLayotState createState() => _HomeLayotState(); } class _HomeLayotState extends State<HomeLayot> { int currentIndex = 0; @override void initState() { super.initState(); } @override Widget build(BuildContext context) { List<Widget> screen = [ NewTasks(), DoneTasks(), ArchiveTasks(), ]; List<String> title = ['Tasks', 'Done Tasks', 'Archived Tasks']; var ScaffoldKey=GlobalKey<ScaffoldState>(); bool isBottomSheetShown=false; IconData fabIcon=Icons.edit; return Scaffold( key: ScaffoldKey, appBar: AppBar( title: Text(title[currentIndex]), ), body: screen[currentIndex], floatingActionButton: FloatingActionButton( child: Icon(fabIcon), onPressed: () { if(isBottomSheetShown){ Navigator.pop(context); isBottomSheetShown=false; setState(() { fabIcon=Icons.edit; }); } else{ ScaffoldKey.currentState?.showBottomSheet((context) { return Container( width: double.infinity, height: 120.0, color: Colors.amber, ); }); isBottomSheetShown=true; setState(() { fabIcon=Icons.add; }); }}, ), bottomNavigationBar: BottomNavigationBar( type: BottomNavigationBarType.fixed, //elevation:0 , showSelectedLabels: false, // backgroundColor: Colors.blue, currentIndex: currentIndex, onTap: (index) { setState(() { currentIndex = index; }); print(index); }, items: [ BottomNavigationBarItem( icon: Icon(Icons.menu), label: 'Tasks', ), BottomNavigationBarItem( icon: Icon(Icons.check_circle_outline), label: 'Done'), BottomNavigationBarItem( icon: Icon(Icons.archive_outlined), label: 'Archived'), ], ), ); } هذا الكود يجب ظهور Bottomsheet عند النقر علئ floatactionbutton ,وتتغير الأيقونة أيضًا لكنها لاتعمل ..لماذا 1 اقتباس رابط هذا التعليق شارك على الشبكات الإجتماعية More sharing options...
0 بلال زيادة نشر 27 أغسطس 2021 أرسل تقرير مشاركة نشر 27 أغسطس 2021 يبدو أنكِ لم تقومي بتعريف bottomsheet عند الضغط على الزر , فيمكنك وضع bottomsheet عند النقر على الزر بهذه الطريقة onPressed: () { showModalBottomSheet( context: context, builder: (context) { return Column( mainAxisSize: MainAxisSize.min, children: <Widget>[ ListTile( leading: new Icon(Icons.photo), title: new Text('Photo'), onTap: () { Navigator.pop(context); }, ), ListTile( leading: new Icon(Icons.music_note), title: new Text('Music'), onTap: () { Navigator.pop(context); }, ), ListTile( leading: new Icon(Icons.videocam), title: new Text('Video'), onTap: () { Navigator.pop(context); }, ), ListTile( leading: new Icon(Icons.share), title: new Text('Share'), onTap: () { Navigator.pop(context); }, ), ], ); }); } اقتباس رابط هذا التعليق شارك على الشبكات الإجتماعية More sharing options...
السؤال
Asma'a
هذا الكود يجب ظهور Bottomsheet عند النقر علئ floatactionbutton ,وتتغير الأيقونة أيضًا لكنها لاتعمل ..لماذا
رابط هذا التعليق
شارك على الشبكات الإجتماعية
1 جواب على هذا السؤال
Recommended Posts
انضم إلى النقاش
يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.