mercredi 23 juin 2021

How to remove drawer icon from appbar when the screen size is large and display it when the screen size is small | Flutter Web

I'm creating a flutter web app, i have some option in top of the page such as about, contact. My problem is i want to show these option in Appbar when displaying in large screen and for mobile i want to put it inside drawer. I implement it using the below code, but the drawer icon is always there in large and small screens. I don't want to show it in large screen.

import 'package:flutter/material.dart';

class HomePage extends StatelessWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Home"),
      ),
      drawer: LayoutBuilder(
        builder: (context, constraints) {
          if (constraints.maxWidth < 768) {
            return Drawer();
          } else {
            return SizedBox();
          }
        },
      ),
    );
  }
}

How can i Implement this in correct way




Aucun commentaire:

Enregistrer un commentaire