sileo 0.0.1
sileo: ^0.0.1 copied to clipboard
An opinionated, physics-based toast component for Flutter
Sileo
An opinionated, physics-based toast notification for Flutter.
Instead of stacking cards, Sileo shows a single liquid pill that springs in, morphs its width to fit its content, and grows a body out of itself, closer to a Dynamic Island than a toast stack. It's a Flutter port of the Sileo React library from Aaryan, with zero third-party dependencies.
Install #
dependencies:
sileo: ^0.0.1
Usage #
Mount one Toaster (via MaterialApp.builder), then call sileo.* from anywhere:
import 'package:sileo/sileo.dart';
MaterialApp(
builder: (context, child) => Toaster(theme: SileoTheme.system, child: child),
home: const HomePage(),
);
// ...anywhere:
sileo.success(const SileoOptions(title: 'Saved', description: 'Your changes are live.'));
sileo.error(const SileoOptions(title: 'Upload failed'));
sileo.warning(const SileoOptions(title: 'Low storage'));
sileo.info(const SileoOptions(title: 'Heads up'));
sileo.action(SileoOptions(
title: 'Update available',
button: SileoButton(title: 'Restart', onPressed: restart),
));
Drive a notification from a future — it shows loading, then morphs to the result:
sileo.future<User>(
saveProfile(form),
SileoFutureOptions(
loading: const SileoOptions(title: 'Saving…'),
success: (user) => SileoOptions(title: 'Saved', description: 'Welcome, ${user.name}.'),
error: (e) => SileoOptions(title: 'Failed', description: '$e'),
),
);
Dismiss or clear:
final id = sileo.info(const SileoOptions(title: 'Working…', duration: Duration.zero)); // persists
sileo.dismiss(id);
sileo.clear();
By default every call drives one notification that morphs in place. Pass an
explicit id to show several at once.
Customising #
Toaster:position,theme(light/dark/system),offset, defaultoptions.SileoOptions:title,description,icon,fill,roundness,duration(omit for 6s,Duration.zeroto persist),autopilot,button,styles.
See the API docs and example/ for a runnable demo of every feature.
License #
MIT.