Expandable In Flutter

Expandable In Flutter :

Screenshot :

Expandable In Flutter :

main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:expandable/expandable.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    SystemChrome.setSystemUIOverlayStyle(
        SystemUiOverlayStyle(statusBarColor: Color(0XFF92B32C)));
    return MaterialApp(
        title: 'Flutter Tutorial',
        debugShowCheckedModeBanner: false,
        theme: ThemeData(
            primarySwatch: Colors.blue, accentColor: Color(0XFF92B32C)),
        home: ExpandablePage());
  }
}

class ExpandablePage extends StatefulWidget {
  @override
  createState() => _ExpandableState();
}

class _ExpandableState extends State<ExpandablePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Container(
            padding: EdgeInsets.all(10),
            child: ListView.builder(
                itemBuilder: (BuildContext context, int index) {
                  return Container(
                      padding: EdgeInsets.all(7),
                      width: MediaQuery.of(context).size.width,
                      child: Column(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: <Widget>[
                            ExpandableNotifier(
                                child: Container(
                                    child: ScrollOnExpand(
                                        child: Column(children: <Widget>[
                              Row(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceBetween,
                                  children: <Widget>[
                                    // builder because  child parent relationship
                                    Builder(builder: (context) {
                                      var controller =
                                          ExpandableController.of(context);
                                      return Container(
                                          width: MediaQuery.of(context)
                                                  .size
                                                  .width -
                                              40,
                                          child: InkWell(
                                              child: Row(
                                                  mainAxisAlignment:
                                                      MainAxisAlignment
                                                          .spaceBetween,
                                                  children: <Widget>[
                                                    Text("Flutter", // modify
                                                        style: TextStyle(
                                                            fontSize: 13,
                                                            color: Color(
                                                                0XFF5CBA47),
                                                            fontWeight:
                                                                FontWeight
                                                                    .w600)),
                                                    Icon(
                                                        controller.expanded
                                                            ? Icons
                                                                .keyboard_arrow_up
                                                            : Icons
                                                                .keyboard_arrow_down,
                                                        color:
                                                            Color(0XFF5CBA47))
                                                  ]),
                                              onTap: () {
                                                controller.toggle();
                                              }));
                                    })
                                  ]),
                              Expandable(
                                  collapsed: Container(),
                                  expanded: Column(children: <Widget>[
                                    Container(
                                        margin: EdgeInsets.only(right: 7),
                                        width:
                                            MediaQuery.of(context).size.width,
                                        height: 40,
                                        child: InkWell(
                                            child: Row(
                                                mainAxisAlignment:
                                                    MainAxisAlignment
                                                        .spaceBetween,
                                                children: <Widget>[
                                                  Text("World best website",
                                                      style: TextStyle(
                                                          fontSize: 13,
                                                          color:
                                                              Color(0XFF8589EF),
                                                          fontWeight:
                                                              FontWeight.w400)),
                                                  Icon(
                                                      Icons
                                                          .keyboard_arrow_right,
                                                      color: Color(0XFF8589EF))
                                                ]),
                                            onTap: () {}))
                                  ]))
                            ]))))
                          ]));
                },
                itemCount: 5)));
  }
}

pubspec.yaml

name: testing
description: A new Flutter application.
version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^0.1.2
  expandable:

dev_dependencies:
  flutter_test:
    sdk: flutter
  build_runner:

flutter:
  uses-material-design: true

The flutter tutorial  is a website that bring you the latest and amazing resources of code. All the languages codes are included in this website. The languages like flutter, android, java,kotlin etc.with the help of this languages any user can develop the beautiful application

For more information about Flutter. visit www.fluttertutorial.in