Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.7 kB
3
Indexable
Never
import 'dart:collection';

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Horizontal Menu')),
        body: const MenuWidget(),
      ),
    );
  }
}

class MenuWidget extends StatelessWidget {
  const MenuWidget({super.key});

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      child: Column(
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              menuItem(context, 'Edit'),
              menuItem(context, 'Save as Drafts'),
              menuItem(context, 'Mark as paid'),
              menuItem(context, 'Discard'),
            ],
          ),
        ],
      ),
    );
  }

  Widget menuItem(BuildContext context, String title) {
    return Container(
      decoration: const BoxDecoration(
        boxShadow: [
          BoxShadow(
            color: Colors.black12,
            blurRadius: 4.0,
            spreadRadius: 2.0,
            offset: Offset(2.0, 2.0),
          ),
        ],
      ),
      child: TextButton(
        onPressed: () {
          // handle item click
          print('$title clicked');
        },
        style: TextButton.styleFrom(
          backgroundColor: Colors.white,
          padding: const EdgeInsets.symmetric(horizontal: 8.0),
        ),
        child: Text(title, style: const TextStyle(color: Colors.black)),
      ),
    );
  }
}