mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Update for Flutter 3.10 beta (#1746)
## Pre-launch Checklist - [x] I read the [Flutter Style Guide] _recently_, and have followed its advice. - [x] I signed the [CLA]. - [x] I read the [Contributors Guide]. - [x] I updated/added relevant documentation (doc comments with `///`). - [ ] All existing and new tests are passing. --------- Co-authored-by: David Iglesias <ditman@gmail.com> Co-authored-by: Mark Thompson <2554588+MarkTechson@users.noreply.github.com> Co-authored-by: John Ryan <ryjohn@google.com>
This commit is contained in:
@@ -103,26 +103,22 @@ class _PlatformAdaptingHomePageState extends State<PlatformAdaptingHomePage> {
|
||||
],
|
||||
),
|
||||
tabBuilder: (context, index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return CupertinoTabView(
|
||||
assert(index <= 2 && index >= 0, 'Unexpected tab index: $index');
|
||||
return switch (index) {
|
||||
0 => CupertinoTabView(
|
||||
defaultTitle: SongsTab.title,
|
||||
builder: (context) => SongsTab(key: songsTabKey),
|
||||
);
|
||||
case 1:
|
||||
return CupertinoTabView(
|
||||
),
|
||||
1 => CupertinoTabView(
|
||||
defaultTitle: NewsTab.title,
|
||||
builder: (context) => const NewsTab(),
|
||||
);
|
||||
case 2:
|
||||
return CupertinoTabView(
|
||||
),
|
||||
2 => CupertinoTabView(
|
||||
defaultTitle: ProfileTab.title,
|
||||
builder: (context) => const ProfileTab(),
|
||||
);
|
||||
default:
|
||||
assert(false, 'Unexpected tab');
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
),
|
||||
_ => const SizedBox.shrink(),
|
||||
};
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -58,9 +58,8 @@ class SongDetailTab extends StatelessWidget {
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: 10,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 0) {
|
||||
return const Padding(
|
||||
itemBuilder: (context, index) => switch (index) {
|
||||
0 => const Padding(
|
||||
padding: EdgeInsets.only(left: 15, top: 16, bottom: 8),
|
||||
child: Text(
|
||||
'You might also like:',
|
||||
@@ -69,10 +68,8 @@ class SongDetailTab extends StatelessWidget {
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
// Just a bunch of boxes that simulates loading song choices.
|
||||
return const SongPlaceholderTile();
|
||||
),
|
||||
_ => const SongPlaceholderTile(),
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
@@ -33,31 +33,23 @@ final wordPairIterator = generateWordPairs();
|
||||
String generateRandomHeadline() {
|
||||
final artist = capitalizePair(wordPairIterator.first);
|
||||
|
||||
switch (_random.nextInt(10)) {
|
||||
case 0:
|
||||
return '$artist says ${nouns[_random.nextInt(nouns.length)]}';
|
||||
case 1:
|
||||
return '$artist arrested due to ${wordPairIterator.first.join(' ')}';
|
||||
case 2:
|
||||
return '$artist releases ${capitalizePair(wordPairIterator.first)}';
|
||||
case 3:
|
||||
return '$artist talks about his ${nouns[_random.nextInt(nouns.length)]}';
|
||||
case 4:
|
||||
return '$artist talks about her ${nouns[_random.nextInt(nouns.length)]}';
|
||||
case 5:
|
||||
return '$artist talks about their ${nouns[_random.nextInt(nouns.length)]}';
|
||||
case 6:
|
||||
return '$artist says their music is inspired by ${wordPairIterator.first.join(' ')}';
|
||||
case 7:
|
||||
return '$artist says the world needs more ${nouns[_random.nextInt(nouns.length)]}';
|
||||
case 8:
|
||||
return '$artist calls their band ${adjectives[_random.nextInt(adjectives.length)]}';
|
||||
case 9:
|
||||
return '$artist finally ready to talk about ${nouns[_random.nextInt(nouns.length)]}';
|
||||
}
|
||||
|
||||
assert(false, 'Failed to generate news headline');
|
||||
return 'Failed to generate news headline';
|
||||
return switch (_random.nextInt(10)) {
|
||||
0 => '$artist says ${nouns[_random.nextInt(nouns.length)]}',
|
||||
1 => '$artist arrested due to ${wordPairIterator.first.join(' ')}',
|
||||
2 => '$artist releases ${capitalizePair(wordPairIterator.first)}',
|
||||
3 => '$artist talks about his ${nouns[_random.nextInt(nouns.length)]}',
|
||||
4 => '$artist talks about her ${nouns[_random.nextInt(nouns.length)]}',
|
||||
5 => '$artist talks about their ${nouns[_random.nextInt(nouns.length)]}',
|
||||
6 =>
|
||||
'$artist says their music is inspired by ${wordPairIterator.first.join(' ')}',
|
||||
7 =>
|
||||
'$artist says the world needs more ${nouns[_random.nextInt(nouns.length)]}',
|
||||
8 =>
|
||||
'$artist calls their band ${adjectives[_random.nextInt(adjectives.length)]}',
|
||||
9 =>
|
||||
'$artist finally ready to talk about ${nouns[_random.nextInt(nouns.length)]}',
|
||||
_ => 'Failed to generate news headline',
|
||||
};
|
||||
}
|
||||
|
||||
List<MaterialColor> getRandomColors(int amount) {
|
||||
|
||||
@@ -19,15 +19,15 @@ class PlatformWidget extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(context) {
|
||||
switch (defaultTargetPlatform) {
|
||||
case TargetPlatform.android:
|
||||
return androidBuilder(context);
|
||||
case TargetPlatform.iOS:
|
||||
return iosBuilder(context);
|
||||
default:
|
||||
assert(false, 'Unexpected platform $defaultTargetPlatform');
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
assert(
|
||||
defaultTargetPlatform == TargetPlatform.android ||
|
||||
defaultTargetPlatform == TargetPlatform.iOS,
|
||||
'Unexpected platform $defaultTargetPlatform');
|
||||
return switch (defaultTargetPlatform) {
|
||||
TargetPlatform.android => androidBuilder(context),
|
||||
TargetPlatform.iOS => iosBuilder(context),
|
||||
_ => const SizedBox.shrink()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ description: A project showcasing a Flutter app following different platform IA
|
||||
version: 1.0.0+1
|
||||
|
||||
environment:
|
||||
sdk: '>=2.19.5 <4.0.0'
|
||||
sdk: ^3.0.0-0
|
||||
|
||||
dependencies:
|
||||
english_words: ^4.0.0
|
||||
|
||||
Reference in New Issue
Block a user