change color BorderSide when switching to dark theme

Issue

The code in the photo is responsible for building the widget. The red line is responsible for constructing the line that underlines the inscription "Location information"

enter image description here
enter image description here

With a white theme, this line is black. Can you tell me how can I make it white when the application theme switches to dark?

   .....
    class MyThemes {
      static final darkTheme = ThemeData(
        scaffoldBackgroundColor: Colors.grey[800],
        colorScheme: ColorScheme.dark(),
        listTileTheme: ListTileThemeData(iconColor: Colors.white,),
        textTheme: TextTheme(
          subtitle2: TextStyle(
            color: Colors.white,
          ),
        ),
          );
  ......

Solution

You can call color on BorderSide

decoration: BoxDecoration(
  border: Border(
    bottom: BorderSide(
      color: Theme.of(context).brightness == Brightness.dark
          ? Colors.white
          : Colors.black,
    ),
  ),
),

You can also check Text‘s decoration and instead using Theme.of(context).brightness you can use your theme data.

Answered By – Yeasin Sheikh

Answer Checked By – Mildred Charles (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *