flutter / samples

A collection of Flutter examples and demos
https://flutter.github.io/samples/
Other
16.71k stars 7.43k forks source link

Flutter samples contains the default useMaterial3 = true #2214

Closed gerfalcon closed 2 months ago

gerfalcon commented 2 months ago

Problem

As of version v3.16, ThemeData.useMaterial3 is set true by default.

"We may not need this anymore" - @khanhnwin at the Observable Flutter #38 Google AI Dart SDK session

Steps to reproduce

  1. Visiting samples where
  2. Some of the ThemeData in theMaterialApp() contains the useMaterial3: true flag in its constructor.
Expected results ``` dart return MaterialApp( title: 'Flutter Demo', theme: ThemeData( // This is the theme of your application. // // (...) colorScheme: ColorScheme.fromSeed(seedColor: Colors.green), ), home: const MyHomePage(title: 'Flutter Demo Home Page'), ); ```
Actual results ``` dart return MaterialApp( title: 'Flutter Demo', theme: ThemeData( // This is the theme of your application. // // (...) colorScheme: ColorScheme.fromSeed(seedColor: Colors.green), useMaterial3: true, /// <-- TODO: Needs to be removed ), home: const MyHomePage(title: 'Flutter Demo Home Page'), ); ```

flutter/samples that need to be updated:

Flutter Doctor output

Doctor output ```console Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.19.2, on macOS 12.6.2 21G320 darwin-arm64, locale en-AE) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [!] Xcode - develop for iOS and macOS (Xcode 13.4.1) ✗ Flutter requires Xcode 14 or higher. Download the latest version or update via the Mac App Store. ! CocoaPods 1.11.3 out of date (1.13.0 is recommended). CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side. Without CocoaPods, plugins will not work on iOS or macOS. For more info, see https://flutter.dev/platform-plugins To upgrade see https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods for instructions. [✓] Chrome - develop for the web [✓] Android Studio (version 2022.3) [✓] IntelliJ IDEA Ultimate Edition (version 2023.3.4) [✓] Connected device (2 available) [✓] Network resources ! Doctor found issues in 1 category. ```

Related issues:

sasanktumpati commented 2 months ago

Hey, can I take up this issue?

gerfalcon commented 2 months ago

Ofc @sasanktumpati, every help is appreciated! 🚀

domesticmouse commented 2 months ago

I've landed @sasanktumpati'a PR, but I was holding off until the useMaterial3 parameter was deleted in master. It was a useful reminder to developers when reading the source that the rules had changed.

gerfalcon commented 2 months ago

@domesticmouse Speaking about master, I've raised a change related to the main flutter create template. Could you help me by reviewing it?

domesticmouse commented 2 months ago

I'd hold off on removing it from the template until the attribute is removed from MaterialApp itself.

gerfalcon commented 2 months ago

I understand your point, @domesticmouse. Additionally, it would be nice to know how many projects are using Material 3 and how many of them disable it.

My only concern is that this will increase the amount of cleanup required for the additional projects and samples.

domesticmouse commented 2 months ago

I understand your point, @domesticmouse. Additionally, it would be nice to know how many projects are using Material 3 and how many of them disable it.

My only concern is that this will increase the amount of cleanup required for the additional projects and samples.

Flutter has a Deprecation Policy policy for handling this situation.

Given Material3 was made the default in 3.16 about three months ago, I'd be expecting it to be removed from Flutter in Q1 2025.

Teams that haven't migrated at that point will have to either migrate, or stay on the last build of Flutter that supports reverting to Material2.

domesticmouse commented 2 months ago

On the cleanup front, dart fix will do the vast majority of the work for us.

gerfalcon commented 2 months ago

It was a great learning for me to be familiarized with the definition of the grace period. Thanks for the detailed explanation, @domesticmouse! 🙌

gerfalcon commented 2 months ago

@domesticmouse , I've closed the issue related to the main template: