Skip to content

Cannot mix 2014 and 2018 terms in call to TextTheme() constructor #51698

Closed

Description

@praharshbhatt

Steps to Reproduce

  1. Write a themeData function
  2. call the method on a ThemeData object

Expected results:
runs successfully

Actual results:
Throws exception

I/flutter (27001): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (27001): The following assertion was thrown building SplashScreen(dirty, dependencies: [MediaQuery], state:
I/flutter (27001): _SplashScreenState#9765f):
I/flutter (27001): Cannot mix 2014 and 2018 terms in call to TextTheme() constructor.
I/flutter (27001): 'package:flutter/src/material/text_theme.dart':
I/flutter (27001): Failed assertion: line 182 pos 10: '(headline1 == null && headline2 == null && headline3 == null &&
I/flutter (27001): headline4 == null && headline5 == null && headline6 == null &&
I/flutter (27001):           subtitle1 == null && subtitle2 == null &&
I/flutter (27001):           bodyText1 == null && bodyText2 == null) ||
I/flutter (27001):          (display4 == null && display3 == null && display2 == null && display1 == null && headline
I/flutter (27001): == null && title == null &&
I/flutter (27001):           subhead == null && subtitle == null &&
I/flutter (27001):           body2 == null && body1 == null)'
I/flutter (27001): 
I/flutter (27001): The relevant error-causing widget was:
I/flutter (27001):   SplashScreen
I/flutter (27001):   file:///D:/Multiverse_Projects/Flutter/Projects/Tempo-guided_breathing/tempo/lib/main.dart:30:32
I/flutter (27001): 
I/flutter (27001): When the exception was thrown, this was the stack:
I/flutter (27001): #2      new TextTheme (package:flutter/src/material/text_theme.dart:182:10)
I/flutter (27001): #3      getMainThemeWithBrightness (package:tempo/themes/maintheme.dart:71:16)
I/flutter (27001): #4      _SplashScreenState.build (package:tempo/main.dart:50:18)
I/flutter (27001): #5      StatefulElement.build (package:flutter/src/widgets/framework.dart:4590:28)
I/flutter (27001): #6      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4478:15)
I/flutter (27001): #7      StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4646:11)
I/flutter (27001): #8      Element.rebuild (package:flutter/src/widgets/framework.dart:4202:5)
I/flutter (27001): #9      ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4461:5)
I/flutter (27001): #10     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4637:11)
I/flutter (27001): #11     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4456:5)
I/flutter (27001): ...     Normal element mounting (115 frames)
I/flutter (27001): #126    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3430:14)
I/flutter (27001): #127    MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5857:32)
I/flutter (27001): ...     Normal element mounting (247 frames)
I/flutter (27001): #374    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3430:14)
I/flutter (27001): #375    Element.updateChild (package:flutter/src/widgets/framework.dart:3198:18)
I/flutter (27001): #376    RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:1142:16)
I/flutter (27001): #377    RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:1113:5)
I/flutter (27001): #378    RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure> (package:flutter/src/widgets/binding.dart:1055:17)
I/flutter (27001): #379    BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2591:19)
I/flutter (27001): #380    RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:1054:13)
I/flutter (27001): #381    WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:935:7)
I/flutter (27001): #382    WidgetsBinding.scheduleAttachRootWidget.<anonymous closure> (package:flutter/src/widgets/binding.dart:917:7)
I/flutter (27001): (elided 13 frames from class _AssertionError, class _RawReceivePortImpl, class _Timer, dart:async, and dart:async-patch)
I/flutter (27001): 
I/flutter (27001): ════════════════════════════════════════════════════════════════════════════════════════════════════
W/DynamiteModule(27001): Local module descriptor class for providerinstaller not found.
I/DynamiteModule(27001): Considering local module providerinstaller:0 and remote module providerinstaller:0
W/ProviderInstaller(27001): Failed to load providerinstaller module: No acceptable module found. Local version is 0 and remote version is 0.
W/ilippelan.temp(27001): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/ilippelan.temp(27001): Accessing hidden method Lsun/misc/Unsafe;->arrayBaseOffset(Ljava/lang/Class;)I (greylist,core-platform-api, linking, allowed)
W/ilippelan.temp(27001): Accessing hidden method Lsun/misc/Unsafe;->copyMemory(JJJ)V (greylist, linking, allowed)
W/ilippelan.temp(27001): Accessing hidden method Lsun/misc/Unsafe;->objectFieldOffset(Ljava/lang/reflect/Field;)J (greylist,core-platform-api, linking, allowed)
I/ilippelan.temp(27001): The ClassLoaderContext is a special shared library.
W/ilippelan.temp(27001): Accessing hidden method Lsun/misc/Unsafe;->getByte(J)B (greylist,core-platform-api, linking, allowed)
W/ilippelan.temp(27001): Accessing hidden method Lsun/misc/Unsafe;->getByte(Ljava/lang/Object;J)B (greylist,core-platform-api, linking, allowed)
W/ilippelan.temp(27001): Accessing hidden method Lsun/misc/Unsafe;->getLong(J)J (greylist,core-platform-api, linking, allowed)
W/ilippelan.temp(27001): Accessing hidden method Lsun/misc/Unsafe;->putByte(JB)V (greylist,core-platform-api, linking, allowed)
W/ilippelan.temp(27001): Accessing hidden method Lsun/misc/Unsafe;->putByte(Ljava/lang/Object;JB)V (greylist,core-platform-api, linking, allowed)
W/ilippelan.temp(27001): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed)
W/ilippelan.temp(27001): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed)
W/ilippelan.temp(27001): Accessing hidden field Ljava/nio/Buffer;->address:J (greylist, reflection, allowed)
I/ilippelan.temp(27001): The ClassLoaderContext is a special shared library.
I/ilippelan.temp(27001): NativeAlloc concurrent copying GC freed 4698(507KB) AllocSpace objects, 5(208KB) LOS objects, 49% free, 2093KB/4186KB, paused 1.491ms total 238.990ms
I/ilippelan.temp(27001): The ClassLoaderContext is a special shared library.
I/flutter (27001): {name: Praharsh Bhatt, vibrate: true, Theme: Dark Theme, photo url: https://lh3.googleusercontent.com/a-/AAuE7mDfePCr-OgOIfblgpzyBAi2zpX_B7NmaVJt2QIAgEE=s96-c, Uploaded Breaths: [The 4-7-8 technique], email: [email protected]}
V/NativeCrypto(27001): Registering com/google/android/gms/org/conscrypt/NativeCrypto's 286 native methods...
W/ilippelan.temp(27001): Accessing hidden method Ljava/security/spec/ECParameterSpec;->getCurveName()Ljava/lang/String; (greylist, reflection, allowed)
D/NetworkSecurityConfig(27001): No Network Security Config specified, using platform default
I/ProviderInstaller(27001): Installed default security provider GmsCore_OpenSSL
W/ilippelan.temp(27001): Accessing hidden field Ljava/net/Socket;->impl:Ljava/net/SocketImpl; (greylist, reflection, allowed)
W/ilippelan.temp(27001): Accessing hidden method Ldalvik/system/CloseGuard;->get()Ldalvik/system/CloseGuard; (greylist,core-platform-api, linking, allowed)
W/ilippelan.temp(27001): Accessing hidden method Ldalvik/system/CloseGuard;->open(Ljava/lang/String;)V (greylist,core-platform-api, linking, allowed)
W/ilippelan.temp(27001): Accessing hidden field Ljava/io/FileDescriptor;->descriptor:I (greylist, JNI, allowed)
E/flutter (27001): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: 'package:flutter/src/material/text_theme.dart': Failed assertion: line 182 pos 10: '(headline1 == null && headline2 == null && headline3 == null && headline4 == null && headline5 == null && headline6 == null &&
E/flutter (27001):           subtitle1 == null && subtitle2 == null &&
E/flutter (27001):           bodyText1 == null && bodyText2 == null) ||
E/flutter (27001):          (display4 == null && display3 == null && display2 == null && display1 == null && headline == null && title == null &&
E/flutter (27001):           subhead == null && subtitle == null &&
E/flutter (27001):           body2 == null && body1 == null)': Cannot mix 2014 and 2018 terms in call to TextTheme() constructor.
E/flutter (27001): #0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:42:39)
E/flutter (27001): #1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:38:5)
E/flutter (27001): #2      new TextTheme (package:flutter/src/material/text_theme.dart:182:10)
E/flutter (27001): #3      getMainThemeWithBrightness (package:tempo/themes/maintheme.dart:71:16)
E/flutter (27001): #4      mainNavigationPage (package:tempo/main.dart:93:11)
E/flutter (27001): #5      new AuthService.<anonymous closure> (package:tempo/services/auth.dart:39:7)
E/flutter (27001): <asynchronous suspension>
E/flutter (27001): #6      new AuthService.<anonymous closure> (package:tempo/services/auth.dart)
E/flutter (27001): #7      _rootRunUnary (dart:async/zone.dart:1134:38)
E/flutter (27001): #8      _CustomZone.runUnary (dart:async/zone.dart:1031:19)
E/flutter (27001): #9      _FutureListener.handleValue (dart:async/future_impl.dart:140:18)
E/flutter (27001): #10     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
E/flutter (27001): #11     Future._propagateToListeners (dart:async/future_impl.dart:711:32)
E/flutter (27001): #12     Future._completeWithValue (dart:async/future_impl.dart:526:5)
E/flutter (27001): #13     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:34:15)
E/flutter (27001): #14     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:293:13)
E/flutter (27001): #15     AuthService.checkIsSignedIn (package:tempo/services/auth.dart)
E/flutter (27001): <asynchronous suspension>
E/flutter (27001): #16     new AuthService (package:tempo/services/auth.dart:34:5)
E/flutter (27001): #17     _SplashScreenState.initState (package:tempo/main.dart:42:23)
E/flutter (27001): #18     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4611:58)
E/flutter (27001): #19     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4456:5)
E/flutter (27001): #20     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3430:14)
E/flutter (27001): #21     Element.updateChild (package:flutter/src/widgets/framework.dart:3198:18)
E/flutter (27001): #22     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5747:14)
E/flutter (27001): #23     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3430:14)
E/flutter (27001): #24     Element.updateChild (package:flutter/src/widgets/framework.dart:3198:18)
E/flutter (27001): #25     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4498:16)
E/flutter (27001): #26     Element.rebuild (package:flutter/src/widgets/framework.dart:4202:5)
E/flutter (27001): #27     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4461:5)
E/flutter (27001): #28     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4456:5)
E/flutter (27001): #29     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3430:14)
E/flutter (27001): #30     Element.updateChild (package:flutter/src/widgets/framework.dart:3198:18)
E/flutter (27001): #31     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5747:14)
E/flutter (27001): #32     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3430:14)
E/flutter (27001): #33     Element.updateChild (package:flutter/src/widgets/framework.dart:3198:18)
E/flutter (27001): #34     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5747:14)
E/flutter (27001): #35     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3430:14)
E/flutter (27001): #36     Element.updateChild (package:flutter/src/widgets/framework.dart:3198:18)
E/flutter (27001): #37     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4498:16)
E/flutter (27001): #38     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4646:11)
E/flutter (27001): #39     Element.rebuild (package:flutter/src/widgets/framework.dart:4202:5)
E/flutter (27001): #40     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4461:5)
E/flutter (27001): #41     StatefulElement._firstBuild (packag
W/ilippelan.temp(27001): Accessing hidden method Ljava/security/spec/ECParameterSpec;->setCurveName(Ljava/lang/String;)V (greylist, reflection, allowed)
W/ilippelan.temp(27001): Accessing hidden method Ldalvik/system/BlockGuard;->getThreadPolicy()Ldalvik/system/BlockGuard$Policy; (greylist,core-platform-api, linking, allowed)
W/ilippelan.temp(27001): Accessing hidden method Ldalvik/system/BlockGuard$Policy;->onNetwork()V (greylist, linking, allowed)

Flutter Doctor:




D:\Multiverse_Projects\Flutter\flutter\bin\flutter.bat doctor --verbose
[√] Flutter (Channel master, v1.15.4-pre.239, on Microsoft Windows [Version 10.0.18363.657], locale en-US)
    • Flutter version 1.15.4-pre.239 at D:\Multiverse_Projects\Flutter\flutter
    • Framework revision 167ef2eda9 (5 hours ago), 2020-02-29 02:56:01 -0500
    • Engine revision 142882e1ba
    • Dart version 2.8.0 (build 2.8.0-dev.10.0 6708f6d4c7)

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at C:\Users\prahu\AppData\Local\Android\Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: D:\Apps\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 3.6)
    • Android Studio at D:\Apps\Android Studio
    • Flutter plugin version 44.0.2
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

[√] Connected device (3 available)
    • Android SDK built for x86 • emulator-5554 • android-x86    • Android 10 (API 29) (emulator)
    • Chrome                    • chrome        • web-javascript • Google Chrome 79.0.3945.130
    • Web Server                • web-server    • web-javascript • Flutter Tools

• No issues found!
Process finished with exit code 0

ThemeData code:

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import '../widgets/shapes.dart';

//This file contains the main theme settings

//Return the ThemeData with Brightness
ThemeData getMainThemeWithBrightness(BuildContext context, Brightness appBrightness) {
  double size = MediaQuery.of(context).size.width < MediaQuery.of(context).size.height
      ? MediaQuery.of(context).size.width
      : (!kIsWeb) ? MediaQuery.of(context).size.height : MediaQuery.of(context).size.height / 2;


  //Set StatusBar color, navigationBar color
  SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
    statusBarColor: appBrightness == Brightness.light ? Colors.white : Colors.black,
    statusBarIconBrightness: appBrightness == Brightness.light ? Brightness.dark : Brightness.light,
    systemNavigationBarColor: appBrightness == Brightness.light ? Colors.white : Colors.black,
    systemNavigationBarIconBrightness: appBrightness == Brightness.light ? Brightness.dark : Brightness.light,
  ));





  return ThemeData(
    // Define the default brightness and colors.
    brightness: appBrightness,
    primaryColor:
        appBrightness == Brightness.light ? Color.fromARGB(255, 234, 76, 137) : Color.fromARGB(255, 5, 144, 98),
    accentColor:
        appBrightness == Brightness.light ? Color.fromARGB(255, 234, 76, 137) : Color.fromARGB(255, 8, 195, 164),

    highlightColor: appBrightness == Brightness.light ? Colors.pinkAccent : Colors.green,
    cursorColor: appBrightness == Brightness.light ? Colors.pinkAccent : Colors.green,
    focusColor: appBrightness == Brightness.light ? Colors.pinkAccent : Colors.green,
    indicatorColor: appBrightness == Brightness.light ? Colors.pinkAccent : Colors.green,
    buttonColor: appBrightness == Brightness.light ? Color.fromARGB(255, 234, 76, 137) : Color.fromARGB(255, 8, 195, 164),

    splashColor:
        appBrightness == Brightness.light ? Color.fromARGB(255, 234, 76, 137) : Color.fromARGB(255, 8, 195, 164),
    primaryColorDark:
        appBrightness == Brightness.light ? Color.fromARGB(255, 234, 76, 137) : Color.fromARGB(255, 34, 95, 77),




    iconTheme: IconThemeData(
        color: appBrightness == Brightness.light ? Colors.black : Colors.white70, opacity: 1.0, size: size * 0.06),

    // Define the default font family.
    fontFamily: "Poppins",

    backgroundColor: appBrightness == Brightness.light ? Colors.white : Colors.black,
    scaffoldBackgroundColor: appBrightness == Brightness.light ? Colors.white : Colors.black,
    canvasColor: appBrightness == Brightness.light ? Colors.white : Colors.black,

    //For Card
    cardColor: appBrightness == Brightness.light ? Color.fromARGB(255, 250, 250, 250) : Color.fromARGB(255, 30, 30, 30),
    cardTheme: CardTheme(
      color: appBrightness == Brightness.light ? Color.fromARGB(255, 250, 250, 250) : Color.fromARGB(255, 30, 30, 30),
      elevation: 6,
      margin: EdgeInsets.all(12),
      shape: roundedShape(),
    ),

    // Define the default TextTheme. Use this to specify the default
    // text styling for headlines, headline2s, bodies of text, and more.
    textTheme: TextTheme(
      headline1: TextStyle(
          fontSize: size * 0.085,
          fontFamily: 'Poppins',
          fontWeight: FontWeight.bold,
          color: appBrightness == Brightness.light ? Colors.black : Colors.white70),
      headline2: TextStyle(
          fontSize: size * 0.08,
          fontFamily: 'Poppins',
          fontWeight: FontWeight.bold,
          color: appBrightness == Brightness.light ? Colors.black : Colors.white70),
      caption: TextStyle(
          fontSize: size * 0.05,
          fontFamily: 'Poppins',
          fontWeight: FontWeight.bold,
          color: appBrightness == Brightness.light ? Colors.black : Colors.white70),
      bodyText1: TextStyle(
          fontSize: size * 0.04,
          fontFamily: "Poppins",
          color: appBrightness == Brightness.light ? Colors.black : Colors.white70),
      bodyText2: TextStyle(
          fontSize: size * 0.038,
          fontFamily: "Poppins",
          color: appBrightness == Brightness.light ? Colors.black : Colors.white70),
      display1: TextStyle(
          fontFamily: "Poppins",
          fontWeight: FontWeight.w500,
          fontSize: size * 0.04,
          color: appBrightness == Brightness.light ? Colors.black : Colors.white70),
    ),
  );
}

Activity

  1. praharshbhatt commented on Mar 1, 2020

    @praharshbhatt
    Author

    It turns out I was using the old deprecated arguments. Removing them and recompiling works.

  2. VladyslavBondarenko commented on Mar 2, 2020

    @VladyslavBondarenko

    @praharshbhatt glad to know that you fixed this, closing

  3. asmaa3107 commented on Dec 19, 2020

    @asmaa3107

    It turns out I was using the old deprecated arguments. Removing them and recompiling works.

    @praharshbhatt glad to know that you fixed this, closing

    I am using templet for my new project and facing the same issue .
    I do not want to delete the deprecated attribute is there any other way to upgrade the material theme package and then use ew arguments (replace current version)?? thanks

  4. github-actions commented on Aug 8, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  5. locked as resolved and limited conversation to collaborators on Aug 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions