From d563aca557ea2b3ddd96a966e2a2d4c6cfa49af8 Mon Sep 17 00:00:00 2001 From: Eunice Vassoa Date: Fri, 7 Jan 2022 11:56:51 +0200 Subject: [PATCH] changing background color conditions --- example/lib/main.dart | 2 +- lib/widgets/filterable_list.dart | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 7859b7a..a5f8de5 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -13,7 +13,7 @@ class MyApp extends StatelessWidget { return MaterialApp( title: 'Example', theme: ThemeData( - primarySwatch: Colors.blue, + primarySwatch: Colors.blue ), home: SafeArea( child: Scaffold( diff --git a/lib/widgets/filterable_list.dart b/lib/widgets/filterable_list.dart index 3546826..84a72ef 100644 --- a/lib/widgets/filterable_list.dart +++ b/lib/widgets/filterable_list.dart @@ -50,10 +50,15 @@ class FilterableList extends StatelessWidget { @override Widget build(BuildContext context) { + final ThemeData theme = Theme.of(context); + final ScaffoldState? scaffold = Scaffold.maybeOf(context); + + Color _suggestionBackgroundColor = suggestionBackgroundColor ?? scaffold?.widget.backgroundColor ?? theme.scaffoldBackgroundColor; + return Material( elevation: 5, borderRadius: BorderRadius.circular(5), - color: suggestionBackgroundColor ?? Colors.white, + color: _suggestionBackgroundColor, child: Container( constraints: BoxConstraints( maxHeight: maxListHeight