Skip to content

DecorationImage.centerSlice (and probably Canvas.drawImageNine) don't work correctly on web #130612

Description

@Hixie

Even with CanvasKit, Canvas.drawImageNine renders incorrectly.

Specifically I was testing with a 4x4 image giving centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0) to DecorationImage and the result did not match other platforms (nor my intuition and understanding of 9-patch image transforms).

Activity

  1. darshankawar commented on Jul 17, 2023

    @darshankawar
    Member

    I tried to verify this based on the given info and using below code sample with a test png (4x4), but observed below error in the console:

    The following assertion was thrown during paint():
    Assertion failed:
    file:///Users/dhs/Documents/Fluttersdk/flutter/packages/flutter/lib/src/painting/decoration_image.dart:521:12
    sourceSize == inputSize
    "centerSlice was used with a BoxFit that does not guarantee that the image is fully visible."
    
    
    runnable code sample
    
    import 'package:flutter/material.dart';
    
    void main() {
      runApp(MaterialApp(
        home: const MyApp(),
      ));
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({Key? key}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: Container(
            decoration: const BoxDecoration(
              image: DecorationImage(
                image: AssetImage('assets/image.png'),
              //  fit: BoxFit.none,
                centerSlice: Rect.fromLTWH(2.0, 2.0, 1.0, 1.0),
              ),
            ),
            child: const Center(
              child: Text('Some text'),
            ),
          )
        );
      }
    }
    
    

    Also, maybe related : #16098

  2. added
    platform-webWeb applications specifically
    team-webOwned by Web platform team
    a: imagesLoading, displaying, rendering images
    and removed
    in triagePresently being triaged by the triage team
    on Jul 17, 2023
  3. Hixie commented on Jul 17, 2023

    @Hixie
    ContributorAuthor
  4. added
    e: web_htmlHTML rendering backend for Web
    e: web_canvaskitCanvasKit (a.k.a. Skia-on-WebGL) rendering backend for Web
    P2Important issues not at the top of the work list
    triaged-webTriaged by Web platform team
    on Jul 20, 2023
  5. github-actions commented on Sep 3, 2026

    @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.

  6. locked as resolved and limited conversation to collaborators on Sep 3, 2026
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

    P2Important issues not at the top of the work lista: imagesLoading, displaying, rendering imagese: web_canvaskitCanvasKit (a.k.a. Skia-on-WebGL) rendering backend for Webplatform-webWeb applications specificallyteam-webOwned by Web platform teamtriaged-webTriaged by Web platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions