text
stringlengths
1
372
final backgroundOffset =
localToGlobal(size.centerLeft(Offset.zero), ancestor: scrollableBox);
// determine the percent position of this list item within the
// scrollable area.
final scrollFraction =
(backgroundoffset.dy / viewportDimension).clamp(0.0, 1.0);
// calculate the vertical alignment of the background
// based on the scroll percent.
final verticalAlignment = alignment(0.0, scrollFraction * 2 - 1);
// convert the background alignment into a pixel offset for
// painting purposes.
final background = child!;
final backgroundSize = background.size;
final listItemSize = size;
final childRect =
verticalAlignment.inscribe(backgroundSize, offset.zero & listItemSize);
// paint the background.
context.paintChild(
background,
(background.parentdata as ParallaxParentData).offset +
offset +
offset(0.0, childRect.top));
}
}
class location {
const location({
required this.name,
required this.place,
required this.imageUrl,
});
final string name;
final string place;
final string imageUrl;
}
const urlPrefix =
'https://docs.flutter.dev/cookbook/img-files/effects/parallax';
const locations = [
location(
name: 'mount rushmore',
place: 'u.s.a',
imageUrl: '$urlprefix/01-mount-rushmore.jpg',
),
location(
name: 'gardens by the bay',
place: 'singapore',
imageUrl: '$urlprefix/02-singapore.jpg',
),
location(
name: 'machu picchu',
place: 'peru',
imageUrl: '$urlprefix/03-machu-picchu.jpg',
),
location(
name: 'vitznau',
place: 'switzerland',
imageUrl: '$urlprefix/04-vitznau.jpg',
),
location(
name: 'bali',
place: 'indonesia',
imageUrl: '$urlprefix/05-bali.jpg',
),
location(
name: 'mexico city',
place: 'mexico',
imageUrl: '$urlprefix/06-mexico-city.jpg',
),
location(
name: 'cairo',
place: 'egypt',
imageUrl: '$urlprefix/07-cairo.jpg',
),
];
<code_end>
<topic_end>
<topic_start>
creating responsive and adaptive apps
one of flutter’s primary goals is to create a framework
that allows you to develop apps from a single codebase
that look and feel great on any platform.
this means that your app might appear on screens of
many different sizes, from a watch, to a foldable
phone with two screens, to a high def monitor.
two terms that describe concepts for this
scenario are adaptive and responsive. ideally,
you’d want your app to be both but what,
exactly, does this mean?
these terms are similar, but they are not the same.
<topic_end>
<topic_start>
the difference between an adaptive and a responsive app
adaptive and responsive can be viewed as separate
dimensions of an app: you can have an adaptive app
that is not responsive, or vice versa. and, of course,
an app can be both, or neither.
learn more in the following 5-minute video:
adaptive vs responsive
<topic_end>
<topic_start>
creating a responsive flutter app