[Gallery] Implement material picker demo (#249)

pull/255/head
rami-a 5 years ago committed by GitHub
parent 3885418fff
commit 2da59e988a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -19797,6 +19797,558 @@ class CodeSegments {
]);
}
static TextSpan pickerDemo(BuildContext context) {
final CodeStyle codeStyle = CodeStyle.of(context);
return TextSpan(children: [
TextSpan(
style: codeStyle.commentStyle,
text: '// Copyright 2019 The Flutter team. All rights reserved.'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a'),
TextSpan(
style: codeStyle.commentStyle,
text:
'// Use of this source code is governed by a BSD-style license that can be'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a'),
TextSpan(
style: codeStyle.commentStyle, text: '// found in the LICENSE file.'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'),
TextSpan(style: codeStyle.keywordStyle, text: 'import'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.stringStyle, text: '\u0027dart:async\u0027'),
TextSpan(style: codeStyle.punctuationStyle, text: ';'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'),
TextSpan(style: codeStyle.keywordStyle, text: 'import'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(
style: codeStyle.stringStyle,
text: '\u0027package:flutter/material.dart\u0027'),
TextSpan(style: codeStyle.punctuationStyle, text: ';'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a'),
TextSpan(style: codeStyle.keywordStyle, text: 'import'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(
style: codeStyle.stringStyle,
text: '\u0027package:gallery/l10n/gallery_localizations.dart\u0027'),
TextSpan(style: codeStyle.punctuationStyle, text: ';'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a'),
TextSpan(style: codeStyle.keywordStyle, text: 'import'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(
style: codeStyle.stringStyle,
text: '\u0027package:intl/intl.dart\u0027'),
TextSpan(style: codeStyle.punctuationStyle, text: ';'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'),
TextSpan(style: codeStyle.keywordStyle, text: 'enum'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'PickerDemoType'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.punctuationStyle, text: '{'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a date'),
TextSpan(style: codeStyle.punctuationStyle, text: ','),
TextSpan(style: codeStyle.baseStyle, text: '\u000a time'),
TextSpan(style: codeStyle.punctuationStyle, text: ','),
TextSpan(style: codeStyle.baseStyle, text: '\u000a'),
TextSpan(style: codeStyle.punctuationStyle, text: '}'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'),
TextSpan(style: codeStyle.keywordStyle, text: 'class'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'PickerDemo'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.keywordStyle, text: 'extends'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'StatefulWidget'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.punctuationStyle, text: '{'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: 'const'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'PickerDemo'),
TextSpan(style: codeStyle.punctuationStyle, text: '({'),
TextSpan(style: codeStyle.classStyle, text: 'Key'),
TextSpan(style: codeStyle.baseStyle, text: ' key'),
TextSpan(style: codeStyle.punctuationStyle, text: ','),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.keywordStyle, text: 'this'),
TextSpan(style: codeStyle.punctuationStyle, text: '.'),
TextSpan(style: codeStyle.baseStyle, text: 'type'),
TextSpan(style: codeStyle.punctuationStyle, text: '})'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.punctuationStyle, text: ':'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.keywordStyle, text: 'super'),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(style: codeStyle.baseStyle, text: 'key'),
TextSpan(style: codeStyle.punctuationStyle, text: ':'),
TextSpan(style: codeStyle.baseStyle, text: ' key'),
TextSpan(style: codeStyle.punctuationStyle, text: ');'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: 'final'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'PickerDemoType'),
TextSpan(style: codeStyle.baseStyle, text: ' type'),
TextSpan(style: codeStyle.punctuationStyle, text: ';'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: '@override'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.classStyle, text: '_PickerDemoState'),
TextSpan(style: codeStyle.baseStyle, text: ' createState'),
TextSpan(style: codeStyle.punctuationStyle, text: '()'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.punctuationStyle, text: '=>'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: '_PickerDemoState'),
TextSpan(style: codeStyle.punctuationStyle, text: '();'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a'),
TextSpan(style: codeStyle.punctuationStyle, text: '}'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'),
TextSpan(style: codeStyle.keywordStyle, text: 'class'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: '_PickerDemoState'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.keywordStyle, text: 'extends'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'State'),
TextSpan(style: codeStyle.punctuationStyle, text: '<'),
TextSpan(style: codeStyle.classStyle, text: 'PickerDemo'),
TextSpan(style: codeStyle.punctuationStyle, text: '>'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.punctuationStyle, text: '{'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.classStyle, text: 'DateTime'),
TextSpan(style: codeStyle.baseStyle, text: ' _fromDate '),
TextSpan(style: codeStyle.punctuationStyle, text: '='),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'DateTime'),
TextSpan(style: codeStyle.punctuationStyle, text: '.'),
TextSpan(style: codeStyle.baseStyle, text: 'now'),
TextSpan(style: codeStyle.punctuationStyle, text: '();'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.classStyle, text: 'TimeOfDay'),
TextSpan(style: codeStyle.baseStyle, text: ' _fromTime '),
TextSpan(style: codeStyle.punctuationStyle, text: '='),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'TimeOfDay'),
TextSpan(style: codeStyle.punctuationStyle, text: '.'),
TextSpan(style: codeStyle.baseStyle, text: 'fromDateTime'),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(style: codeStyle.classStyle, text: 'DateTime'),
TextSpan(style: codeStyle.punctuationStyle, text: '.'),
TextSpan(style: codeStyle.baseStyle, text: 'now'),
TextSpan(style: codeStyle.punctuationStyle, text: '());'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a '),
TextSpan(style: codeStyle.classStyle, text: 'String'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.keywordStyle, text: 'get'),
TextSpan(style: codeStyle.baseStyle, text: ' _title '),
TextSpan(style: codeStyle.punctuationStyle, text: '{'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: 'switch'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(style: codeStyle.baseStyle, text: 'widget'),
TextSpan(style: codeStyle.punctuationStyle, text: '.'),
TextSpan(style: codeStyle.baseStyle, text: 'type'),
TextSpan(style: codeStyle.punctuationStyle, text: ')'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.punctuationStyle, text: '{'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: 'case'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'PickerDemoType'),
TextSpan(style: codeStyle.punctuationStyle, text: '.'),
TextSpan(style: codeStyle.baseStyle, text: 'date'),
TextSpan(style: codeStyle.punctuationStyle, text: ':'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: 'return'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'GalleryLocalizations'),
TextSpan(style: codeStyle.punctuationStyle, text: '.'),
TextSpan(style: codeStyle.baseStyle, text: 'of'),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(style: codeStyle.baseStyle, text: 'context'),
TextSpan(style: codeStyle.punctuationStyle, text: ').'),
TextSpan(style: codeStyle.baseStyle, text: 'demoDatePickerTitle'),
TextSpan(style: codeStyle.punctuationStyle, text: ';'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: 'case'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'PickerDemoType'),
TextSpan(style: codeStyle.punctuationStyle, text: '.'),
TextSpan(style: codeStyle.baseStyle, text: 'time'),
TextSpan(style: codeStyle.punctuationStyle, text: ':'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: 'return'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'GalleryLocalizations'),
TextSpan(style: codeStyle.punctuationStyle, text: '.'),
TextSpan(style: codeStyle.baseStyle, text: 'of'),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(style: codeStyle.baseStyle, text: 'context'),
TextSpan(style: codeStyle.punctuationStyle, text: ').'),
TextSpan(style: codeStyle.baseStyle, text: 'demoTimePickerTitle'),
TextSpan(style: codeStyle.punctuationStyle, text: ';'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.punctuationStyle, text: '}'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: 'return'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.stringStyle, text: '\u0027\u0027'),
TextSpan(style: codeStyle.punctuationStyle, text: ';'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.punctuationStyle, text: '}'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a '),
TextSpan(style: codeStyle.classStyle, text: 'String'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.keywordStyle, text: 'get'),
TextSpan(style: codeStyle.baseStyle, text: ' _labelText '),
TextSpan(style: codeStyle.punctuationStyle, text: '{'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: 'switch'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(style: codeStyle.baseStyle, text: 'widget'),
TextSpan(style: codeStyle.punctuationStyle, text: '.'),
TextSpan(style: codeStyle.baseStyle, text: 'type'),
TextSpan(style: codeStyle.punctuationStyle, text: ')'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.punctuationStyle, text: '{'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: 'case'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'PickerDemoType'),
TextSpan(style: codeStyle.punctuationStyle, text: '.'),
TextSpan(style: codeStyle.baseStyle, text: 'date'),
TextSpan(style: codeStyle.punctuationStyle, text: ':'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: 'return'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'DateFormat'),
TextSpan(style: codeStyle.punctuationStyle, text: '.'),
TextSpan(style: codeStyle.baseStyle, text: 'yMMMd'),
TextSpan(style: codeStyle.punctuationStyle, text: '().'),
TextSpan(style: codeStyle.baseStyle, text: 'format'),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(style: codeStyle.baseStyle, text: '_fromDate'),
TextSpan(style: codeStyle.punctuationStyle, text: ');'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: 'case'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'PickerDemoType'),
TextSpan(style: codeStyle.punctuationStyle, text: '.'),
TextSpan(style: codeStyle.baseStyle, text: 'time'),
TextSpan(style: codeStyle.punctuationStyle, text: ':'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: 'return'),
TextSpan(style: codeStyle.baseStyle, text: ' _fromTime'),
TextSpan(style: codeStyle.punctuationStyle, text: '.'),
TextSpan(style: codeStyle.baseStyle, text: 'format'),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(style: codeStyle.baseStyle, text: 'context'),
TextSpan(style: codeStyle.punctuationStyle, text: ');'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.punctuationStyle, text: '}'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: 'return'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.stringStyle, text: '\u0027\u0027'),
TextSpan(style: codeStyle.punctuationStyle, text: ';'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.punctuationStyle, text: '}'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a '),
TextSpan(style: codeStyle.classStyle, text: 'Future'),
TextSpan(style: codeStyle.punctuationStyle, text: '<'),
TextSpan(style: codeStyle.keywordStyle, text: 'void'),
TextSpan(style: codeStyle.punctuationStyle, text: '>'),
TextSpan(style: codeStyle.baseStyle, text: ' _showDatePicker'),
TextSpan(style: codeStyle.punctuationStyle, text: '()'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.keywordStyle, text: 'async'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.punctuationStyle, text: '{'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: 'final'),
TextSpan(style: codeStyle.baseStyle, text: ' picked '),
TextSpan(style: codeStyle.punctuationStyle, text: '='),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.keywordStyle, text: 'await'),
TextSpan(style: codeStyle.baseStyle, text: ' showDatePicker'),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(style: codeStyle.baseStyle, text: '\u000a context'),
TextSpan(style: codeStyle.punctuationStyle, text: ':'),
TextSpan(style: codeStyle.baseStyle, text: ' context'),
TextSpan(style: codeStyle.punctuationStyle, text: ','),
TextSpan(style: codeStyle.baseStyle, text: '\u000a initialDate'),
TextSpan(style: codeStyle.punctuationStyle, text: ':'),
TextSpan(style: codeStyle.baseStyle, text: ' _fromDate'),
TextSpan(style: codeStyle.punctuationStyle, text: ','),
TextSpan(style: codeStyle.baseStyle, text: '\u000a firstDate'),
TextSpan(style: codeStyle.punctuationStyle, text: ':'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'DateTime'),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(style: codeStyle.numberStyle, text: '2015'),
TextSpan(style: codeStyle.punctuationStyle, text: ','),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.numberStyle, text: '1'),
TextSpan(style: codeStyle.punctuationStyle, text: '),'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a lastDate'),
TextSpan(style: codeStyle.punctuationStyle, text: ':'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'DateTime'),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(style: codeStyle.numberStyle, text: '2100'),
TextSpan(style: codeStyle.punctuationStyle, text: '),'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.punctuationStyle, text: ');'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: 'if'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(style: codeStyle.baseStyle, text: 'picked '),
TextSpan(style: codeStyle.punctuationStyle, text: '!='),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.keywordStyle, text: 'null'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.punctuationStyle, text: '&&'),
TextSpan(style: codeStyle.baseStyle, text: ' picked '),
TextSpan(style: codeStyle.punctuationStyle, text: '!='),
TextSpan(style: codeStyle.baseStyle, text: ' _fromDate'),
TextSpan(style: codeStyle.punctuationStyle, text: ')'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.punctuationStyle, text: '{'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a setState'),
TextSpan(style: codeStyle.punctuationStyle, text: '(()'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.punctuationStyle, text: '{'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a _fromDate '),
TextSpan(style: codeStyle.punctuationStyle, text: '='),
TextSpan(style: codeStyle.baseStyle, text: ' picked'),
TextSpan(style: codeStyle.punctuationStyle, text: ';'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.punctuationStyle, text: '});'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.punctuationStyle, text: '}'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.punctuationStyle, text: '}'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a '),
TextSpan(style: codeStyle.classStyle, text: 'Future'),
TextSpan(style: codeStyle.punctuationStyle, text: '<'),
TextSpan(style: codeStyle.keywordStyle, text: 'void'),
TextSpan(style: codeStyle.punctuationStyle, text: '>'),
TextSpan(style: codeStyle.baseStyle, text: ' _showTimePicker'),
TextSpan(style: codeStyle.punctuationStyle, text: '()'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.keywordStyle, text: 'async'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.punctuationStyle, text: '{'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: 'final'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'TimeOfDay'),
TextSpan(style: codeStyle.baseStyle, text: ' picked '),
TextSpan(style: codeStyle.punctuationStyle, text: '='),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.keywordStyle, text: 'await'),
TextSpan(style: codeStyle.baseStyle, text: ' showTimePicker'),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(style: codeStyle.baseStyle, text: '\u000a context'),
TextSpan(style: codeStyle.punctuationStyle, text: ':'),
TextSpan(style: codeStyle.baseStyle, text: ' context'),
TextSpan(style: codeStyle.punctuationStyle, text: ','),
TextSpan(style: codeStyle.baseStyle, text: '\u000a initialTime'),
TextSpan(style: codeStyle.punctuationStyle, text: ':'),
TextSpan(style: codeStyle.baseStyle, text: ' _fromTime'),
TextSpan(style: codeStyle.punctuationStyle, text: ','),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.punctuationStyle, text: ');'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: 'if'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(style: codeStyle.baseStyle, text: 'picked '),
TextSpan(style: codeStyle.punctuationStyle, text: '!='),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.keywordStyle, text: 'null'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.punctuationStyle, text: '&&'),
TextSpan(style: codeStyle.baseStyle, text: ' picked '),
TextSpan(style: codeStyle.punctuationStyle, text: '!='),
TextSpan(style: codeStyle.baseStyle, text: ' _fromTime'),
TextSpan(style: codeStyle.punctuationStyle, text: ')'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.punctuationStyle, text: '{'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a setState'),
TextSpan(style: codeStyle.punctuationStyle, text: '(()'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.punctuationStyle, text: '{'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a _fromTime '),
TextSpan(style: codeStyle.punctuationStyle, text: '='),
TextSpan(style: codeStyle.baseStyle, text: ' picked'),
TextSpan(style: codeStyle.punctuationStyle, text: ';'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.punctuationStyle, text: '});'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.punctuationStyle, text: '}'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.punctuationStyle, text: '}'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: '@override'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.classStyle, text: 'Widget'),
TextSpan(style: codeStyle.baseStyle, text: ' build'),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(style: codeStyle.classStyle, text: 'BuildContext'),
TextSpan(style: codeStyle.baseStyle, text: ' context'),
TextSpan(style: codeStyle.punctuationStyle, text: ')'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.punctuationStyle, text: '{'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: 'return'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'Scaffold'),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(style: codeStyle.baseStyle, text: '\u000a appBar'),
TextSpan(style: codeStyle.punctuationStyle, text: ':'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'AppBar'),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(
style: codeStyle.baseStyle,
text: '\u000a automaticallyImplyLeading'),
TextSpan(style: codeStyle.punctuationStyle, text: ':'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.keywordStyle, text: 'false'),
TextSpan(style: codeStyle.punctuationStyle, text: ','),
TextSpan(style: codeStyle.baseStyle, text: '\u000a title'),
TextSpan(style: codeStyle.punctuationStyle, text: ':'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'Text'),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(style: codeStyle.baseStyle, text: '_title'),
TextSpan(style: codeStyle.punctuationStyle, text: '),'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.punctuationStyle, text: '),'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a body'),
TextSpan(style: codeStyle.punctuationStyle, text: ':'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'Center'),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(style: codeStyle.baseStyle, text: '\u000a child'),
TextSpan(style: codeStyle.punctuationStyle, text: ':'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'Column'),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(
style: codeStyle.baseStyle, text: '\u000a mainAxisSize'),
TextSpan(style: codeStyle.punctuationStyle, text: ':'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'MainAxisSize'),
TextSpan(style: codeStyle.punctuationStyle, text: '.'),
TextSpan(style: codeStyle.baseStyle, text: 'min'),
TextSpan(style: codeStyle.punctuationStyle, text: ','),
TextSpan(style: codeStyle.baseStyle, text: '\u000a children'),
TextSpan(style: codeStyle.punctuationStyle, text: ':'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.punctuationStyle, text: '['),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.classStyle, text: 'Text'),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(style: codeStyle.baseStyle, text: '_labelText'),
TextSpan(style: codeStyle.punctuationStyle, text: '),'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.classStyle, text: 'SizedBox'),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(style: codeStyle.baseStyle, text: 'height'),
TextSpan(style: codeStyle.punctuationStyle, text: ':'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.numberStyle, text: '16'),
TextSpan(style: codeStyle.punctuationStyle, text: '),'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.classStyle, text: 'RaisedButton'),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(style: codeStyle.baseStyle, text: '\u000a child'),
TextSpan(style: codeStyle.punctuationStyle, text: ':'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'Text'),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.classStyle, text: 'GalleryLocalizations'),
TextSpan(style: codeStyle.punctuationStyle, text: '.'),
TextSpan(style: codeStyle.baseStyle, text: 'of'),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(style: codeStyle.baseStyle, text: 'context'),
TextSpan(style: codeStyle.punctuationStyle, text: ').'),
TextSpan(style: codeStyle.baseStyle, text: 'demoPickersShowPicker'),
TextSpan(style: codeStyle.punctuationStyle, text: ','),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.punctuationStyle, text: '),'),
TextSpan(
style: codeStyle.baseStyle, text: '\u000a onPressed'),
TextSpan(style: codeStyle.punctuationStyle, text: ':'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.punctuationStyle, text: '()'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.punctuationStyle, text: '{'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: 'switch'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(style: codeStyle.baseStyle, text: 'widget'),
TextSpan(style: codeStyle.punctuationStyle, text: '.'),
TextSpan(style: codeStyle.baseStyle, text: 'type'),
TextSpan(style: codeStyle.punctuationStyle, text: ')'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.punctuationStyle, text: '{'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: 'case'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'PickerDemoType'),
TextSpan(style: codeStyle.punctuationStyle, text: '.'),
TextSpan(style: codeStyle.baseStyle, text: 'date'),
TextSpan(style: codeStyle.punctuationStyle, text: ':'),
TextSpan(
style: codeStyle.baseStyle,
text: '\u000a _showDatePicker'),
TextSpan(style: codeStyle.punctuationStyle, text: '();'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: 'break'),
TextSpan(style: codeStyle.punctuationStyle, text: ';'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: 'case'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'PickerDemoType'),
TextSpan(style: codeStyle.punctuationStyle, text: '.'),
TextSpan(style: codeStyle.baseStyle, text: 'time'),
TextSpan(style: codeStyle.punctuationStyle, text: ':'),
TextSpan(
style: codeStyle.baseStyle,
text: '\u000a _showTimePicker'),
TextSpan(style: codeStyle.punctuationStyle, text: '();'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: 'break'),
TextSpan(style: codeStyle.punctuationStyle, text: ';'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.punctuationStyle, text: '}'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.punctuationStyle, text: '},'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.punctuationStyle, text: ')'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.punctuationStyle, text: '],'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.punctuationStyle, text: '),'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.punctuationStyle, text: '),'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.punctuationStyle, text: ');'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.punctuationStyle, text: '}'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a'),
TextSpan(style: codeStyle.punctuationStyle, text: '}'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a'),
]);
}
static TextSpan progressIndicatorsDemo(BuildContext context) {
final CodeStyle codeStyle = CodeStyle.of(context);
return TextSpan(children: [

@ -29,6 +29,7 @@ import 'package:gallery/demos/material/dialog_demo.dart';
import 'package:gallery/demos/material/grid_list_demo.dart';
import 'package:gallery/demos/material/list_demo.dart';
import 'package:gallery/demos/material/menu_demo.dart';
import 'package:gallery/demos/material/picker_demo.dart';
import 'package:gallery/demos/material/progress_indicator_demo.dart';
import 'package:gallery/demos/material/selection_controls_demo.dart';
import 'package:gallery/demos/material/sliders_demo.dart';
@ -381,6 +382,27 @@ List<GalleryDemo> materialDemos(BuildContext context) {
),
],
),
GalleryDemo(
title: localizations.demoPickersTitle,
icon: GalleryIcons.event,
subtitle: localizations.demoPickersSubtitle,
configurations: [
GalleryDemoConfiguration(
title: localizations.demoDatePickerTitle,
description: localizations.demoDatePickerDescription,
documentationUrl: '$_docsBaseUrl/material/showDatePicker.html',
buildRoute: (context) => PickerDemo(type: PickerDemoType.date),
code: CodeSegments.pickerDemo,
),
GalleryDemoConfiguration(
title: localizations.demoTimePickerTitle,
description: localizations.demoTimePickerDescription,
documentationUrl: '$_docsBaseUrl/material/showTimePicker.htmlhtml',
buildRoute: (context) => PickerDemo(type: PickerDemoType.time),
code: CodeSegments.pickerDemo,
),
],
),
GalleryDemo(
title: localizations.demoProgressIndicatorTitle,
icon: GalleryIcons.progressActivity,

@ -0,0 +1,112 @@
// Copyright 2019 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:gallery/l10n/gallery_localizations.dart';
import 'package:intl/intl.dart';
// BEGIN pickerDemo
enum PickerDemoType {
date,
time,
}
class PickerDemo extends StatefulWidget {
const PickerDemo({Key key, this.type}) : super(key: key);
final PickerDemoType type;
@override
_PickerDemoState createState() => _PickerDemoState();
}
class _PickerDemoState extends State<PickerDemo> {
DateTime _fromDate = DateTime.now();
TimeOfDay _fromTime = TimeOfDay.fromDateTime(DateTime.now());
String get _title {
switch (widget.type) {
case PickerDemoType.date:
return GalleryLocalizations.of(context).demoDatePickerTitle;
case PickerDemoType.time:
return GalleryLocalizations.of(context).demoTimePickerTitle;
}
return '';
}
String get _labelText {
switch (widget.type) {
case PickerDemoType.date:
return DateFormat.yMMMd().format(_fromDate);
case PickerDemoType.time:
return _fromTime.format(context);
}
return '';
}
Future<void> _showDatePicker() async {
final picked = await showDatePicker(
context: context,
initialDate: _fromDate,
firstDate: DateTime(2015, 1),
lastDate: DateTime(2100),
);
if (picked != null && picked != _fromDate) {
setState(() {
_fromDate = picked;
});
}
}
Future<void> _showTimePicker() async {
final TimeOfDay picked = await showTimePicker(
context: context,
initialTime: _fromTime,
);
if (picked != null && picked != _fromTime) {
setState(() {
_fromTime = picked;
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
title: Text(_title),
),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(_labelText),
SizedBox(height: 16),
RaisedButton(
child: Text(
GalleryLocalizations.of(context).demoPickersShowPicker,
),
onPressed: () {
switch (widget.type) {
case PickerDemoType.date:
_showDatePicker();
break;
case PickerDemoType.time:
_showTimePicker();
break;
}
},
)
],
),
),
);
}
}
// END

@ -2033,6 +2033,21 @@ class GalleryLocalizations {
desc: r'Title for the custom sliders component demo.');
}
String get demoDatePickerDescription {
return Intl.message(
'Shows a dialog containing a Material Design date picker.',
locale: _localeName,
name: 'demoDatePickerDescription',
desc: r'Description for date picker demo.');
}
String get demoDatePickerTitle {
return Intl.message('Date Picker',
locale: _localeName,
name: 'demoDatePickerTitle',
desc: r'Title for date picker demo.');
}
String get demoDialogSubtitle {
return Intl.message('Simple, alert, and fullscreen',
locale: _localeName,
@ -2448,6 +2463,27 @@ class GalleryLocalizations {
desc: r'Title for the outline button component demo.');
}
String get demoPickersShowPicker {
return Intl.message('SHOW PICKER',
locale: _localeName,
name: 'demoPickersShowPicker',
desc: r'Button text to show the date or time picker in the demo.');
}
String get demoPickersSubtitle {
return Intl.message('Date and time selection',
locale: _localeName,
name: 'demoPickersSubtitle',
desc: r'Subtitle for pickers demo.');
}
String get demoPickersTitle {
return Intl.message('Pickers',
locale: _localeName,
name: 'demoPickersTitle',
desc: r'Title for pickers demo.');
}
String get demoProgressIndicatorSubtitle {
return Intl.message('Linear, circular, indeterminate',
locale: _localeName,
@ -2931,6 +2967,21 @@ class GalleryLocalizations {
desc: r'The label for an email address input field.');
}
String get demoTimePickerDescription {
return Intl.message(
'Shows a dialog containing a Material Design time picker.',
locale: _localeName,
name: 'demoTimePickerDescription',
desc: r'Description for time picker demo.');
}
String get demoTimePickerTitle {
return Intl.message('Time Picker',
locale: _localeName,
name: 'demoTimePickerTitle',
desc: r'Title for time picker demo.');
}
String get demoToggleButtonDescription {
return Intl.message(
'Toggle buttons can be used to group related options. To emphasize groups of related toggle buttons, a group should share a common container',

@ -1224,6 +1224,34 @@
"@demoLinearProgressIndicatorDescription": {
"description": "Description for linear progress indicator demo."
},
"demoPickersTitle": "Pickers",
"@demoPickersTitle": {
"description": "Title for pickers demo."
},
"demoPickersSubtitle": "Date and time selection",
"@demoPickersSubtitle": {
"description": "Subtitle for pickers demo."
},
"demoDatePickerTitle": "Date Picker",
"@demoDatePickerTitle": {
"description": "Title for date picker demo."
},
"demoDatePickerDescription": "Shows a dialog containing a Material Design date picker.",
"@demoDatePickerDescription": {
"description": "Description for date picker demo."
},
"demoTimePickerTitle": "Time Picker",
"@demoTimePickerTitle": {
"description": "Title for time picker demo."
},
"demoTimePickerDescription": "Shows a dialog containing a Material Design time picker.",
"@demoTimePickerDescription": {
"description": "Description for time picker demo."
},
"demoPickersShowPicker": "SHOW PICKER",
"@demoPickersShowPicker": {
"description": "Button text to show the date or time picker in the demo."
},
"demoTabsTitle": "Tabs",
"@demoTabsTitle": {
"description": "Title for tabs demo."

@ -1157,6 +1157,34 @@
name="demoLinearProgressIndicatorDescription"
description="Description for linear progress indicator demo."
>A Material Design linear progress indicator, also known as a progress bar.</string>
<string
name="demoPickersTitle"
description="Title for pickers demo."
>Pickers</string>
<string
name="demoPickersSubtitle"
description="Subtitle for pickers demo."
>Date and time selection</string>
<string
name="demoDatePickerTitle"
description="Title for date picker demo."
>Date Picker</string>
<string
name="demoDatePickerDescription"
description="Description for date picker demo."
>Shows a dialog containing a Material Design date picker.</string>
<string
name="demoTimePickerTitle"
description="Title for time picker demo."
>Time Picker</string>
<string
name="demoTimePickerDescription"
description="Description for time picker demo."
>Shows a dialog containing a Material Design time picker.</string>
<string
name="demoPickersShowPicker"
description="Button text to show the date or time picker in the demo."
>SHOW PICKER</string>
<string
name="demoTabsTitle"
description="Title for tabs demo."

@ -536,6 +536,10 @@ class MessageLookup extends MessageLookupByLibrary {
"Sliders reflect a range of values along a bar, from which users may select a single value or range of values. The sliders can be themed and customized."),
"demoCustomSlidersTitle":
MessageLookupByLibrary.simpleMessage("Custom Sliders"),
"demoDatePickerDescription": MessageLookupByLibrary.simpleMessage(
"Shows a dialog containing a Material Design date picker."),
"demoDatePickerTitle":
MessageLookupByLibrary.simpleMessage("Date Picker"),
"demoDialogSubtitle": MessageLookupByLibrary.simpleMessage(
"Simple, alert, and fullscreen"),
"demoDialogTitle": MessageLookupByLibrary.simpleMessage("Dialogs"),
@ -638,6 +642,11 @@ class MessageLookup extends MessageLookupByLibrary {
"Outline buttons become opaque and elevate when pressed. They are often paired with raised buttons to indicate an alternative, secondary action."),
"demoOutlineButtonTitle":
MessageLookupByLibrary.simpleMessage("Outline Button"),
"demoPickersShowPicker":
MessageLookupByLibrary.simpleMessage("SHOW PICKER"),
"demoPickersSubtitle":
MessageLookupByLibrary.simpleMessage("Date and time selection"),
"demoPickersTitle": MessageLookupByLibrary.simpleMessage("Pickers"),
"demoProgressIndicatorSubtitle": MessageLookupByLibrary.simpleMessage(
"Linear, circular, indeterminate"),
"demoProgressIndicatorTitle":
@ -764,6 +773,10 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Where can we reach you?"),
"demoTextFieldYourEmailAddress":
MessageLookupByLibrary.simpleMessage("Your email address"),
"demoTimePickerDescription": MessageLookupByLibrary.simpleMessage(
"Shows a dialog containing a Material Design time picker."),
"demoTimePickerTitle":
MessageLookupByLibrary.simpleMessage("Time Picker"),
"demoToggleButtonDescription": MessageLookupByLibrary.simpleMessage(
"Toggle buttons can be used to group related options. To emphasize groups of related toggle buttons, a group should share a common container"),
"demoToggleButtonTitle":

Loading…
Cancel
Save