You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			52 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Dart
		
	
			
		
		
	
	
			52 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Dart
		
	
import 'package:flutter/material.dart';
 | 
						|
 | 
						|
import 'package:fluffychat/config/app_config.dart';
 | 
						|
 | 
						|
class M2PopupMenuButton<T> extends StatelessWidget {
 | 
						|
  final List<PopupMenuEntry<T>> Function(BuildContext) itemBuilder;
 | 
						|
  final T? initialValue;
 | 
						|
  final void Function(T)? onSelected;
 | 
						|
  final void Function()? onCanceled;
 | 
						|
  final Widget? icon;
 | 
						|
  final Color? color;
 | 
						|
  final Widget? child;
 | 
						|
 | 
						|
  const M2PopupMenuButton({
 | 
						|
    Key? key,
 | 
						|
    required this.itemBuilder,
 | 
						|
    this.initialValue,
 | 
						|
    this.onSelected,
 | 
						|
    this.onCanceled,
 | 
						|
    this.icon,
 | 
						|
    this.color,
 | 
						|
    this.child,
 | 
						|
  }) : super(key: key);
 | 
						|
 | 
						|
  @override
 | 
						|
  Widget build(BuildContext context) {
 | 
						|
    final theme = Theme.of(context);
 | 
						|
    return Theme(
 | 
						|
      data: theme.copyWith(
 | 
						|
        useMaterial3: false,
 | 
						|
        popupMenuTheme: PopupMenuThemeData(
 | 
						|
          color: theme.colorScheme.surface,
 | 
						|
          shape: RoundedRectangleBorder(
 | 
						|
            borderRadius: BorderRadius.circular(AppConfig.borderRadius),
 | 
						|
          ),
 | 
						|
          elevation: theme.appBarTheme.scrolledUnderElevation,
 | 
						|
          textStyle: theme.textTheme.bodyText1,
 | 
						|
        ),
 | 
						|
      ),
 | 
						|
      child: PopupMenuButton<T>(
 | 
						|
        itemBuilder: itemBuilder,
 | 
						|
        initialValue: initialValue,
 | 
						|
        onSelected: onSelected,
 | 
						|
        onCanceled: onCanceled,
 | 
						|
        icon: icon,
 | 
						|
        color: color,
 | 
						|
        child: child,
 | 
						|
      ),
 | 
						|
    );
 | 
						|
  }
 | 
						|
}
 |