smart_empty_state 0.1.1
smart_empty_state: ^0.1.1 copied to clipboard
A customizable and responsive empty state widget for Flutter apps.
import 'package:flutter/material.dart';
import 'package:smart_empty_state/smart_empty_state.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
useMaterial3: true,
),
home: const ExamplePage(),
);
}
}
class ExamplePage extends StatefulWidget {
const ExamplePage({super.key});
@override
State<ExamplePage> createState() => _ExamplePageState();
}
class _ExamplePageState extends State<ExamplePage> {
EmptyStateType selectedType = EmptyStateType.noData;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Smart Empty State')),
body: Column(
children: [
Padding(
padding: const EdgeInsets.all(16),
child: DropdownButtonFormField<EmptyStateType>(
initialValue: selectedType,
decoration: const InputDecoration(
labelText: 'Select State',
border: OutlineInputBorder(),
),
items: EmptyStateType.values.map((type) {
return DropdownMenuItem(value: type, child: Text(type.name));
}).toList(),
onChanged: (value) {
if (value == null) return;
setState(() {
selectedType = value;
});
},
),
),
Expanded(
child: SmartEmptyState(
type: selectedType,
onAction: () {
debugPrint('${selectedType.name} action pressed');
},
),
),
],
),
);
}
}