bottom_popup_menu_button 0.0.1 copy "bottom_popup_menu_button: ^0.0.1" to clipboard
bottom_popup_menu_button: ^0.0.1 copied to clipboard

A new flutter plugin project.

example/lib/main.dart

import 'dart:async';

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

void main() {
  runApp(MyApp());
}

class UserTag {
  final String name;

  UserTag({this.name});
}

class UserTile extends StatelessWidget {
  final UserTag tag;

  const UserTile({Key key, this.tag}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return ListTile(
      contentPadding: EdgeInsets.zero,
      title: Text(tag.name),
      trailing: CircleAvatar(
        child: ClipRRect(
          borderRadius: BorderRadius.circular(300),
          child: Image.network(
            'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTFiyH2SE52qzOFfDJ8GDzv8mgmOEkRb9RdyA&usqp=CAU',
            fit: BoxFit.cover,
          ),
        ),
      ),
    );
  }
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      platformVersion = await BottomPopupMenuButton.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  List<BottomPopupMenuEntry<UserTag>> userTagsList(List<UserTag> tags) {
    return List.generate(
        tags.length,
        (index) => BottomPopupMenuItem(
            value: tags[index],
            child: UserTile(
              tag: tags[index],
            )));
  }

  List<UserTag> tags = [
    UserTag(name: 'alyona'),
    UserTag(name: 'ismail'),
    UserTag(name: 'alex'),
    UserTag(name: 'raha'),
    UserTag(name: 'alyona'),
    UserTag(name: 'ismail'),
    UserTag(name: 'alex'),
  ];

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
            child: BottomPopupMenuButton(
                position: RelativeRect.fromLTRB(0, 0, 150, 0),
                itemBuilder: (context) => userTagsList(tags))),
      ),
    );
  }
}
0
likes
110
pub points
19%
popularity

Publisher

unverified uploader

A new flutter plugin project.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on bottom_popup_menu_button