1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 13:58:47 +00:00

Landing beta changes in master for the new stable release (#747)

This commit is contained in:
Andrew Brogdon
2021-03-03 11:44:35 -08:00
committed by GitHub
parent 6c81510d6e
commit 8c1cd0b049
101 changed files with 1006 additions and 1040 deletions

View File

@@ -116,7 +116,7 @@ class _PlatformAdaptingHomePageState extends State<PlatformAdaptingHomePage> {
);
default:
assert(false, 'Unexpected tab');
return null;
return SizedBox.shrink();
}
},
);

View File

@@ -22,9 +22,9 @@ class NewsTab extends StatefulWidget {
class _NewsTabState extends State<NewsTab> {
static const _itemsLength = 20;
List<Color> colors;
List<String> titles;
List<String> contents;
late final List<Color> colors;
late final List<String> titles;
late final List<String> contents;
@override
void initState() {
@@ -36,8 +36,6 @@ class _NewsTabState extends State<NewsTab> {
}
Widget _listBuilder(BuildContext context, int index) {
if (index >= _itemsLength) return null;
return SafeArea(
top: false,
bottom: false,
@@ -101,6 +99,7 @@ class _NewsTabState extends State<NewsTab> {
),
body: Container(
child: ListView.builder(
itemCount: _itemsLength,
itemBuilder: _listBuilder,
),
),
@@ -111,6 +110,7 @@ class _NewsTabState extends State<NewsTab> {
return CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(),
child: ListView.builder(
itemCount: _itemsLength,
itemBuilder: _listBuilder,
),
);

View File

@@ -109,7 +109,11 @@ class ProfileTab extends StatelessWidget {
}
class PreferenceCard extends StatelessWidget {
const PreferenceCard({this.header, this.content, this.preferenceChoices});
const PreferenceCard({
required this.header,
required this.content,
required this.preferenceChoices,
});
final String header;
final String content;

View File

@@ -12,7 +12,11 @@ import 'widgets.dart';
/// On Android, this page sits at the top of your app. On iOS, this page is on
/// top of the songs tab's content but is below the tab bar itself.
class SongDetailTab extends StatelessWidget {
const SongDetailTab({this.id, this.song, this.color});
const SongDetailTab({
required this.id,
required this.song,
required this.color,
});
final int id;
final String song;

View File

@@ -15,9 +15,9 @@ class SongsTab extends StatefulWidget {
static const androidIcon = Icon(Icons.music_note);
static const iosIcon = Icon(CupertinoIcons.music_note);
const SongsTab({Key key, this.androidDrawer}) : super(key: key);
const SongsTab({Key? key, this.androidDrawer}) : super(key: key);
final Widget androidDrawer;
final Widget? androidDrawer;
@override
_SongsTabState createState() => _SongsTabState();
@@ -28,8 +28,8 @@ class _SongsTabState extends State<SongsTab> {
final _androidRefreshKey = GlobalKey<RefreshIndicatorState>();
List<MaterialColor> colors;
List<String> songNames;
late List<MaterialColor> colors;
late List<String> songNames;
@override
void initState() {
@@ -51,7 +51,7 @@ class _SongsTabState extends State<SongsTab> {
}
Widget _listBuilder(BuildContext context, int index) {
if (index >= _itemsLength) return null;
if (index >= _itemsLength) return Container();
// Show a slightly different color palette. Show poppy-ier colors on iOS
// due to lighter contrasting bars and tone it down on Android.
@@ -96,7 +96,7 @@ class _SongsTabState extends State<SongsTab> {
// done in a real app but it's done here since this app
// unrealistically toggles the current platform for demonstration
// purposes.
WidgetsBinding.instance.reassembleApplication();
WidgetsBinding.instance!.reassembleApplication();
}
// ===========================================================================
@@ -117,7 +117,8 @@ class _SongsTabState extends State<SongsTab> {
actions: [
IconButton(
icon: Icon(Icons.refresh),
onPressed: () async => await _androidRefreshKey.currentState.show(),
onPressed: () async =>
await _androidRefreshKey.currentState!.show(),
),
IconButton(
icon: Icon(Icons.shuffle),
@@ -131,6 +132,7 @@ class _SongsTabState extends State<SongsTab> {
onRefresh: _refreshData,
child: ListView.builder(
padding: EdgeInsets.symmetric(vertical: 12),
itemCount: _itemsLength,
itemBuilder: _listBuilder,
),
),
@@ -155,7 +157,10 @@ class _SongsTabState extends State<SongsTab> {
sliver: SliverPadding(
padding: EdgeInsets.symmetric(vertical: 12),
sliver: SliverList(
delegate: SliverChildBuilderDelegate(_listBuilder),
delegate: SliverChildBuilderDelegate(
_listBuilder,
childCount: _itemsLength,
),
),
),
),

View File

@@ -57,7 +57,7 @@ String generateRandomHeadline() {
}
assert(false, 'Failed to generate news headline');
return null;
return 'Failed to generate news headline';
}
List<MaterialColor> getRandomColors(int amount) {

View File

@@ -9,12 +9,10 @@ import 'package:flutter/material.dart';
/// A simple widget that builds different things on different platforms.
class PlatformWidget extends StatelessWidget {
const PlatformWidget({
Key key,
@required this.androidBuilder,
@required this.iosBuilder,
}) : assert(androidBuilder != null),
assert(iosBuilder != null),
super(key: key);
Key? key,
required this.androidBuilder,
required this.iosBuilder,
}) : super(key: key);
final WidgetBuilder androidBuilder;
final WidgetBuilder iosBuilder;
@@ -28,7 +26,7 @@ class PlatformWidget extends StatelessWidget {
return iosBuilder(context);
default:
assert(false, 'Unexpected platform $defaultTargetPlatform');
return null;
return SizedBox.shrink();
}
}
}
@@ -40,15 +38,15 @@ class PlatformWidget extends StatelessWidget {
class PressableCard extends StatefulWidget {
const PressableCard({
this.onPressed,
this.color,
this.flattenAnimation,
required this.color,
required this.flattenAnimation,
this.child,
});
final VoidCallback onPressed;
final VoidCallback? onPressed;
final Color color;
final Animation<double> flattenAnimation;
final Widget child;
final Widget? child;
@override
State<StatefulWidget> createState() => _PressableCardState();
@@ -57,8 +55,8 @@ class PressableCard extends StatefulWidget {
class _PressableCardState extends State<PressableCard>
with SingleTickerProviderStateMixin {
bool pressed = false;
AnimationController controller;
Animation<double> elevationAnimation;
late final AnimationController controller;
late final Animation<double> elevationAnimation;
@override
void initState() {
@@ -93,9 +91,7 @@ class _PressableCardState extends State<PressableCard>
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
if (widget.onPressed != null) {
widget.onPressed();
}
widget.onPressed?.call();
},
// This widget both internally drives an animation when pressed and
// responds to an external animation to flatten the card when in a
@@ -138,13 +134,17 @@ class _PressableCardState extends State<PressableCard>
/// This is an example of a custom widget that an app developer might create for
/// use on both iOS and Android as part of their brand's unique design.
class HeroAnimatingSongCard extends StatelessWidget {
HeroAnimatingSongCard(
{this.song, this.color, this.heroAnimation, this.onPressed});
HeroAnimatingSongCard({
required this.song,
required this.color,
required this.heroAnimation,
this.onPressed,
});
final String song;
final Color color;
final Animation<double> heroAnimation;
final VoidCallback onPressed;
final VoidCallback? onPressed;
double get playButtonSize => 50 + 50 * heroAnimation.value;
@@ -226,7 +226,7 @@ class SongPlaceholderTile extends StatelessWidget {
child: Row(
children: [
Container(
color: Theme.of(context).textTheme.bodyText2.color,
color: Theme.of(context).textTheme.bodyText2!.color,
width: 130,
),
Padding(
@@ -239,27 +239,27 @@ class SongPlaceholderTile extends StatelessWidget {
Container(
height: 9,
margin: EdgeInsets.only(right: 60),
color: Theme.of(context).textTheme.bodyText2.color,
color: Theme.of(context).textTheme.bodyText2!.color,
),
Container(
height: 9,
margin: EdgeInsets.only(right: 20, top: 8),
color: Theme.of(context).textTheme.bodyText2.color,
color: Theme.of(context).textTheme.bodyText2!.color,
),
Container(
height: 9,
margin: EdgeInsets.only(right: 40, top: 8),
color: Theme.of(context).textTheme.bodyText2.color,
color: Theme.of(context).textTheme.bodyText2!.color,
),
Container(
height: 9,
margin: EdgeInsets.only(right: 80, top: 8),
color: Theme.of(context).textTheme.bodyText2.color,
color: Theme.of(context).textTheme.bodyText2!.color,
),
Container(
height: 9,
margin: EdgeInsets.only(right: 50, top: 8),
color: Theme.of(context).textTheme.bodyText2.color,
color: Theme.of(context).textTheme.bodyText2!.color,
),
],
),
@@ -287,7 +287,7 @@ void showChoices(BuildContext context, List<String> choices) {
showDialog<void>(
context: context,
builder: (context) {
var selectedRadio = 1;
int? selectedRadio = 1;
return AlertDialog(
contentPadding: EdgeInsets.only(top: 12),
content: StatefulBuilder(
@@ -295,12 +295,11 @@ void showChoices(BuildContext context, List<String> choices) {
return Column(
mainAxisSize: MainAxisSize.min,
children: List<Widget>.generate(choices.length, (index) {
return RadioListTile(
return RadioListTile<int?>(
title: Text(choices[index]),
value: index,
groupValue: selectedRadio,
// ignore: avoid_types_on_closure_parameters
onChanged: (int value) {
onChanged: (value) {
setState(() => selectedRadio = value);
},
);

View File

@@ -7,63 +7,63 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0-nullsafety.1"
version: "2.5.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.1"
version: "2.1.0"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.3"
version: "1.1.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
version: "1.2.0"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.1"
version: "1.1.0"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0-nullsafety.3"
version: "1.15.0"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
version: "1.0.2"
english_words:
dependency: "direct main"
description:
name: english_words
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.5"
version: "4.0.0-nullsafety.0"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
version: "1.2.0"
flutter:
dependency: "direct main"
description: flutter
@@ -75,7 +75,7 @@ packages:
name: flutter_lorem
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "2.0.0"
flutter_test:
dependency: "direct dev"
description: flutter
@@ -87,28 +87,28 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10-nullsafety.1"
version: "0.12.10"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.3"
version: "1.3.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.1"
version: "1.8.0"
pedantic:
dependency: "direct dev"
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.2"
version: "1.10.0"
sky_engine:
dependency: transitive
description: flutter
@@ -120,55 +120,55 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.2"
version: "1.8.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0-nullsafety.1"
version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.1"
version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.1"
version: "1.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
version: "1.2.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19-nullsafety.2"
version: "0.2.19"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.3"
version: "1.3.0"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.3"
version: "2.1.0"
sdks:
dart: ">=2.10.0-110 <2.11.0"
dart: ">=2.12.0-259 <3.0.0"

View File

@@ -3,20 +3,20 @@ description: A project showcasing a Flutter app following different platform IA
version: 1.0.0+1
environment:
sdk: ">=2.5.0 <3.0.0"
sdk: '>=2.12.0-0 <3.0.0'
dependencies:
english_words: ^3.1.5
flutter_lorem: ^1.1.0
english_words: ^4.0.0-nullsafety.0
flutter_lorem: ^2.0.0
flutter:
sdk: flutter
cupertino_icons: ^0.1.3
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
pedantic: ^1.9.0
pedantic: ^1.10.0
flutter:
uses-material-design: true