flutter_widget_extension 0.0.2 flutter_widget_extension: ^0.0.2 copied to clipboard
A Flutter package for chain build widget, decrease widget nested hell.
FlutterWidgetExtension #
🔵 Internationalization #
English | 中文
ℹ️ Introductions #
A Flutter package for chain build widget, decrease widget nested hell. Only pick the frequently used function. Some method may introduce unnecessary container. Please refre the souce code.
Example
Before:
Widget widget() {
return Padding(
padding: const EdgeInsets.all(20.0),
child: Center(
child: Stack(
alignment: AlignmentDirectional.topEnd,
children: [
GestureDetector(
onTap: () => debugPrint("Widget2 is clicked"),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0),
color: Colors.purple,
),
child: Container(
margin: const EdgeInsets.all(4.0),
child: ClipRRect(
borderRadius: BorderRadius.circular(20.0),
child: Image.network(
"https://c-ssl.duitang.com/uploads/item/201609/20/20160920124307_mcZHQ.thumb.1000_0.jpeg"),
),
),
),
),
IconButton(
onPressed: () => debugPrint("Icon is clicked"),
icon: const Icon(
Icons.highlight_remove,
color: Colors.pink,
)),
],
)));
}
After:
dependencies:
flutter_widget_extension: ^0.0.2
import 'package:flutter_widget_extension/flutter_widget_extension.dart';
Widget widget() {
return Image.network(
"https://c-ssl.duitang.com/uploads/item/201609/20/20160920124307_mcZHQ.thumb.1000_0.jpeg")
.round(20.0)
.addMargin(const EdgeInsets.all(4.0))
.addBackgroundColor(Colors.purple)
.round(20.0)
.addOnTap(() => debugPrint("Widget2 is clicked"))
.badge(IconButton(
onPressed: () => debugPrint("Icon is clicked"),
icon: const Icon(
Icons.highlight_remove,
color: Colors.pink,
)))
.center()
.addPadding(const EdgeInsets.all(20.0));
}