flutter_native_alert 1.2.0 copy "flutter_native_alert: ^1.2.0" to clipboard
flutter_native_alert: ^1.2.0 copied to clipboard

outdated

flutter_native_alert offers the ability to display Android and iOS native dialog and toast

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:flutter_native_alert/flutter_native_alert.dart';

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

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Flutter Native Alert'),
        ),
        body: Center(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [

              ElevatedButton.icon(
                  onPressed: () async {
                    bool ret = await FlutterNativeAlert.getInstance().showConfirm(
                      title: "Welcome to use",
                      message: "flutter_native_alert offers the ability to display Android and iOS native dialog and toast",
                      confirmButtonText: "OK",  // Optional, the text of the confirmation button, null means that the button is not displayed
                      cancelButtonText: "Cancel", // Optional, the text of the cancel button, null means that the button is not displayed
                    );

                    FlutterNativeAlert.getInstance().showToast("You clicked:" + (ret ? "OK":"Cancel"));
                  },
                  icon: Icon(Icons.privacy_tip_rounded),
                  label: Text("showConfirm")
              ),


              ElevatedButton.icon(
                  onPressed: (){
                    FlutterNativeAlert.getInstance().hideConfirm();
                  },
                  icon: Icon(Icons.privacy_tip_outlined),
                  label: Text("hideConfirm")
              ),

              ElevatedButton.icon(
                  onPressed: (){
                    FlutterNativeAlert.getInstance().showToast("I'm a Toast", duration: Duration(milliseconds: 1500));
                  },
                  icon: Icon(Icons.info),
                  label: Text("showToast")
              ),

            ],
          ),
        ),
      ),
    );
  }
}
4
likes
40
pub points
28%
popularity

Publisher

unverified uploader

flutter_native_alert offers the ability to display Android and iOS native dialog and toast

Homepage
Repository (GitHub)
View/report issues

License

BSD-2-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_native_alert