Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[animations package] FadeThroughTransition doesn't work correctly with ListTile.tileColor when ThemeData.canvasColor is specified #104543

Closed
gidrokolbaska opened this issue May 24, 2022 · 4 comments
Labels
r: solved Issue is closed as solved

Comments

@gidrokolbaska
Copy link

gidrokolbaska commented May 24, 2022

Steps to Reproduce

  1. Run my sample
  2. In ThemeData of your app, specify the canvasColor;
  3. Take a look on how your tileColor disappears.
    Yeah, you can set the fillColor of FadeThroughTransition to Colors.transparent but in this case the transition is janky...
    By running the code sample you will see some additional glitches as well, e.g. positioning of the widgets :)

Expected results:
I expect ListTile to have its' tileColor visible when using FadeThroughTransition without setting fillColor to transparent (which is also buggy)

Expected Results Actual Results
image image

and a video (includes both tileColor and positioning issues):

Simulator.Screen.Recording.-.iPhone.12.-.2022-05-25.at.00.05.35.mp4
Code sample
void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  int _pageIndex = 0;
  final _pageList = [
    const MyHomePage(),
    Align(
      alignment: Alignment.center,
      child: Center(
        child: Container(
          height: 200,
          width: 200,
          color: Colors.red,
        ),
      ),
    ),
    Container(
      height: 200,
      width: 200,
      color: Colors.blue,
    )
  ];
  @override
  Widget build(BuildContext context) {
    return ScreenUtilInit(
        designSize: const Size(360, 690),
        minTextAdapt: true,
        builder: (context, child) {
          return MaterialApp(
            //useInheritedMediaQuery: true,
            title: 'Flutter Demo',
            theme: ThemeData(
              canvasColor: Colors.grey,
              // primarySwatch: Colors.blue,
            ),
            home: Scaffold(
              appBar: AppBar(),
              bottomNavigationBar: BottomNavigationBar(
                currentIndex: _pageIndex,
                backgroundColor: Colors.blue,
                onTap: (selectedIndex) {
                  setState(() {
                    _pageIndex = selectedIndex;
                  });
                },
                items: const [
                  BottomNavigationBarItem(
                      icon: Icon(Icons.photo_library), label: 'Page1'),
                  BottomNavigationBarItem(
                      icon: Icon(Icons.photo), label: 'Page2'),
                  BottomNavigationBarItem(
                      icon: Icon(Icons.search), label: 'Page3'),
                ],
              ),
              body: PageTransitionSwitcher(
                transitionBuilder:
                    (child, primaryAnimation, secondaryAnimation) {
                  return FadeThroughTransition(
                    //fillColor: Colors.transparent,
                    animation: primaryAnimation,
                    secondaryAnimation: secondaryAnimation,
                    child: child,
                  );
                },
                child: _pageList[_pageIndex],
              ),
            ),
          );
        });
  }
}
Logs
           oh c'mon, there is no need for that
Analyzing test_app...                                                   

   info • Unused import: 'package:modal_bottom_sheet/modal_bottom_sheet.dart' • lib/main.dart:4:8 • unused_import
   info • Prefer const with constant constructors • lib/main.dart:94:18 • prefer_const_constructors
   info • Prefer const with constant constructors • lib/main.dart:122:11 • prefer_const_constructors
   info • Prefer const with constant constructors • lib/main.dart:124:20 • prefer_const_constructors
   info • Prefer const with constant constructors • lib/main.dart:125:22 • prefer_const_constructors
   info • The declaration '_ModalBottomSheetDemo' isn't referenced • lib/main.dart:168:7 • unused_element
   info • Prefer const with constant constructors • lib/main.dart:186:16 • prefer_const_constructors
 Flutter (Channel master, 3.1.0-0.0.pre.731, on macOS 12.1 21C52 darwin-arm, locale ru-RU)
    • Flutter version 3.1.0-0.0.pre.731 at /Users/gidrokolbaska/Developer/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 630f9559ff (8 days ago), 2022-05-16 07:24:10 -0400
    • Engine revision 498a85623a
    • Dart version 2.18.0 (build 2.18.0-117.0.dev)
    • DevTools version 2.13.1

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /Users/gidrokolbaska/Library/Android/sdk
    • Platform android-32, build-tools 32.1.0-rc1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)

[✓] VS Code (version 1.67.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.34.0

[✓] Connected device (3 available)
    • iPhone 12 (mobile) • 418F5868-558D-4393-8600-ADA65821DB6E • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-4 (simulator)
    • macOS (desktop)    • macos                                • darwin-arm64   • macOS 12.1 21C52 darwin-arm
    • Chrome (web)       • chrome                               • web-javascript • Google Chrome 101.0.4951.64

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
@maheshmnj maheshmnj added the in triage Presently being triaged by the triage team label May 25, 2022
@maheshmnj
Copy link
Member

maheshmnj commented May 25, 2022

Hi @gidrokolbaska, Thanks for filing the issue. Looks like the code sample you shared is incomplete, However, With the below code sample, I see it working as intended.

code sample
import 'package:animations/animations.dart';
import 'package:flutter/material.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  int _pageIndex = 0;
  final _pageList = [
    const MyHomePage(),
    Align(
      alignment: Alignment.center,
      child: Center(
        child: Container(
          height: 200,
          width: 200,
          color: Colors.red,
        ),
      ),
    ),
    Container(
      height: 200,
      width: 200,
      color: Colors.blue,
    )
  ];
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      //useInheritedMediaQuery: true,
      title: 'Flutter Demo',
      theme: ThemeData(
        canvasColor: Colors.grey,
        // primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(),
        bottomNavigationBar: BottomNavigationBar(
          currentIndex: _pageIndex,
          backgroundColor: Colors.blue,
          onTap: (selectedIndex) {
            setState(() {
              _pageIndex = selectedIndex;
            });
          },
          items: const [
            BottomNavigationBarItem(
                icon: Icon(Icons.photo_library), label: 'Page1'),
            BottomNavigationBarItem(icon: Icon(Icons.photo), label: 'Page2'),
            BottomNavigationBarItem(icon: Icon(Icons.search), label: 'Page3'),
          ],
        ),
        body: PageTransitionSwitcher(
          transitionBuilder: (child, primaryAnimation, secondaryAnimation) {
            return FadeThroughTransition(
              //fillColor: Colors.transparent,
              animation: primaryAnimation,
              secondaryAnimation: secondaryAnimation,
              child: child,
            );
          },
          child: _pageList[_pageIndex],
        ),
      ),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Material(
      child: ListView.builder(itemBuilder: (context, index) {
        return Padding(
          padding: const EdgeInsets.all(8.0),
          child: ListTile(
            tileColor: Colors.green,
            title: Text('Item $index'),
          ),
        );
      }),
    );
  }
}
Screen.Recording.2022-05-25.at.3.43.02.PM.mov

In case you still see the issue please share a minimal and complete code sample.

flutter doctor -v (mac)
[✓] Flutter (Channel master, 3.1.0-0.0.pre.854, on macOS 12.3 21E230 darwin-arm, locale en-IN)
    • Flutter version 3.1.0-0.0.pre.854 at /Users/mahesh/Documents/flutter_master
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ec20ea80ad (35 hours ago), 2022-05-21 16:28:06 -0400
    • Engine revision 1bfe551d6b
    • Dart version 2.18.0 (build 2.18.0-142.0.dev)
    • DevTools version 2.13.1

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/mahesh/Library/Android/sdk
    • Platform android-32, build-tools 31.0.0
    • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    ! CocoaPods 1.10.2 out of date (1.11.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#installation for instructions.

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)

[✓] IntelliJ IDEA Community Edition (version 2021.2.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 61.2.4
    • Dart plugin version 212.5080.8

[✓] VS Code (version 1.66.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.40.0

[✓] Connected device (4 available)
    • Redmi K20 Pro (mobile) • 192.168.1.2:5555                     • android-arm64  • Android 11 (API 30)
    • iPhone 12 Pro (mobile) • 19FD0231-BFF0-441D-B584-AD94C4084525 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-15-2 (simulator)
    • macOS (desktop)        • macos                                • darwin-arm64   • macOS 12.3 21E230 darwin-arm
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 101.0.4951.64

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.

@maheshmnj maheshmnj added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 25, 2022
@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 25, 2022
@gidrokolbaska
Copy link
Author

Hi @gidrokolbaska, Thanks for filing the issue. Looks like the code sample you shared is incomplete, However, With the below code sample, I see it working as intended.

flutter doctor -v
Screen.Recording.2022-05-25.at.3.43.02.PM.mov
In case you still see the issue please share a minimal and complete code sample.

flutter doctor -v (mac)

hmm, yeah, it works by wrapping the ListTile with Material but isn't it suppose to work out of the box without the Material widget? Am I missing something?

@maheshmnj
Copy link
Member

@gidrokolbaska the ListTile docs recommends wrapping ListTile in material widget for these colors to take effect.

The tileColor, selectedTileColor, focusColor, and hoverColor are not painted by the list tile itself but by the material widget ancestor.

There's a PR filed which would do this out of the box #102310

Closing as this is working as intended

@maheshmnj maheshmnj added r: solved Issue is closed as solved and removed in triage Presently being triaged by the triage team labels May 26, 2022
@github-actions
Copy link

github-actions bot commented Jun 9, 2022

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
r: solved Issue is closed as solved
Projects
None yet
Development

No branches or pull requests

2 participants