Skip to content

Commit 9f6c7f5

Browse files
Merge branch 'master' of https://github.com/flutter/samples into Update-platform_channels
2 parents 045cc70 + 1fae13e commit 9f6c7f5

File tree

26 files changed

+386
-723
lines changed

26 files changed

+386
-723
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ A collection of open source samples that illustrate best practices for
1010
The easiest way to browse through the samples in this repo (as well as a few others!)
1111
is the [visual samples index](https://flutter.github.io/samples).
1212

13+
## Tip: minimize download size
14+
15+
As this repository is quite big, you can use svn to download a single example.
16+
For example:
17+
18+
```
19+
svn co https://github.com/flutter/samples/trunk/provider_shopper
20+
```
21+
22+
You can also use a shallow clone to download just the latest revision:
23+
24+
```
25+
git clone --depth 1 https://github.com/flutter/samples.git
26+
```
27+
1328
## Interested in contributing?
1429

1530
See the [contributor's guide](CONTRIBUTING.md)!

experimental/desktop_photo_search/lib/main.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ class UnsplashHomePage extends StatelessWidget {
8282
label: 'About ...',
8383
onClicked: () {
8484
showDialog<void>(
85-
context: context,
86-
builder: (context) => PolicyDialog(),
85+
context: context,
86+
builder: (context) => PolicyDialog(),
8787
);
8888
},
8989
),

experimental/desktop_photo_search/lib/src/widgets/about_dialog.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ class PolicyDialog extends StatelessWidget {
4545
children: <TextSpan>[
4646
TextSpan(
4747
text: 'https://policies.google.com/terms',
48-
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.lightBlue),
48+
style: TextStyle(
49+
fontWeight: FontWeight.bold,
50+
color: Colors.lightBlue),
4951
recognizer: TapGestureRecognizer()
5052
..onTap = () async {
5153
final url = 'https://policies.google.com/terms';
@@ -65,7 +67,9 @@ class PolicyDialog extends StatelessWidget {
6567
children: <TextSpan>[
6668
TextSpan(
6769
text: 'https://unsplash.com/terms',
68-
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.lightBlue),
70+
style: TextStyle(
71+
fontWeight: FontWeight.bold,
72+
color: Colors.lightBlue),
6973
recognizer: TapGestureRecognizer()
7074
..onTap = () async {
7175
final url = 'https://unsplash.com/terms';

experimental/veggieseasons/lib/data/preferences.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ class Preferences extends ChangeNotifier {
5050
notifyListeners();
5151
}
5252

53+
Future<void> restoreDefaults() async {
54+
final prefs = await SharedPreferences.getInstance();
55+
await prefs.clear();
56+
load();
57+
}
58+
5359
void load() {
5460
_loading = _loadFromSharedPrefs();
5561
}

experimental/veggieseasons/lib/screens/search.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import 'package:flutter/widgets.dart';
88
import 'package:provider/provider.dart';
99
import 'package:veggieseasons/data/app_state.dart';
1010
import 'package:veggieseasons/data/veggie.dart';
11-
import 'package:veggieseasons/widgets/search_bar.dart';
1211
import 'package:veggieseasons/widgets/veggie_headline.dart';
1312

1413
class SearchScreen extends StatefulWidget {
@@ -49,7 +48,7 @@ class _SearchScreenState extends State<SearchScreen> with RestorationMixin {
4948
Widget _createSearchBox() {
5049
return Padding(
5150
padding: const EdgeInsets.all(8),
52-
child: SearchBar(
51+
child: CupertinoSearchTextField(
5352
controller: controller.value,
5453
focusNode: focusNode,
5554
),

experimental/veggieseasons/lib/screens/settings.dart

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,44 @@ class SettingsScreen extends StatelessWidget {
213213
);
214214
}
215215

216+
SettingsItem _buildRestoreDefaultsItem(
217+
BuildContext context, Preferences prefs) {
218+
return SettingsItem(
219+
label: 'Restore Defaults',
220+
icon: SettingsIcon(
221+
backgroundColor: CupertinoColors.systemRed,
222+
icon: Styles.resetIcon,
223+
),
224+
content: SettingsNavigationIndicator(),
225+
onPress: () {
226+
showCupertinoDialog<void>(
227+
context: context,
228+
builder: (context) => CupertinoAlertDialog(
229+
title: Text('Are you sure?'),
230+
content: Text(
231+
'Are you sure you want to reset the current settings?',
232+
),
233+
actions: <Widget>[
234+
CupertinoDialogAction(
235+
isDestructiveAction: true,
236+
child: Text('Yes'),
237+
onPressed: () async {
238+
await prefs.restoreDefaults();
239+
Navigator.pop(context);
240+
},
241+
),
242+
CupertinoDialogAction(
243+
isDefaultAction: true,
244+
child: Text('No'),
245+
onPressed: () => Navigator.pop(context),
246+
)
247+
],
248+
),
249+
);
250+
},
251+
);
252+
}
253+
216254
@override
217255
Widget build(BuildContext context) {
218256
final prefs = Provider.of<Preferences>(context);
@@ -238,6 +276,7 @@ class SettingsScreen extends StatelessWidget {
238276
items: [
239277
_buildCaloriesItem(context, prefs),
240278
_buildCategoriesItem(context, prefs),
279+
_buildRestoreDefaultsItem(context, prefs),
241280
],
242281
),
243282
],

experimental/veggieseasons/lib/styles.dart

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,12 @@ abstract class Styles {
120120
? CupertinoColors.lightBackgroundGray
121121
: null;
122122

123-
static Color searchBackground(CupertinoThemeData themeData) =>
124-
themeData.barBackgroundColor;
125-
126123
static const frostedBackground = Color(0xccf8f8f8);
127124

128125
static const closeButtonUnpressed = Color(0xff101010);
129126

130127
static const closeButtonPressed = Color(0xff808080);
131128

132-
static TextStyle searchText(CupertinoThemeData themeData) =>
133-
themeData.textTheme.textStyle.copyWith(
134-
fontSize: 14,
135-
);
136-
137129
static TextStyle settingsItemSubtitleText(CupertinoThemeData themeData) =>
138130
themeData.textTheme.textStyle.copyWith(
139131
fontSize: 12,
@@ -206,7 +198,7 @@ abstract class Styles {
206198
: CupertinoColors.darkBackgroundGray;
207199

208200
static Color settingsLineation(Brightness brightness) =>
209-
brightness == Brightness.light ? Color(0xffbcbbc1) : Color(0xFF4C4B4B);
201+
brightness == Brightness.light ? Color(0xffbcbbc1) : Color(0xff4c4b4b);
210202

211203
static const Color settingsBackground = Color(0xffefeff4);
212204

@@ -222,6 +214,12 @@ abstract class Styles {
222214
fontPackage: CupertinoIcons.iconFontPackage,
223215
);
224216

217+
static const resetIcon = IconData(
218+
0xf4c4,
219+
fontFamily: CupertinoIcons.iconFont,
220+
fontPackage: CupertinoIcons.iconFontPackage,
221+
);
222+
225223
static const calorieIcon = IconData(
226224
0xf3bb,
227225
fontFamily: CupertinoIcons.iconFont,
@@ -238,5 +236,5 @@ abstract class Styles {
238236

239237
static const ColorFilter desaturatedColorFilter =
240238
// 222222 is a random color that has low color saturation.
241-
ColorFilter.mode(Color(0xFF222222), BlendMode.saturation);
239+
ColorFilter.mode(Color(0xff222222), BlendMode.saturation);
242240
}

experimental/veggieseasons/lib/widgets/search_bar.dart

Lines changed: 0 additions & 72 deletions
This file was deleted.

testing_app/README.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ would do.
1212
Show how to perform:
1313

1414
- Widget Testing,
15-
- Flutter Driver(Integration) Testing,
15+
- Integration Testing,
1616
- Performance Testing, and
1717
- State Management Testing using the [Provider][] package.
1818

@@ -27,20 +27,15 @@ The Flutter SDK can run unit tests and widget tests in a virtual machine, withou
2727
### To run tests on a physical device/emulator:
2828
- Widget Tests:
2929
- Run `flutter run test/<file_path>`
30-
- Flutter Driver Tests:
31-
- Run `flutter drive --target=test_driver/<file_path>`
32-
- eg. `flutter drive --target=test_driver/app.dart` to run the test in `test_driver/app_test.dart`
30+
- Integration Tests:
31+
- Run `flutter drive --driver=integration_test/driver.dart --target=integration_test/app_test.dart`
3332
- Performance Tests:
34-
- Run `flutter drive --target=test_driver/app.dart --driver test_driver/perf_test.dart --profile --trace-startup`
33+
- Run `flutter drive --driver=integration_test/driver.dart --target=integration_test/perf_test.dart --profile --trace-startup`
3534
- Using a physical device and running performance tests in profile mode is recommended.
3635
- The `--trace-startup` option is used to avoid flushing older timeline events when the timeline gets long.
37-
- [E2E](https://pub.dev/packages/e2e) Tests:
38-
- Run `flutter drive --target test/perf_test_e2e.dart --driver test_driver/e2e_test.dart --profile`
39-
- Similar to the above but the test is driven on device.
40-
- You may also reference [E2E manual](https://github.com/flutter/plugins/tree/master/packages/e2e#firebase-test-lab) for how to run such test on Firebase Test Lab.
4136
- State Management Tests:
42-
- For testing state using Flutter Driver
43-
- Run `flutter drive --target=test_driver/<file_path>`
37+
- For testing state using Flutter Integration Tests
38+
- Run `flutter drive --driver=integration_test/driver.dart --target=integration_test/state_mgmt_test.dart`
4439

4540
### To generate test coverage report:
4641
- Install the `lcov` tool:
@@ -53,9 +48,9 @@ The Flutter SDK can run unit tests and widget tests in a virtual machine, withou
5348
- Open `coverage/index/index.html` in your preferred browser.
5449

5550
### CI/CD
56-
- Refer [.travis.yml](../.travis.yml) and the [tool](../tool) directory to see how to test Flutter projects using Travis-CI.
51+
- Refer [.github](../.github) and the [tool](../tool) directory to see how to test Flutter projects using GitHub Actions.
5752

58-
Note that we aren't performing Flutter Driver tests using the Travis tool in this repo. That is because it's recommended to use physical devices to run Driver tests. You can use [Firebase Test Lab](https://firebase.google.com/docs/test-lab), [Codemagic](https://codemagic.io/) or any platform of your choice to do that.
53+
Note that tools like GitHub Actions can't run tests on a physical device, which is required to run integration tests. Instead, you can use [Firebase Test Lab](https://firebase.google.com/docs/test-lab), [Codemagic](https://docs.codemagic.io/testing/aws/) or any platform of your choice to do that.
5954

6055
## Questions/issues
6156

0 commit comments

Comments
 (0)