Flutter Package : Slide Popup Dialog

Flutter Package : Slide Popup Dialog

Tambahkan Package Pada pubspec.yaml

slide_popup_dialog: ^0.0.2

main.dart

import 'package:flutter/material.dart';
import 'package:slide_popup_dialog/slide_popup_dialog.dart' as sliderPopup;

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

Tambahkan Stateless Widget

class App extends StatelessWidget {

  final String title = "Slidder Popup";
  final Color bgColor = Colors.blueAccent;
  final Color fgColor = Colors.white70;
  final IconData icLogo = Icons.star_border;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: title,
      home: Scaffold(
        backgroundColor: fgColor,
        appBar: new AppBar(
          backgroundColor: bgColor,
          leading: Icon(icLogo),
          title: Text(title),
        ),
        body: Home(),
      ),
    );
  }

}

Tambahkan Stateful Widget

class Home extends StatefulWidget {
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {

  void _showDialog() {
    sliderPopup.showSlideDialog(
      context: context,
      barrierColor: Colors.white.withOpacity(0.7),
      pillColor: Colors.white,
      backgroundColor: Colors.blueAccent,
      child: Icon(
        Icons.android,
        size: 100.0,
        color: Colors.white,
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Container(
       child: Center(
        child: RaisedButton(
          child: Text("Press to open dialog"),
          onPressed: _showDialog,
        ),
    ));
  }
}

Jalankan dengan F5

Flutter Developer