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
b1f88a65
Unverified
Commit
b1f88a65
authored
Apr 28, 2022
by
Taha Tesser
Committed by
GitHub
Apr 28, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
`ReorderableListView`: fix broken dartpad example & update examples, add tests (#102723)
parent
b333fe2e
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
181 additions
and
49 deletions
+181
-49
reorderable_list_view.0.dart
...ib/material/reorderable_list/reorderable_list_view.0.dart
+9
-12
reorderable_list_view.1.dart
...ib/material/reorderable_list/reorderable_list_view.1.dart
+9
-12
reorderable_list_view.build_default_drag_handles.0.dart
...t/reorderable_list_view.build_default_drag_handles.0.dart
+9
-12
reorderable_list_view.reorderable_list_view_builder.0.dart
...eorderable_list_view.reorderable_list_view_builder.0.dart
+9
-12
reorderable_list_view.0_test.dart
...i/test/reorderable_list/reorderable_list_view.0_test.dart
+36
-0
reorderable_list_view.1_test.dart
...i/test/reorderable_list/reorderable_list_view.1_test.dart
+36
-0
reorderable_list_view.build_default_drag_handles.0_test.dart
...rderable_list_view.build_default_drag_handles.0_test.dart
+36
-0
reorderable_list_view.reorderable_list_view_builder.0_test.dart
...rable_list_view.reorderable_list_view_builder.0_test.dart
+36
-0
reorderable_list.dart
packages/flutter/lib/src/material/reorderable_list.dart
+1
-1
No files found.
examples/api/lib/material/reorderable_list/reorderable_list_view.0.dart
View file @
b1f88a65
...
...
@@ -6,33 +6,30 @@
import
'package:flutter/material.dart'
;
void
main
(
)
=>
runApp
(
const
My
App
());
void
main
(
)
=>
runApp
(
const
Reorderable
App
());
class
MyApp
extends
StatelessWidget
{
const
MyApp
({
Key
?
key
})
:
super
(
key:
key
);
static
const
String
_title
=
'Flutter Code Sample'
;
class
ReorderableApp
extends
StatelessWidget
{
const
ReorderableApp
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
title:
_title
,
home:
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
_title
)),
body:
const
MyStatefulWidget
(),
appBar:
AppBar
(
title:
const
Text
(
'ReorderableListView Sample'
)),
body:
const
ReorderableExample
(),
),
);
}
}
class
MyStatefulWidget
extends
StatefulWidget
{
const
MyStatefulWidget
({
Key
?
key
})
:
super
(
key:
key
);
class
ReorderableExample
extends
StatefulWidget
{
const
ReorderableExample
({
Key
?
key
})
:
super
(
key:
key
);
@override
State
<
MyStatefulWidget
>
createState
()
=>
_MyStatefulWidgetState
();
State
<
ReorderableExample
>
createState
()
=>
_MyStatefulWidgetState
();
}
class
_MyStatefulWidgetState
extends
State
<
MyStatefulWidget
>
{
class
_MyStatefulWidgetState
extends
State
<
ReorderableExample
>
{
final
List
<
int
>
_items
=
List
<
int
>.
generate
(
50
,
(
int
index
)
=>
index
);
@override
...
...
examples/api/lib/material/reorderable_list/reorderable_list_view.1.dart
View file @
b1f88a65
...
...
@@ -7,33 +7,30 @@ import 'dart:ui';
import
'package:flutter/material.dart'
;
void
main
(
)
=>
runApp
(
const
My
App
());
void
main
(
)
=>
runApp
(
const
Reorderable
App
());
class
MyApp
extends
StatelessWidget
{
const
MyApp
({
Key
?
key
})
:
super
(
key:
key
);
static
const
String
_title
=
'Flutter Code Sample'
;
class
ReorderableApp
extends
StatelessWidget
{
const
ReorderableApp
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
title:
_title
,
home:
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
_title
)),
body:
const
MyStatefulWidget
(),
appBar:
AppBar
(
title:
const
Text
(
'ReorderableListView Sample'
)),
body:
const
ReorderableExample
(),
),
);
}
}
class
MyStatefulWidget
extends
StatefulWidget
{
const
MyStatefulWidget
({
Key
?
key
})
:
super
(
key:
key
);
class
ReorderableExample
extends
StatefulWidget
{
const
ReorderableExample
({
Key
?
key
})
:
super
(
key:
key
);
@override
State
<
MyStatefulWidget
>
createState
()
=>
_MyStatefulWidget
State
();
State
<
ReorderableExample
>
createState
()
=>
_ReorderableExample
State
();
}
class
_
MyStatefulWidgetState
extends
State
<
MyStatefulWidget
>
{
class
_
ReorderableExampleState
extends
State
<
ReorderableExample
>
{
final
List
<
int
>
_items
=
List
<
int
>.
generate
(
50
,
(
int
index
)
=>
index
);
@override
...
...
examples/api/lib/material/reorderable_list/reorderable_list_view.build_default_drag_handles.0.dart
View file @
b1f88a65
...
...
@@ -6,33 +6,30 @@
import
'package:flutter/material.dart'
;
void
main
(
)
=>
runApp
(
const
My
App
());
void
main
(
)
=>
runApp
(
const
Reorderable
App
());
class
MyApp
extends
StatelessWidget
{
const
MyApp
({
Key
?
key
})
:
super
(
key:
key
);
static
const
String
_title
=
'Flutter Code Sample'
;
class
ReorderableApp
extends
StatelessWidget
{
const
ReorderableApp
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
title:
_title
,
home:
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
_title
)),
body:
const
MyStatefulWidget
(),
appBar:
AppBar
(
title:
const
Text
(
'ReorderableListView Sample'
)),
body:
const
ReorderableExample
(),
),
);
}
}
class
MyStatefulWidget
extends
StatefulWidget
{
const
MyStatefulWidget
({
Key
?
key
})
:
super
(
key:
key
);
class
ReorderableExample
extends
StatefulWidget
{
const
ReorderableExample
({
Key
?
key
})
:
super
(
key:
key
);
@override
State
<
MyStatefulWidget
>
createState
()
=>
_MyStatefulWidget
State
();
State
<
ReorderableExample
>
createState
()
=>
_ReorderableExample
State
();
}
class
_
MyStatefulWidgetState
extends
State
<
MyStatefulWidget
>
{
class
_
ReorderableExampleState
extends
State
<
ReorderableExample
>
{
final
List
<
int
>
_items
=
List
<
int
>.
generate
(
50
,
(
int
index
)
=>
index
);
@override
...
...
examples/api/lib/material/reorderable_list/reorderable_list_view.reorderable_list_view_builder.0.dart
View file @
b1f88a65
...
...
@@ -6,35 +6,32 @@
import
'package:flutter/material.dart'
;
void
main
(
)
=>
runApp
(
const
My
App
());
void
main
(
)
=>
runApp
(
const
Reorderable
App
());
class
MyApp
extends
StatelessWidget
{
const
MyApp
({
Key
?
key
})
:
super
(
key:
key
);
static
const
String
_title
=
'Flutter Code Sample'
;
class
ReorderableApp
extends
StatelessWidget
{
const
ReorderableApp
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
title:
_title
,
home:
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
_title
)),
appBar:
AppBar
(
title:
const
Text
(
'ReorderableListView Sample'
)),
body:
const
Center
(
child:
MyStatefulWidget
(),
child:
ReorderableExample
(),
),
),
);
}
}
class
MyStatefulWidget
extends
StatefulWidget
{
const
MyStatefulWidget
({
Key
?
key
})
:
super
(
key:
key
);
class
ReorderableExample
extends
StatefulWidget
{
const
ReorderableExample
({
Key
?
key
})
:
super
(
key:
key
);
@override
State
<
MyStatefulWidget
>
createState
()
=>
_MyStatefulWidget
State
();
State
<
ReorderableExample
>
createState
()
=>
_ReorderableExample
State
();
}
class
_
MyStatefulWidgetState
extends
State
<
MyStatefulWidget
>
{
class
_
ReorderableExampleState
extends
State
<
ReorderableExample
>
{
final
List
<
int
>
_items
=
List
<
int
>.
generate
(
50
,
(
int
index
)
=>
index
);
@override
...
...
examples/api/test/reorderable_list/reorderable_list_view.0_test.dart
0 → 100644
View file @
b1f88a65
// 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/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_api_samples/material/reorderable_list/reorderable_list_view.0.dart'
as
example
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
Future
<
void
>
longPressDrag
(
WidgetTester
tester
,
Offset
start
,
Offset
end
)
async
{
final
TestGesture
drag
=
await
tester
.
startGesture
(
start
);
await
tester
.
pump
(
kLongPressTimeout
+
kPressTimeout
);
await
drag
.
moveTo
(
end
);
await
tester
.
pump
(
kPressTimeout
);
await
drag
.
up
();
}
testWidgets
(
'Reorder list item'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
example
.
ReorderableApp
(),
),
);
expect
(
tester
.
getCenter
(
find
.
text
(
'Item 3'
)).
dy
,
252.0
);
await
longPressDrag
(
tester
,
tester
.
getCenter
(
find
.
text
(
'Item 3'
)),
tester
.
getCenter
(
find
.
text
(
'Item 2'
)),
);
await
tester
.
pumpAndSettle
();
expect
(
tester
.
getCenter
(
find
.
text
(
'Item 3'
)).
dy
,
196.0
);
});
}
examples/api/test/reorderable_list/reorderable_list_view.1_test.dart
0 → 100644
View file @
b1f88a65
// 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/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_api_samples/material/reorderable_list/reorderable_list_view.1.dart'
as
example
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
Future
<
void
>
longPressDrag
(
WidgetTester
tester
,
Offset
start
,
Offset
end
)
async
{
final
TestGesture
drag
=
await
tester
.
startGesture
(
start
);
await
tester
.
pump
(
kLongPressTimeout
+
kPressTimeout
);
await
drag
.
moveTo
(
end
);
await
tester
.
pump
(
kPressTimeout
);
await
drag
.
up
();
}
testWidgets
(
'Reorder list item'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
example
.
ReorderableApp
(),
),
);
expect
(
tester
.
getCenter
(
find
.
text
(
'Item 3'
)).
dy
,
252.0
);
await
longPressDrag
(
tester
,
tester
.
getCenter
(
find
.
text
(
'Item 3'
)),
tester
.
getCenter
(
find
.
text
(
'Item 2'
)),
);
await
tester
.
pumpAndSettle
();
expect
(
tester
.
getCenter
(
find
.
text
(
'Item 3'
)).
dy
,
196.0
);
});
}
examples/api/test/reorderable_list/reorderable_list_view.build_default_drag_handles.0_test.dart
0 → 100644
View file @
b1f88a65
// 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/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_api_samples/material/reorderable_list/reorderable_list_view.build_default_drag_handles.0.dart'
as
example
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
Future
<
void
>
longPressDrag
(
WidgetTester
tester
,
Offset
start
,
Offset
end
)
async
{
final
TestGesture
drag
=
await
tester
.
startGesture
(
start
);
await
tester
.
pump
(
kLongPressTimeout
+
kPressTimeout
);
await
drag
.
moveTo
(
end
);
await
tester
.
pump
(
kPressTimeout
);
await
drag
.
up
();
}
testWidgets
(
'Reorder list item'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
example
.
ReorderableApp
(),
),
);
expect
(
tester
.
getCenter
(
find
.
text
(
'Item 3'
)).
dy
,
280.0
);
await
longPressDrag
(
tester
,
tester
.
getCenter
(
find
.
text
(
'Item 3'
)),
tester
.
getCenter
(
find
.
text
(
'Item 2'
)),
);
await
tester
.
pumpAndSettle
();
expect
(
tester
.
getCenter
(
find
.
text
(
'Item 3'
)).
dy
,
216.0
);
});
}
examples/api/test/reorderable_list/reorderable_list_view.reorderable_list_view_builder.0_test.dart
0 → 100644
View file @
b1f88a65
// 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/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_api_samples/material/reorderable_list/reorderable_list_view.reorderable_list_view_builder.0.dart'
as
example
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
Future
<
void
>
longPressDrag
(
WidgetTester
tester
,
Offset
start
,
Offset
end
)
async
{
final
TestGesture
drag
=
await
tester
.
startGesture
(
start
);
await
tester
.
pump
(
kLongPressTimeout
+
kPressTimeout
);
await
drag
.
moveTo
(
end
);
await
tester
.
pump
(
kPressTimeout
);
await
drag
.
up
();
}
testWidgets
(
'Reorder list item'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
example
.
ReorderableApp
(),
),
);
expect
(
tester
.
getCenter
(
find
.
text
(
'Item 3'
)).
dy
,
252.0
);
await
longPressDrag
(
tester
,
tester
.
getCenter
(
find
.
text
(
'Item 3'
)),
tester
.
getCenter
(
find
.
text
(
'Item 2'
)),
);
await
tester
.
pumpAndSettle
();
expect
(
tester
.
getCenter
(
find
.
text
(
'Item 3'
)).
dy
,
196.0
);
});
}
packages/flutter/lib/src/material/reorderable_list.dart
View file @
b1f88a65
...
...
@@ -38,7 +38,7 @@ import 'theme.dart';
///
/// This example demonstrates using the [proxyDecorator] callback to customize
/// the appearance of a list item while it's being dragged.
/// {@tool
snippet
}
/// {@tool
dartpad
}
///
/// While a drag is underway, the widget returned by the [proxyDecorator]
/// serves as a "proxy" (a substitute) for the item in the list. The proxy is
...
...
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