flutter_dialog 0.0.1 flutter_dialog: ^0.0.1 copied to clipboard
A new Flutter for dialog
import 'package:flutter/material.dart';
import 'package:flutter_dialog/flutter_dialog.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: FlutterDialog(
child: MyHomePage(title: 'Flutter Dialog Text'),
blueAmount: 2.0,
cancelable: true,
),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
FlutterDialog flutterDialog;
@override
void initState() {
flutterDialog = context.ancestorWidgetOfExactType(FlutterDialog);
super.initState();
}
void _showDialog() {
flutterDialog.showDialog(
title: Text(
"Fluttr Dialog test",
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w600,
fontSize: 22.0,
),
),
content: Text(
"Fluttr Dialog test",
style: TextStyle(
color: Colors.black,
fontSize: 16.0,
),
),
);
}
void _showCustomDialog() {
flutterDialog.showCustomDialog(
dialog: Row(
children: <Widget>[
Container(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
"Fluttr Dialog test",
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w600,
fontSize: 22.0,
),
),
Text(
"Fluttr Dialog test",
style: TextStyle(
color: Colors.black,
fontSize: 16.0,
),
),
],
),
),
],
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.display1,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _showCustomDialog,
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}