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
57b69524
Unverified
Commit
57b69524
authored
Aug 27, 2020
by
Matt Carroll
Committed by
GitHub
Aug 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for lerpDuration() (#64668)
parent
fbc15384
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
0 deletions
+64
-0
basic_types.dart
packages/flutter/lib/src/foundation/basic_types.dart
+7
-0
basic_types_test.dart
packages/flutter/test/foundation/basic_types_test.dart
+57
-0
No files found.
packages/flutter/lib/src/foundation/basic_types.dart
View file @
57b69524
...
...
@@ -238,3 +238,10 @@ class Factory<T> {
return
'Factory(type:
$type
)'
;
}
}
/// Linearly interpolate between two `Duration`s.
Duration
lerpDuration
(
Duration
a
,
Duration
b
,
double
t
)
{
return
Duration
(
microseconds:
(
a
.
inMicroseconds
+
(
b
.
inMicroseconds
-
a
.
inMicroseconds
)
*
t
).
round
(),
);
}
\ No newline at end of file
packages/flutter/test/foundation/basic_types_test.dart
0 → 100644
View file @
57b69524
// 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/src/foundation/basic_types.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
group
(
'lerp Duration'
,
()
{
test
(
'linearly interpolates between positive Durations'
,
()
{
expect
(
lerpDuration
(
const
Duration
(
seconds:
1
),
const
Duration
(
seconds:
2
),
0.5
),
const
Duration
(
milliseconds:
1500
),
);
});
test
(
'linearly interpolates between negative Durations'
,
()
{
expect
(
lerpDuration
(
const
Duration
(
seconds:
-
1
),
const
Duration
(
seconds:
-
2
),
0.5
),
const
Duration
(
milliseconds:
-
1500
),
);
});
test
(
'linearly interpolates between positive and negative Durations'
,
()
{
expect
(
lerpDuration
(
const
Duration
(
seconds:
-
1
),
const
Duration
(
seconds:
2
),
0.5
),
const
Duration
(
milliseconds:
500
),
);
});
test
(
'starts at first Duration'
,
()
{
expect
(
lerpDuration
(
const
Duration
(
seconds:
1
),
const
Duration
(
seconds:
2
),
0
),
const
Duration
(
seconds:
1
),
);
});
test
(
'ends at second Duration'
,
()
{
expect
(
lerpDuration
(
const
Duration
(
seconds:
1
),
const
Duration
(
seconds:
2
),
1
),
const
Duration
(
seconds:
2
),
);
});
test
(
'time values beyond 1.0 have a multiplier effect'
,
()
{
expect
(
lerpDuration
(
const
Duration
(
seconds:
1
),
const
Duration
(
seconds:
2
),
5
),
const
Duration
(
seconds:
6
),
);
expect
(
lerpDuration
(
const
Duration
(
seconds:
-
1
),
const
Duration
(
seconds:
-
2
),
5
),
const
Duration
(
seconds:
-
6
),
);
});
});
}
\ No newline at end of file
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