tolyui_feedback 0.3.6+7 copy "tolyui_feedback: ^0.3.6+7" to clipboard
tolyui_feedback: ^0.3.6+7 copied to clipboard

A feedback ui package for toly ui. Contains message、popover、tooltip etc...

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:tolyui_feedback/tolyui_feedback.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'TolyPopPicker Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const PopPickerDemo(),
    );
  }
}

class PopPickerDemo extends StatefulWidget {
  const PopPickerDemo({super.key});

  @override
  State<PopPickerDemo> createState() => _PopPickerDemoState();
}

class _PopPickerDemoState extends State<PopPickerDemo> {
  String _selectedAction = '未选择';

  void _showBasicPicker() {
    showTolyPopPicker(
      context: context,
      tasks: [
        TolyPopItem(
          info: '拍照',
          task: () {
            setState(() => _selectedAction = '拍照');
          },
        ),
        TolyPopItem(
          info: '从相册选择',
          task: () {
            setState(() => _selectedAction = '从相册选择');
          },
        ),
      ],
    );
  }

  void _showPickerWithTitle() {
    showTolyPopPicker(
      context: context,
      title: const Text('选择操作', style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
      tasks: [
        TolyPopItem(
          info: '编辑',
          task: () {
            setState(() => _selectedAction = '编辑');
          },
        ),
        TolyPopItem(
          info: '删除',
          task: () {
            setState(() => _selectedAction = '删除');
          },
        ),
        TolyPopItem(
          info: '分享',
          task: () {
            setState(() => _selectedAction = '分享');
          },
        ),
      ],
    );
  }

  void _showPickerWithMessage() {
    showTolyPopPicker(
      context: context,
      message: '请选择您要执行的操作',
      cancelText: '关闭',
      tasks: [
        TolyPopItem(
          info: '保存到本地',
          task: () {
            setState(() => _selectedAction = '保存到本地');
          },
        ),
        TolyPopItem(
          info: '发送给朋友',
          task: () {
            setState(() => _selectedAction = '发送给朋友');
          },
        ),
        TolyPopItem(
          info: '复制链接',
          task: () {
            setState(() => _selectedAction = '复制链接');
          },
        ),
      ],
    );
  }

  void _showPickerWithCustomRadius() {
    showTolyPopPicker(
      context: context,
      title: const Text('自定义圆角', style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
      borderRadius: 20.0,
      tasks: [
        TolyPopItem(
          info: '大圆角效果',
          task: () {
            setState(() => _selectedAction = '大圆角效果');
          },
        ),
        TolyPopItem(
          info: '圆角半径 20px',
          task: () {
            setState(() => _selectedAction = '圆角半径 20px');
          },
        ),
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: const Text('TolyPopPicker 示例'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            Card(
              child: Padding(
                padding: const EdgeInsets.all(16.0),
                child: Column(
                  children: [
                    const Text('当前选择:', style: TextStyle(fontSize: 16)),
                    const SizedBox(height: 8),
                    Text(
                      _selectedAction,
                      style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: Colors.blue),
                    ),
                  ],
                ),
              ),
            ),
            const SizedBox(height: 24),
            ElevatedButton(
              onPressed: _showBasicPicker,
              child: const Text('基础选择器'),
            ),
            const SizedBox(height: 12),
            ElevatedButton(
              onPressed: _showPickerWithTitle,
              child: const Text('带标题的选择器'),
            ),
            const SizedBox(height: 12),
            ElevatedButton(
              onPressed: _showPickerWithMessage,
              child: const Text('带消息的选择器'),
            ),
            const SizedBox(height: 12),
            ElevatedButton(
              onPressed: _showPickerWithCustomRadius,
              child: const Text('自定义圆角选择器'),
            ),
          ],
        ),
      ),
    );
  }
}
3
likes
140
points
90
downloads

Publisher

verified publishertoly1994.com

Weekly Downloads

A feedback ui package for toly ui. Contains message、popover、tooltip etc...

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, tolyui_message

More

Packages that depend on tolyui_feedback