1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-09 06:18:49 +00:00
Files
samples/web/samples_index/lib/samples_index.dart
John Ryan 0a5a5109de Add samples index (#359)
* add samples_index to web/ directory

Co-authored-by: Thea Flowers <theaflowers@google.com>

* add pub_get.dart script

* build sample index in peanut post build

* re-generate sample index with web demos

* print more details in peanut_post_build.dart

* add images for demos

* run generator

* update README

* add animations and provider shopper as symlinks

* add links to symlinked web demos

* use relative paths

* update cookbook images, urls, and description CSS

* use relative URL for navbar link

* unstage HTML files

* .gitignore generated HTML files

* add margin to toolbar

* rename escape functions

* add and update copyright headers

Co-authored-by: Thea Flowers <theaflowers@google.com>
2020-03-09 16:17:08 -07:00

24 lines
845 B
Dart

// Copyright 2020 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:convert';
import 'package:resource/resource.dart';
import 'src/data.dart';
import 'package:checked_yaml/checked_yaml.dart';
export 'src/data.dart';
Future<List<Sample>> getSamples() async {
var yamlFile = Resource('package:samples_index/src/samples.yaml');
var cookbookFile = Resource('package:samples_index/src/cookbook.json');
var contents = await yamlFile.readAsString();
var cookbookContents = await cookbookFile.readAsString();
var index = checkedYamlDecode(contents, (m) => Index.fromJson(m),
sourceUrl: yamlFile.uri);
var cookbookIndex = Index.fromJson(json.decode(cookbookContents));
return index.samples..addAll(cookbookIndex.samples);
}