Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
49e16867
Unverified
Commit
49e16867
authored
Sep 22, 2023
by
Polina Cherkasova
Committed by
GitHub
Sep 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TabController should dispatch creation in constructor. (#133952)
parent
c00e9798
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
3 deletions
+31
-3
tab_controller.dart
packages/flutter/lib/src/material/tab_controller.dart
+6
-1
tabs.dart
packages/flutter/lib/src/material/tabs.dart
+1
-0
page_selector_test.dart
packages/flutter/test/material/page_selector_test.dart
+6
-0
tab_controller_test.dart
packages/flutter/test/material/tab_controller_test.dart
+16
-0
framework_test.dart
packages/flutter/test/widgets/framework_test.dart
+1
-1
scrollable_test.dart
packages/flutter/test/widgets/scrollable_test.dart
+1
-1
No files found.
packages/flutter/lib/src/material/tab_controller.dart
View file @
49e16867
...
...
@@ -6,6 +6,7 @@ import 'dart:math' as math;
import
'package:flutter/widgets.dart'
;
import
'../foundation/memory_allocations.dart'
;
import
'constants.dart'
;
// Examples can assume:
...
...
@@ -114,7 +115,11 @@ class TabController extends ChangeNotifier {
_animationController
=
AnimationController
.
unbounded
(
value:
initialIndex
.
toDouble
(),
vsync:
vsync
,
);
)
{
if
(
kFlutterMemoryAllocationsEnabled
)
{
ChangeNotifier
.
maybeDispatchObjectCreation
(
this
);
}
}
// Private constructor used by `_copyWith`. This allows a new TabController to
// be created without having to create a new animationController.
...
...
packages/flutter/lib/src/material/tabs.dart
View file @
49e16867
...
...
@@ -1380,6 +1380,7 @@ class _TabBarState extends State<TabBar> {
_controller
!.
removeListener
(
_handleTabControllerTick
);
}
_controller
=
null
;
_scrollController
?.
dispose
();
// We don't own the _controller Animation, so it's not disposed here.
super
.
dispose
();
}
...
...
packages/flutter/test/material/page_selector_test.dart
View file @
49e16867
...
...
@@ -70,6 +70,7 @@ void main() {
vsync:
const
TestVSync
(),
length:
3
,
);
addTearDown
(
tabController
.
dispose
);
await
tester
.
pumpWidget
(
buildFrame
(
tabController
));
expect
(
tabController
.
index
,
0
);
...
...
@@ -91,6 +92,7 @@ void main() {
vsync:
const
TestVSync
(),
length:
3
,
);
addTearDown
(
tabController
.
dispose
);
await
tester
.
pumpWidget
(
buildFrame
(
tabController
));
expect
(
tabController
.
index
,
0
);
...
...
@@ -135,6 +137,7 @@ void main() {
initialIndex:
1
,
length:
3
,
);
addTearDown
(
tabController
.
dispose
);
await
tester
.
pumpWidget
(
buildFrame
(
tabController
));
expect
(
tabController
.
index
,
1
);
...
...
@@ -196,6 +199,7 @@ void main() {
initialIndex:
1
,
length:
3
,
);
addTearDown
(
tabController
.
dispose
);
await
tester
.
pumpWidget
(
buildFrame
(
tabController
,
color:
kRed
,
selectedColor:
kBlue
));
expect
(
tabController
.
index
,
1
);
...
...
@@ -212,6 +216,7 @@ void main() {
initialIndex:
1
,
length:
3
,
);
addTearDown
(
tabController
.
dispose
);
await
tester
.
pumpWidget
(
buildFrame
(
tabController
,
indicatorSize:
16.0
));
final
Iterable
<
Element
>
indicatorElements
=
find
.
descendant
(
...
...
@@ -233,6 +238,7 @@ void main() {
initialIndex:
1
,
length:
3
,
);
addTearDown
(
tabController
.
dispose
);
Iterable
<
TabPageSelectorIndicator
>
indicators
;
...
...
packages/flutter/test/material/tab_controller_test.dart
0 → 100644
View file @
49e16867
// 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
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'
;
void
main
(
)
{
testWidgetsWithLeakTracking
(
'
$TabController
dispatches creation in constructor.'
,
(
WidgetTester
widgetTester
)
async
{
await
expectLater
(
await
memoryEvents
(()
async
=>
TabController
(
length:
1
,
vsync:
const
TestVSync
()).
dispose
(),
TabController
),
areCreateAndDispose
,
);
});
}
packages/flutter/test/widgets/framework_test.dart
View file @
49e16867
...
...
@@ -1062,7 +1062,7 @@ void main() {
element
.
createChild
(
0
,
after:
null
);
});
testWidgets
WithLeakTracking
(
'GlobalKey - re-attach child to new parents, and the old parent is deactivated(unmounted)'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'GlobalKey - re-attach child to new parents, and the old parent is deactivated(unmounted)'
,
(
WidgetTester
tester
)
async
{
// This is a regression test for https://github.com/flutter/flutter/issues/62055
const
Key
key1
=
GlobalObjectKey
(
'key1'
);
const
Key
key2
=
GlobalObjectKey
(
'key2'
);
...
...
packages/flutter/test/widgets/scrollable_test.dart
View file @
49e16867
...
...
@@ -861,7 +861,7 @@ void main() {
expect
(
targetMidLeftPage1
,
findsOneWidget
);
});
testWidgets
WithLeakTracking
(
'ensureVisible does not move TabViews'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'ensureVisible does not move TabViews'
,
(
WidgetTester
tester
)
async
{
final
TickerProvider
vsync
=
TestTickerProvider
();
final
TabController
controller
=
TabController
(
length:
3
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment