mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

This converts all remaining "## Sample code" segments into snippets, and fixes the snippet generator to handle multiple snippets in the same dartdoc block properly. I also generated, compiled, and ran each of the existing application samples, and fixed them up to be more useful and/or just run without errors. This PR fixes these problems with examples: 1. Switching tabs in a snippet now works if there is more than one snippet in a single dartdoc block. 2. Generation of snippet code now works if there is more than one snippet. 3. Contrast of text and links in the code sample block has been improved to recommended levels. 4. Added five new snippet templates, including a "freeform" template to make it possible to show examples that need to change the app instantiation. 5. Fixed several examples to run properly, a couple by adding the "Scaffold" widget to the template, a couple by just fixing their code. 6. Fixed visual look of some of the samples when they run by placing many samples inside of a Scaffold. 7. In order to make it easier to run locally, changed the sample analyzer to remove the contents of the supplied temp directory before running, since having files that hang around is problematic (only a problem when running locally with the `--temp` argument). 8. Added a `SampleCheckerException` class, and handle sample checking exceptions more gracefully. 9. Deprecated the old "## Sample code" designation, and added enforcement for the deprecation. 10. Removed unnecessary `new` from templates (although they never appeared in the samples thanks to dartfmt, but still). Fixes #26398 Fixes #27411
44 lines
1.4 KiB
Dart
44 lines
1.4 KiB
Dart
// Copyright 2018 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// This file is used by ../analyze-sample-code_test.dart, which depends on the
|
|
// precise contents (including especially the comments) of this file.
|
|
|
|
// Examples can assume:
|
|
// bool _visible = true;
|
|
|
|
/// A blabla that blabla its blabla blabla blabla.
|
|
///
|
|
/// Bla blabla blabla its blabla into an blabla blabla and then blabla the
|
|
/// blabla back into the blabla blabla blabla.
|
|
///
|
|
/// Bla blabla of blabla blabla than 0.0 and 1.0, this blabla is blabla blabla
|
|
/// blabla it blabla pirates blabla the blabla into of blabla blabla. Bla the
|
|
/// blabla 0.0, the penzance blabla is blabla not blabla at all. Bla the blabla
|
|
/// 1.0, the blabla is blabla blabla blabla an blabla blabla.
|
|
///
|
|
/// {@tool sample}
|
|
/// Bla blabla blabla some [Text] when the `_blabla` blabla blabla is true, and
|
|
/// blabla it when it is blabla:
|
|
///
|
|
/// ```dart
|
|
/// new Opacity(
|
|
/// opacity: _visible ? 1.0 : 0.0,
|
|
/// child: const Text('Poor wandering ones!'),
|
|
/// )
|
|
/// ```
|
|
/// {@end-tool}
|
|
///
|
|
/// {@tool sample}
|
|
/// Bla blabla blabla some [Text] when the `_blabla` blabla blabla is true, and
|
|
/// blabla finale blabla:
|
|
///
|
|
/// ```dart
|
|
/// new Opacity(
|
|
/// opacity: _visible ? 1.0 : 0.0,
|
|
/// child: const Text('Poor wandering ones!'),
|
|
/// )
|
|
/// ```
|
|
/// {@end-tool}
|