more_widgets 4.0.1
more_widgets: ^4.0.1 copied to clipboard
This package will offer you new useful widgets to use in your apps.
example/lib/main.dart
// A single-page demo app that showcases widgets from the local `more_widgets` package.
import 'package:flutter/material.dart';
import 'package:more_widgets/more_widgets.dart';
void main() {
runApp(const ExampleApp());
}
class ExampleApp extends StatelessWidget {
const ExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'more_widgets - Example',
theme: ThemeData(colorScheme: ColorScheme.fromSeed(seedColor: Colors.indigo)),
home: const ExampleHomePage(),
);
}
}
class ExampleHomePage extends StatelessWidget {
const ExampleHomePage({super.key});
void _showSnack(BuildContext context, String message) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(message)));
}
@override
Widget build(BuildContext context) {
return GradientBackground(
child: Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(title: const Text('more_widgets - Example')),
body: SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SizedBox(height: 8),
// GradientButton demo
const Text('GradientButton', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
const SizedBox(height: 8),
GradientButton(
buttonText: 'Press me',
onPressed: () => _showSnack(context, 'GradientButton pressed'),
),
const SizedBox(height: 24),
// RoundedContainer demo
const Text('RoundedContainer', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
const SizedBox(height: 8),
RoundedContainer(
color: Colors.white70,
child: Padding(
padding: const EdgeInsets.all(12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text('This is a rounded container.'),
const SizedBox(height: 8),
TextButton(
onPressed: () => _showSnack(context, 'Inner button in RoundedContainer pressed'),
child: const Text('Inner action'),
)
],
),
),
),
const SizedBox(height: 24),
// LoadingWidget demo
const Text('LoadingWidget', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
const SizedBox(height: 8),
Container(
padding: const EdgeInsets.all(12),
color: Colors.white70,
child: const LoadingWidget(),
),
const SizedBox(height: 24),
// BottomActionSheet demo
const Text('BottomActionSheet', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
const SizedBox(height: 8),
ElevatedButton(
onPressed: () {
BottomActionSheet.show(
context: context,
actions: [
BottomActionSheetAction(title: 'Action 1', onPressed: () => _showSnack(context, 'Action 1')),
BottomActionSheetAction(title: 'Delete', onPressed: () => _showSnack(context, 'Delete'), isDestructiveAction: true),
],
title: 'Choose an action',
message: 'Select one of the available actions',
cancelButton: BottomActionSheetAction(title: 'Cancel', onPressed: () => _showSnack(context, 'Cancel')),
);
},
child: const Text('Show BottomActionSheet'),
),
const SizedBox(height: 24),
// Dialogs demo
const Text('Dialogs', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
const SizedBox(height: 8),
Wrap(
spacing: 8,
runSpacing: 8,
children: [
ElevatedButton(
onPressed: () {
Dialogs.infoDialog(
context: context,
title: 'Info',
message: 'This is an informational dialog. This is an informational dialog. This is an informational dialog. This is an informational dialog. This is an informational dialog. This is an informational dialog. This is an informational dialog. This is an informational dialog. This is an informational dialog. This is an informational dialog. This is an informational dialog. This is an informational dialog. This is an informational dialog. This is an informational dialog. This is an informational dialog. This is an informational dialog. This is an informational dialog. This is an informational dialog. This is an informational dialog. This is an informational dialog. ',
onPressed: () => _showSnack(context, 'Info OK'),
);
},
child: const Text('InfoDialog'),
),
ElevatedButton(
onPressed: () {
Dialogs.dialogWithOptions(
context: context,
title: 'Confirm',
message: 'Do you want to continue?',
onPressedLeftButton: () => _showSnack(context, 'Left pressed'),
onPressedRightButton: () => _showSnack(context, 'Right pressed'),
);
},
child: const Text('DialogWithOptions'),
),
ElevatedButton(
onPressed: () {
final controller = TextEditingController();
Dialogs.textInputDialog(
context: context,
title: 'Input',
message: 'Enter some text',
controller: controller,
onChanged: (value) => _showSnack(context, 'Changed: $value'),
onPressedLeftButton: () => _showSnack(context, 'Left in Input'),
onPressedRightButton: () => _showSnack(context, 'Right in Input'),
);
},
child: const Text('TextInputDialog'),
),
ElevatedButton(
onPressed: () {
Dialogs.loadingDialog(context: context, title: 'Loading');
final navigator = Navigator.of(context);
Future.delayed(const Duration(seconds: 2), () => navigator.pop());
},
child: const Text('LoadingDialog'),
),
],
),
const SizedBox(height: 40),
],
),
),
),
);
}
}