2

Though I am new to Flutter but now on my way of cloning an expandable and collapsible sidebar menu of a website i saw on the internet.

My attempt

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  final appTitle = 'Drawer Demo';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: appTitle,
      home: MyHomePage(title: appTitle),
    );
  }
}

class MyHomePage extends StatelessWidget {
  final String title;

  MyHomePage({Key key, this.title}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text(title)),
      body: Center(child: Text('Dashboard')),
      drawer: Drawer(
  child: ListView(
    children: <Widget>[
      Text('Dashboard'),
      ExpansionTile(
        title: Text("User management"),
        children: <Widget>[Text("Users"), 
        Text("Add user"),
        Text("Migrate users")
        ],
      ),
      ExpansionTile(
        title: Text("Remittance management"),
        children: <Widget>[Text("Add remittance"), 
        Text("Trace remittance"),
        Text("Remittance history"),
        Text("Search remittances"),
        Text("Online remittance requests")
        ],
      )
    ],
  ),
),
    );
  }
}

Code output

enter image description here

Required output

enter image description here

Dear members, any help ?

Thanks in advance.

CCC
  • 111
  • 5
  • 16
  • This solution is very good https://stackoverflow.com/questions/51706739/flutter-how-to-add-a-expandable-menu-item-inside-navigation-drawer – Abdelrahman Tareq Dec 08 '20 at 09:54

1 Answers1

0

Use ExpansionPanelList() to wrap your ExpansionPanels

Even though i wanted to implement ExpansionTitle widget but this alternative widget mentioned above made me search for it and found this GitHub link below implementing ExpansionPanelList widget in the way i wanted.

Here is the link: https://github.com/jaggerwang/flutter-in-practice

CCC
  • 111
  • 5
  • 16
bananagag
  • 161
  • 1
  • 1
  • 10