Skip to content

Consider changing the Color.lerp implementation to more naturally handle transparency #48534

@sooxt98

Description

@sooxt98

Simply run with dart pad and press the FAB button. I'm not show is AnimatedContainer problem or SKIA colour rendering problem.

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Transparent Issue',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Colors.transparent issue'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  bool isColorSwap = true;

  void _incrementCounter() {
    setState(() {
      isColorSwap = !isColorSwap;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[
            Expanded(
                child: AnimatedContainer(
                    child: Center(child: Text('fade between white color')),
                    width: double.infinity,
                    duration: Duration(milliseconds: 500),
                    color: isColorSwap ? Colors.lightBlue[100] : Colors.white)),
            Expanded(
                child: AnimatedContainer(
                    child:
                        Center(child: Text('fade between transparent color')),
                    width: double.infinity,
                    duration: Duration(milliseconds: 500),
                    color: isColorSwap
                        ? Colors.lightBlue[100]
                        : Colors.transparent))
          ]),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'ClickMe',
        child: Icon(Icons.add),
      ),
    );
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: animationAnimation APIsc: API breakBackwards-incompatible API changesengineflutter/engine related. See also e: labels.found in release: 3.3Found to occur in 3.3found in release: 3.6Found to occur in 3.6has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions