package_dialog_demo 1.0.1 copy "package_dialog_demo: ^1.0.1" to clipboard
package_dialog_demo: ^1.0.1 copied to clipboard

A new Flutter package, A project, A new Flutter package project, A new Flutter package project, A new Flutter package project, A new Flutter package project, A new Flutter package project, A new Flut [...]

example/main.dart

import 'package:flutter/material.dart';
import 'package:package_dialog_demo/package_dialog_demo.dart' as DialogDemo;

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

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: DialogPage(),
    );
  }
}

class DialogPage extends StatefulWidget {
  @override
  _DialogPageState createState() => _DialogPageState();
}

class _DialogPageState extends State<DialogPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          'Dialog组件',
          style: TextStyle(color: Colors.white, fontSize: 25),
        ),
      ),
      body: Container(
        alignment: Alignment.center,
        child: Column(
          children: [
            SizedBox(height: 10),
            TextButton(
                onPressed: () {
                  showDialog(
                      context: context,
                      builder: (BuildContext context) {
                        return DialogDemo.CustomDialog(
                          title: '标题',
                          content: '这是一个描述描述',
                          dialogType: DialogDemo.DialogType.upgrade,
                          cancelCallBack: () {
                            print('点击了取消按钮');
                          },
                          confirmCallBack: () {
                            print('点击了确认按钮');
                          },
                        );
                      });
                },
                child: Text('自定义弹窗升级弹窗')),
            SizedBox(height: 10),
            TextButton(
                onPressed: () {
                  showDialog(
                      context: context,
                      builder: (BuildContext context) {
                        return DialogDemo.CustomDialog(
                          title: '标题',
                          content: '这是一个描述描述',
                          dialogType: DialogDemo.DialogType.alert,
                        );
                      });
                },
                child: Text('自定义alert')),
          ],
        ),
      ),
    );
  }
}
0
likes
100
pub points
0%
popularity

Publisher

unverified uploader

A new Flutter package, A project, A new Flutter package project, A new Flutter package project, A new Flutter package project, A new Flutter package project, A new Flutter package project, A new Flutter package project, A new Flutter package project,.

Homepage

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on package_dialog_demo