• Greg Spencer's avatar
    Move examples from dart:ui ui/lib/text.dart to examples/api (#96557) · 017ed179
    Greg Spencer authored
    This extracts the examples that are in flutter/engine@main/lib/ui/text.dart into examples in the examples/api/lib/ui directory and adds some simple tests for them.
    
    Also, fixes some inconsistent test file naming.
    
    This is step 1: the next step is to remove the examples from the dart:ui code.
    017ed179
ink.image_clip.1_test.dart 1.33 KB
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:typed_data';

import 'package:flutter/material.dart';
import 'package:flutter_api_samples/material/ink/ink.image_clip.1.dart' as example;
import 'package:flutter_test/flutter_test.dart';

void main() {
  const List<int> kTransparentImage = <int>[
    0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49,
    0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x06,
    0x00, 0x00, 0x00, 0x1F, 0x15, 0xC4, 0x89, 0x00, 0x00, 0x00, 0x0A, 0x49, 0x44,
    0x41, 0x54, 0x78, 0x9C, 0x63, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00, 0x01, 0x0D,
    0x0A, 0x2D, 0xB4, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE,
  ];

  testWidgets('Ink ancestor material is clipped', (WidgetTester tester) async {
    await tester.pumpWidget(
      MaterialApp(
        home: Scaffold(
          body: example.MyStatelessWidget(
            image: MemoryImage(Uint8List.fromList(kTransparentImage)),
          ),
        ),
      ),
    );

    final Finder inkMaterialFinder = find.ancestor(of: find.byType(Ink), matching: find.byType(Material));
    expect(find.ancestor(of: inkMaterialFinder, matching: find.byType(ClipRRect)), findsOneWidget);
  });
}