اذهب إلى المحتوى
  • 0

عدم ظهور bottomsheet في فلاتر

Asma'a

السؤال

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 ,وتتغير الأيقونة أيضًا لكنها لاتعمل ..لماذا

رابط هذا التعليق
شارك على الشبكات الإجتماعية

Recommended Posts

  • 0

يبدو أنكِ لم تقومي بتعريف 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);
    		},
    	),
    ],
    );
  });
}

 

رابط هذا التعليق
شارك على الشبكات الإجتماعية

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...