"Fossies" - the Fresh Open Source Software Archive

Member "flutter-1.22.4/dev/integration_tests/flutter_gallery/lib/gallery/about.dart" (13 Nov 2020, 3095 Bytes) of package /linux/misc/flutter-1.22.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Dart source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 // Copyright 2014 The Flutter Authors. All rights reserved.
    2 // Use of this source code is governed by a BSD-style license that can be
    3 // found in the LICENSE file.
    4 
    5 import 'package:flutter/gestures.dart';
    6 import 'package:flutter/foundation.dart' show defaultTargetPlatform;
    7 import 'package:flutter/material.dart';
    8 
    9 import 'package:url_launcher/url_launcher.dart';
   10 
   11 class _LinkTextSpan extends TextSpan {
   12 
   13   // Beware!
   14   //
   15   // This class is only safe because the TapGestureRecognizer is not
   16   // given a deadline and therefore never allocates any resources.
   17   //
   18   // In any other situation -- setting a deadline, using any of the less trivial
   19   // recognizers, etc -- you would have to manage the gesture recognizer's
   20   // lifetime and call dispose() when the TextSpan was no longer being rendered.
   21   //
   22   // Since TextSpan itself is @immutable, this means that you would have to
   23   // manage the recognizer from outside the TextSpan, e.g. in the State of a
   24   // stateful widget that then hands the recognizer to the TextSpan.
   25 
   26   _LinkTextSpan({ TextStyle style, String url, String text }) : super(
   27     style: style,
   28     text: text ?? url,
   29     recognizer: TapGestureRecognizer()..onTap = () {
   30       launch(url, forceSafariVC: false);
   31     }
   32   );
   33 }
   34 
   35 void showGalleryAboutDialog(BuildContext context) {
   36   final ThemeData themeData = Theme.of(context);
   37   final TextStyle aboutTextStyle = themeData.textTheme.bodyText1;
   38   final TextStyle linkStyle = themeData.textTheme.bodyText1.copyWith(color: themeData.accentColor);
   39 
   40   showAboutDialog(
   41     context: context,
   42     applicationVersion: 'January 2019',
   43     applicationIcon: const FlutterLogo(),
   44     applicationLegalese: '© 2014 The Flutter Authors',
   45     children: <Widget>[
   46       Padding(
   47         padding: const EdgeInsets.only(top: 24.0),
   48         child: RichText(
   49           text: TextSpan(
   50             children: <TextSpan>[
   51               TextSpan(
   52                 style: aboutTextStyle,
   53                 text: 'Flutter is an open-source project to help developers '
   54                       'build high-performance, high-fidelity, mobile apps for '
   55                       '${defaultTargetPlatform == TargetPlatform.iOS ? 'multiple platforms' : 'iOS and Android'} '
   56                       'from a single codebase. This design lab is a playground '
   57                       "and showcase of Flutter's many widgets, behaviors, "
   58                       'animations, layouts, and more. Learn more about Flutter at ',
   59               ),
   60               _LinkTextSpan(
   61                 style: linkStyle,
   62                 url: 'https://flutter.dev',
   63               ),
   64               TextSpan(
   65                 style: aboutTextStyle,
   66                 text: '.\n\nTo see the source code for this app, please visit the ',
   67               ),
   68               _LinkTextSpan(
   69                 style: linkStyle,
   70                 url: 'https://goo.gl/iv1p4G',
   71                 text: 'flutter github repo',
   72               ),
   73               TextSpan(
   74                 style: aboutTextStyle,
   75                 text: '.',
   76               ),
   77             ],
   78           ),
   79         ),
   80       ),
   81     ],
   82   );
   83 }