Flutter Extend ThemeData, add colours etc

838 views Asked by At

I am trying to extend the color scheme used by my first app. I created a separate file that contains the following:

import 'package:flutter/cupertino.dart';

class Testy extends CupertinoThemeData {
  final Color bgws = Color.fromRGBO(120, 120, 120, 1);
}

I then imported it into Main.Dart but cannot see how to use my new color. I thought Testy.bgws would do it but clearly I am missing something.

1

There are 1 answers

0
novol On

You can use default textTheme without Cupertino like

    final ThemeData appThemeLight = ThemeData(
      /// theme
      brightness: Brightness.light,
    
      /// screen
      primaryColor: Colors.blue,
    
      /// brightness color
      accentColor: Colors.white,
    
      /// opacity color
      hintColor: Colors.grey,
    
      /// here you can add cupertino
      cupertinoOverrideTheme: CupertinoThemeData(
        primaryColor: Colors.black,
      ),
....

and use it Theme.of(context)...

also don't forget add appThemeLight to MaterialApp like theme: appThemeLight