desktoasts 0.0.3 desktoasts: ^0.0.3 copied to clipboard
A plugin to show native toasts on Windows.
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:desktoasts/desktoasts.dart';
ToastService? service;
void main() {
service = new ToastService(
appName: 'desktoasts',
companyName: 'alexmercerind',
productName: 'desktoasts_example',
);
runApp(MyApp());
}
class MyApp extends StatefulWidget {
MyApp({Key? key}) : super(key: key);
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('desktoasts'),
centerTitle: true,
),
body: ListView(
padding: EdgeInsets.all(32.0),
children: [
Container(
height: 56.0,
child: Row(
children: [
Expanded(
child: Text('A toast with a subtitle.'),
),
ElevatedButton(onPressed: () {
Toast toast = new Toast(
type: ToastType.text02,
title: 'Hello World!',
subtitle: 'This toast contains a subtitle.',
);
service?.show(toast);
}, child: Text('Show'))
],
),
),
Container(
height: 56.0,
child: Row(
children: [
Expanded(
child: Text('A toast with an image.'),
),
ElevatedButton(onPressed: () {
Toast toast = new Toast(
type: ToastType.imageAndText02,
title: 'Hello World!',
subtitle: 'This toast contains an image.',
image: new File('C:/Windows/Web/Screen/img100.jpg')
);
service?.show(toast);
}, child: Text('Show'))
],
),
),
Container(
height: 56.0,
child: Row(
children: [
Expanded(
child: Text('A toast with actions.'),
),
ElevatedButton(onPressed: () {
Toast toast = new Toast(
type: ToastType.imageAndText02,
title: 'Hello World!',
subtitle: 'This toast contains actions in it.',
image: new File('C:/Windows/Web/Screen/img100.jpg'),
actions: [
'Accept',
'Decline',
]
);
service?.show(toast);
}, child: Text('Show'))
],
),
),
],
),
),
);
}
}