buildButton method
Widget
buildButton(
- dynamic button
)
Implementation
Widget buildButton(dynamic button) {
bool isPrimary = button['primary'].toLowerCase() == "true";
final isDarkMode = Theme.of(context).brightness == Brightness.dark;
return Container(
height: 25,
margin: EdgeInsets.only(right: 8, bottom: 8),
child: TextButton(
onPressed: () {
_launchUrl(Uri.parse(button['action'].toString()));
},
style: ButtonStyle(
backgroundColor: isPrimary
? MaterialStatePropertyAll(widget.themeConfig?.primary ??
(isDarkMode ? Colors.white : Colors.black))
: null,
shape: MaterialStateProperty.all(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(4.0),
side: BorderSide(
color: isPrimary
? widget.themeConfig?.primary ??
(isDarkMode ? Colors.white : Colors.black)
: isDarkMode
? widget.themeConfig?.darkText ?? Colors.white
: widget.themeConfig?.lightText ?? Colors.black,
),
),
),
),
child: Text(
button['label'].toString().toUpperCase(),
style: TextStyle(
fontSize: 8,
color: isPrimary
? isDarkMode
? widget.themeConfig?.lightText ?? Colors.black
: widget.themeConfig?.darkText ?? Colors.white
: isDarkMode
? widget.themeConfig?.darkText ?? Colors.white
: widget.themeConfig?.lightText ?? Colors.black,
),
),
),
);
}