Unverified Commit d0596582 authored by Dan Field's avatar Dan Field Committed by GitHub

Fix tests that use bogus objects, update TestImageInfo interface (#64599)

parent c8f3df7e
...@@ -4,11 +4,13 @@ ...@@ -4,11 +4,13 @@
// @dart = 2.8 // @dart = 2.8
import 'dart:typed_data';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import '../painting/mocks_for_image_cache.dart'; import '../painting/image_data.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
Future<void> pumpWidgetWithBoilerplate(WidgetTester tester, Widget widget) async { Future<void> pumpWidgetWithBoilerplate(WidgetTester tester, Widget widget) async {
...@@ -27,14 +29,15 @@ Future<void> pumpWidgetWithBoilerplate(WidgetTester tester, Widget widget) async ...@@ -27,14 +29,15 @@ Future<void> pumpWidgetWithBoilerplate(WidgetTester tester, Widget widget) async
); );
} }
void main() { Future<void> main() async {
testWidgets('Need at least 2 tabs', (WidgetTester tester) async { testWidgets('Need at least 2 tabs', (WidgetTester tester) async {
try { try {
await pumpWidgetWithBoilerplate(tester, CupertinoTabBar( await pumpWidgetWithBoilerplate(tester, CupertinoTabBar(
items: const <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 1'), title: const Text('Tab 1'),
), ),
], ],
)); ));
...@@ -49,14 +52,14 @@ void main() { ...@@ -49,14 +52,14 @@ void main() {
await pumpWidgetWithBoilerplate(tester, MediaQuery( await pumpWidgetWithBoilerplate(tester, MediaQuery(
data: const MediaQueryData(), data: const MediaQueryData(),
child: CupertinoTabBar( child: CupertinoTabBar(
items: const <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 1'), title: const Text('Tab 1'),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 2'), title: const Text('Tab 2'),
), ),
], ],
currentIndex: 1, currentIndex: 1,
...@@ -83,13 +86,13 @@ void main() { ...@@ -83,13 +86,13 @@ void main() {
await pumpWidgetWithBoilerplate(tester, MediaQuery( await pumpWidgetWithBoilerplate(tester, MediaQuery(
data: const MediaQueryData(), data: const MediaQueryData(),
child: CupertinoTabBar( child: CupertinoTabBar(
items: const <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
label: 'Tab 1', label: 'Tab 1',
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
label: 'Tab 2', label: 'Tab 2',
), ),
], ],
...@@ -115,14 +118,14 @@ void main() { ...@@ -115,14 +118,14 @@ void main() {
await pumpWidgetWithBoilerplate(tester, MediaQuery( await pumpWidgetWithBoilerplate(tester, MediaQuery(
data: const MediaQueryData(), data: const MediaQueryData(),
child: CupertinoTabBar( child: CupertinoTabBar(
items: const <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 1'), title: const Text('Tab 1'),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 2'), title: const Text('Tab 2'),
), ),
], ],
currentIndex: 1, currentIndex: 1,
...@@ -156,14 +159,14 @@ void main() { ...@@ -156,14 +159,14 @@ void main() {
await pumpWidgetWithBoilerplate(tester, MediaQuery( await pumpWidgetWithBoilerplate(tester, MediaQuery(
data: const MediaQueryData(platformBrightness: Brightness.dark), data: const MediaQueryData(platformBrightness: Brightness.dark),
child: CupertinoTabBar( child: CupertinoTabBar(
items: const <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 1'), title: const Text('Tab 1'),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 2'), title: const Text('Tab 2'),
), ),
], ],
currentIndex: 1, currentIndex: 1,
...@@ -193,14 +196,14 @@ void main() { ...@@ -193,14 +196,14 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoTabBar( home: CupertinoTabBar(
items: const <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 1'), title: const Text('Tab 1'),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 2'), title: const Text('Tab 2'),
), ),
], ],
currentIndex: 1, currentIndex: 1,
...@@ -224,14 +227,14 @@ void main() { ...@@ -224,14 +227,14 @@ void main() {
CupertinoApp( CupertinoApp(
theme: const CupertinoThemeData(brightness: Brightness.dark), theme: const CupertinoThemeData(brightness: Brightness.dark),
home: CupertinoTabBar( home: CupertinoTabBar(
items: const <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 1'), title: const Text('Tab 1'),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 2'), title: const Text('Tab 2'),
), ),
], ],
currentIndex: 1, currentIndex: 1,
...@@ -254,21 +257,21 @@ void main() { ...@@ -254,21 +257,21 @@ void main() {
}); });
testWidgets('Use active icon', (WidgetTester tester) async { testWidgets('Use active icon', (WidgetTester tester) async {
const TestImageProvider activeIcon = TestImageProvider(16, 16); final MemoryImage activeIcon = MemoryImage(Uint8List.fromList(kBlueSquare));
const TestImageProvider inactiveIcon = TestImageProvider(24, 24); final MemoryImage inactiveIcon = MemoryImage(Uint8List.fromList(kTransparentImage));
await pumpWidgetWithBoilerplate(tester, MediaQuery( await pumpWidgetWithBoilerplate(tester, MediaQuery(
data: const MediaQueryData(), data: const MediaQueryData(),
child: CupertinoTabBar( child: CupertinoTabBar(
items: const <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 1'), title: const Text('Tab 1'),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(inactiveIcon), icon: ImageIcon(inactiveIcon),
activeIcon: ImageIcon(activeIcon), activeIcon: ImageIcon(activeIcon),
title: Text('Tab 2'), title: const Text('Tab 2'),
), ),
], ],
currentIndex: 1, currentIndex: 1,
...@@ -288,14 +291,14 @@ void main() { ...@@ -288,14 +291,14 @@ void main() {
testWidgets('Adjusts height to account for bottom padding', (WidgetTester tester) async { testWidgets('Adjusts height to account for bottom padding', (WidgetTester tester) async {
final CupertinoTabBar tabBar = CupertinoTabBar( final CupertinoTabBar tabBar = CupertinoTabBar(
items: const <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Aka'), title: const Text('Aka'),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Shiro'), title: const Text('Shiro'),
), ),
], ],
); );
...@@ -329,14 +332,14 @@ void main() { ...@@ -329,14 +332,14 @@ void main() {
await pumpWidgetWithBoilerplate(tester, MediaQuery( await pumpWidgetWithBoilerplate(tester, MediaQuery(
data: const MediaQueryData(), data: const MediaQueryData(),
child: CupertinoTabBar( child: CupertinoTabBar(
items: const <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 1'), title: const Text('Tab 1'),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 2'), title: const Text('Tab 2'),
), ),
], ],
), ),
...@@ -347,14 +350,14 @@ void main() { ...@@ -347,14 +350,14 @@ void main() {
await pumpWidgetWithBoilerplate(tester, MediaQuery( await pumpWidgetWithBoilerplate(tester, MediaQuery(
data: const MediaQueryData(), data: const MediaQueryData(),
child: CupertinoTabBar( child: CupertinoTabBar(
items: const <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 1'), title: const Text('Tab 1'),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 2'), title: const Text('Tab 2'),
), ),
], ],
backgroundColor: const Color(0xFFFFFFFF), // Opaque white. backgroundColor: const Color(0xFFFFFFFF), // Opaque white.
...@@ -370,14 +373,14 @@ void main() { ...@@ -370,14 +373,14 @@ void main() {
await pumpWidgetWithBoilerplate(tester, MediaQuery( await pumpWidgetWithBoilerplate(tester, MediaQuery(
data: const MediaQueryData(), data: const MediaQueryData(),
child: CupertinoTabBar( child: CupertinoTabBar(
items: const <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 1'), title: const Text('Tab 1'),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 2'), title: const Text('Tab 2'),
), ),
], ],
currentIndex: 1, currentIndex: 1,
...@@ -395,14 +398,14 @@ void main() { ...@@ -395,14 +398,14 @@ void main() {
await pumpWidgetWithBoilerplate(tester, MediaQuery( await pumpWidgetWithBoilerplate(tester, MediaQuery(
data: const MediaQueryData(), data: const MediaQueryData(),
child: CupertinoTabBar( child: CupertinoTabBar(
items: const <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 1'), title: const Text('Tab 1'),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 2'), title: const Text('Tab 2'),
), ),
], ],
), ),
...@@ -425,7 +428,7 @@ void main() { ...@@ -425,7 +428,7 @@ void main() {
}); });
testWidgets('Title of items should be nullable', (WidgetTester tester) async { testWidgets('Title of items should be nullable', (WidgetTester tester) async {
const TestImageProvider iconProvider = TestImageProvider(16, 16); final MemoryImage iconProvider = MemoryImage(Uint8List.fromList(kTransparentImage));
final List<int> itemsTapped = <int>[]; final List<int> itemsTapped = <int>[];
await pumpWidgetWithBoilerplate( await pumpWidgetWithBoilerplate(
...@@ -433,12 +436,12 @@ void main() { ...@@ -433,12 +436,12 @@ void main() {
MediaQuery( MediaQuery(
data: const MediaQueryData(), data: const MediaQueryData(),
child: CupertinoTabBar( child: CupertinoTabBar(
items: const <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon( icon: ImageIcon(
TestImageProvider(24, 24), MemoryImage(Uint8List.fromList(kTransparentImage)),
), ),
title: Text('Tab 1'), title: const Text('Tab 1'),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon( icon: ImageIcon(
...@@ -465,18 +468,18 @@ void main() { ...@@ -465,18 +468,18 @@ void main() {
MediaQuery( MediaQuery(
data: const MediaQueryData(), data: const MediaQueryData(),
child: CupertinoTabBar( child: CupertinoTabBar(
items: const <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon( icon: ImageIcon(
TestImageProvider(24, 24), MemoryImage(Uint8List.fromList(kTransparentImage)),
), ),
title: Text('Tab 1'), title: const Text('Tab 1'),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon( icon: ImageIcon(
TestImageProvider(24, 24), MemoryImage(Uint8List.fromList(kTransparentImage)),
), ),
title: Text('Tab 2'), title: const Text('Tab 2'),
), ),
], ],
), ),
...@@ -491,18 +494,18 @@ void main() { ...@@ -491,18 +494,18 @@ void main() {
MediaQuery( MediaQuery(
data: const MediaQueryData(), data: const MediaQueryData(),
child: CupertinoTabBar( child: CupertinoTabBar(
items: const <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon( icon: ImageIcon(
TestImageProvider(24, 24), MemoryImage(Uint8List.fromList(kTransparentImage)),
), ),
title: Text('Tab 1'), title: const Text('Tab 1'),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon( icon: ImageIcon(
TestImageProvider(24, 24), MemoryImage(Uint8List.fromList(kTransparentImage)),
), ),
title: Text('Tab 2'), title: const Text('Tab 2'),
), ),
], ],
backgroundColor: const Color(0xFFFFFFFF), // Opaque white. backgroundColor: const Color(0xFFFFFFFF), // Opaque white.
......
...@@ -4,11 +4,13 @@ ...@@ -4,11 +4,13 @@
// @dart = 2.8 // @dart = 2.8
import 'dart:typed_data';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import '../../painting/mocks_for_image_cache.dart'; import '../../painting/image_data.dart';
List<int> selectedTabs; List<int> selectedTabs;
...@@ -287,7 +289,7 @@ void main() { ...@@ -287,7 +289,7 @@ void main() {
tabBar: CupertinoTabBar( tabBar: CupertinoTabBar(
items: List<BottomNavigationBarItem>.generate( items: List<BottomNavigationBarItem>.generate(
10, 10,
(int i) => BottomNavigationBarItem(icon: const ImageIcon(TestImageProvider(24, 23)), title: Text('$i')), (int i) => BottomNavigationBarItem(icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))), title: Text('$i')),
), ),
), ),
tabBuilder: (BuildContext context, int index) => const Text('content'), tabBuilder: (BuildContext context, int index) => const Text('content'),
...@@ -322,14 +324,14 @@ void main() { ...@@ -322,14 +324,14 @@ void main() {
CupertinoTabBar _buildTabBar({ int selectedTab = 0 }) { CupertinoTabBar _buildTabBar({ int selectedTab = 0 }) {
return CupertinoTabBar( return CupertinoTabBar(
items: const <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 1'), title: const Text('Tab 1'),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 2'), title: const Text('Tab 2'),
), ),
], ],
currentIndex: selectedTab, currentIndex: selectedTab,
......
...@@ -4,10 +4,12 @@ ...@@ -4,10 +4,12 @@
// @dart = 2.8 // @dart = 2.8
import 'dart:typed_data';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import '../painting/mocks_for_image_cache.dart'; import '../painting/image_data.dart';
import '../rendering/mock_canvas.dart'; import '../rendering/mock_canvas.dart';
/// Integration tests testing both [CupertinoPageScaffold] and [CupertinoTabScaffold]. /// Integration tests testing both [CupertinoPageScaffold] and [CupertinoTabScaffold].
...@@ -208,14 +210,14 @@ void main() { ...@@ -208,14 +210,14 @@ void main() {
home: CupertinoTabScaffold( home: CupertinoTabScaffold(
tabBar: CupertinoTabBar( tabBar: CupertinoTabBar(
backgroundColor: CupertinoColors.white, backgroundColor: CupertinoColors.white,
items: const <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 1'), title: const Text('Tab 1'),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 2'), title: const Text('Tab 2'),
), ),
], ],
), ),
...@@ -248,14 +250,14 @@ void main() { ...@@ -248,14 +250,14 @@ void main() {
), ),
child: CupertinoTabScaffold( child: CupertinoTabScaffold(
tabBar: CupertinoTabBar( tabBar: CupertinoTabBar(
items: const <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 1'), title: const Text('Tab 1'),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 2'), title: const Text('Tab 2'),
), ),
], ],
), ),
...@@ -298,14 +300,14 @@ void main() { ...@@ -298,14 +300,14 @@ void main() {
CupertinoApp( CupertinoApp(
home: CupertinoTabScaffold( home: CupertinoTabScaffold(
tabBar: CupertinoTabBar( tabBar: CupertinoTabBar(
items: const <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 1'), title: const Text('Tab 1'),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 2'), title: const Text('Tab 2'),
), ),
], ],
), ),
......
...@@ -4,10 +4,12 @@ ...@@ -4,10 +4,12 @@
// @dart = 2.8 // @dart = 2.8
import 'dart:typed_data';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import '../painting/mocks_for_image_cache.dart'; import '../painting/image_data.dart';
import '../rendering/rendering_tester.dart'; import '../rendering/rendering_tester.dart';
List<int> selectedTabs; List<int> selectedTabs;
...@@ -44,7 +46,7 @@ void main() { ...@@ -44,7 +46,7 @@ void main() {
BottomNavigationBarItem tabGenerator(int index) { BottomNavigationBarItem tabGenerator(int index) {
return BottomNavigationBarItem( return BottomNavigationBarItem(
icon: const ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab ${index + 1}'), title: Text('Tab ${index + 1}'),
); );
} }
...@@ -1081,7 +1083,7 @@ void main() { ...@@ -1081,7 +1083,7 @@ void main() {
tabBar: CupertinoTabBar( tabBar: CupertinoTabBar(
items: List<BottomNavigationBarItem>.generate( items: List<BottomNavigationBarItem>.generate(
10, 10,
(int i) => BottomNavigationBarItem(icon: const ImageIcon(TestImageProvider(24, 23)), title: Text('$i')), (int i) => BottomNavigationBarItem(icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))), title: Text('$i')),
), ),
), ),
tabBuilder: (BuildContext context, int index) => const Text('content'), tabBuilder: (BuildContext context, int index) => const Text('content'),
...@@ -1116,14 +1118,14 @@ void main() { ...@@ -1116,14 +1118,14 @@ void main() {
CupertinoTabBar _buildTabBar({ int selectedTab = 0 }) { CupertinoTabBar _buildTabBar({ int selectedTab = 0 }) {
return CupertinoTabBar( return CupertinoTabBar(
items: const <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 1'), title: const Text('Tab 1'),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: ImageIcon(TestImageProvider(24, 24)), icon: ImageIcon(MemoryImage(Uint8List.fromList(kTransparentImage))),
title: Text('Tab 2'), title: const Text('Tab 2'),
), ),
], ],
currentIndex: selectedTab, currentIndex: selectedTab,
......
...@@ -31,7 +31,9 @@ class TestImageInfo implements ImageInfo { ...@@ -31,7 +31,9 @@ class TestImageInfo implements ImageInfo {
} }
class TestImageProvider extends ImageProvider<int> { class TestImageProvider extends ImageProvider<int> {
const TestImageProvider(this.key, this.imageValue, { this.image }); const TestImageProvider(this.key, this.imageValue, { this.image = const TestImage() })
: assert(image != null);
final int key; final int key;
final int imageValue; final int imageValue;
final ui.Image image; final ui.Image image;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment