basic_widgets 1.0.0+1 basic_widgets: ^1.0.0+1 copied to clipboard
Basic Widgets library
import 'package:basic_widgets/basic_widgets.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MainApp());
}
class MainApp extends StatelessWidget {
const MainApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: TestView(),
);
}
}
class TestView extends StatelessWidget {
const TestView({
super.key,
});
@override
Widget build(BuildContext context) {
return const Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
DialogButton(),
SheetButton(),
],
),
));
}
}
@immutable
final class SheetButton extends StatelessWidget {
const SheetButton({
super.key,
});
@override
Widget build(BuildContext context) {
return BasicButton.outlined(
child: const Text('Show Sheet'),
onPressed: () {
showBasicModalSheet(
context: context,
enableDrag: false,
isDismissible: false,
constraints: const BoxConstraints.expand(
width: double.infinity,
height: 340 + 28,
),
builder: (context) => BasicSheet(
type: BasicSheetType.withOutCloseButton,
child: SafeArea(
child: SizedBox(
height: 340 + 28,
child: PopScope(
canPop: false,
child: Column(
children: [
Expanded(
child: BasicCard(
color: Theme.of(context)
.colorScheme
.primary
.withOpacity(.12),
margin: const EdgeInsets.all(24),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
BasicCard(
width: 44,
height: 44,
color: Theme.of(context).colorScheme.primary,
child: Icon(
FontAwesomeIcons.clockRotateLeft,
color:
Theme.of(context).colorScheme.onPrimary,
),
),
Text(
'Update required',
style: Theme.of(context).textTheme.titleLarge,
),
Text(
'Sorry for any inconvenience. We have recently made some update and bug fixes to improve your app experience.',
style: Theme.of(context).textTheme.bodyMedium,
textAlign: TextAlign.center,
),
],
),
),
),
BasicButton.primary(
child: const Text(
'Update',
),
onPressed: () {
Navigator.of(context).pop();
},
),
],
),
),
),
),
),
);
},
);
}
}
@immutable
final class DialogButton extends StatelessWidget {
const DialogButton({
super.key,
});
@override
Widget build(BuildContext context) {
return BasicButton.primary(
child: const Text('Show Dialog'),
onPressed: () {
showBasicDialog(
context,
delegate: BasicDialogDelegate(
title: 'Update Required',
content:
'Sorry for any inconvenience. We have recently made some update and bug fixes to improve your app experience.',
actions: [
BasicDialogAction(
text: 'Update',
buttonType: ActionButtonType.filled,
onPressed: () {
Navigator.of(context).pop();
},
),
],
barrierDismissible: false,
),
);
},
);
}
}