Home > Software engineering >  Why do I have to remove const from MaterialApp if I use a theme?
Why do I have to remove const from MaterialApp if I use a theme?

Time:12-24

First, here is an example without using a theme. I can put const on MaterialApp.

import 'package:flutter/material.dart';

void main() {
  runApp(const _MyApp());
}

class _MyApp extends StatelessWidget {
  const _MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp( //            
  • Related