Skip to content

Commit

Permalink
Add minimum CI possible for dartpad workshops (flutter#133)
Browse files Browse the repository at this point in the history
* Add minimum CI possible for dartpad workshops

This commit has following changes -
1. Add minimum CI possible for dartpad workshops
2. Fix minor issues in snippet and solution dart files
3. Fix links in README.md
4. Rearrange CODELABS list alphabetically amongst the scripts

* Minimum format dartpad workshops files
  • Loading branch information
hrishikesh-kadam committed Jun 1, 2021
1 parent 3664409 commit d0a8417
Show file tree
Hide file tree
Showing 26 changed files with 905 additions and 459 deletions.
12 changes: 7 additions & 5 deletions dartpad_codelabs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ Workshops in this directory are displayed using DartPad.

## Open a workshop

- [Flutter example][flutter-webserver]
- [Dart example][dart-webserver]
- [Flutter example][flutter-webserver]
- [Getting started with Slivers][slivers]
- [Inherted Widget][inherited-widget]
- [Null safety workshop][null-safety-workshop]

Alternatively, these workshops can be loaded from GitHub directly:

- [Dart example (GitHub)][flutter-github]
- [Flutter example (GitHub)][dart-github]
- [Dart example (GitHub)][dart-github]
- [Flutter example (GitHub)][flutter-github]

## Deploying

Expand All @@ -32,5 +33,6 @@ firebase deploy
[dart-webserver]: https://dartpad.dev/workshops.html?webserver=https://dartpad-workshops-io2021.web.app/example_dart
[slivers]: https://dartpad.dev/workshops.html?webserver=https://dartpad-workshops-io2021.web.app/getting_started_with_slivers
[inherited-widget]: https://dartpad.dev/workshops.html?webserver=https://dartpad-workshops-io2021.web.app/inherited_widget
[flutter-github]: https://dartpad.dev/workshops.html?gh_owner=flutter&gh_repo=codelabs&gh_ref=main&gh_path=dartpad_workshops/src/example_dart
[dart-github]: https://dartpad.dev/workshops.html?gh_owner=flutter&gh_repo=codelabs&gh_ref=main&gh_path=dartpad_workshops/src/example_flutter
[dart-github]: https://dartpad.dev/workshops.html?gh_owner=flutter&gh_repo=codelabs&gh_ref=master&gh_path=dartpad_codelabs/src/example_dart
[flutter-github]: https://dartpad.dev/workshops.html?gh_owner=flutter&gh_repo=codelabs&gh_ref=master&gh_path=dartpad_codelabs/src/example_flutter
[null-safety-workshop]: https://dartpad.dev/workshops.html?webserver=https://dartpad-workshops-io2021.web.app/null_safety_workshop
2 changes: 1 addition & 1 deletion dartpad_codelabs/src/example_flutter/step_02/snippet.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';

static const hostingUrl = 'https://dartpad-workshops-io2021.web.app';
const hostingUrl = 'https://dartpad-workshops-io2021.web.app';

void main() => runApp(MyApp());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class HorizonsApp extends StatelessWidget {
backgroundColor: Colors.teal[800],
),
body: WeeklyForecastList(),
)
),
);
}
}
Expand All @@ -37,7 +37,7 @@ class WeeklyForecastList extends StatelessWidget {
final DateTime currentDate = DateTime.now();
final TextTheme textTheme = Theme.of(context).textTheme;
final List<DailyForecast> forecasts = Server.getDailyForecastList();

return SingleChildScrollView(
child: Column(
children: forecasts.map((DailyForecast dailyForecast) {
Expand All @@ -59,61 +59,63 @@ class WeeklyForecastList extends StatelessWidget {
),
);
}).toList(),
)
),
);
}
}

// --------------------------------------------
// Below this line are helper classes and data.

const String baseAssetURL = 'https://dartpad-workshops-io2021.web.app/getting_started_with_slivers/';
const String baseAssetURL =
'https://dartpad-workshops-io2021.web.app/getting_started_with_slivers/';
const String headerImage = '${baseAssetURL}assets/header.jpeg';

const Map<int, DailyForecast> _kDummyData = {
0 : DailyForecast(
0: DailyForecast(
id: 0,
imageId: '${baseAssetURL}assets/day_0.jpeg',
highTemp: 73,
lowTemp: 52,
description: 'Partly cloudy in the morning, with sun appearing in the afternoon.',
description:
'Partly cloudy in the morning, with sun appearing in the afternoon.',
),
1 : DailyForecast(
1: DailyForecast(
id: 1,
imageId: '${baseAssetURL}assets/day_1.jpeg',
highTemp: 70,
lowTemp: 50,
description: 'Partly sunny.',
),
2 : DailyForecast(
2: DailyForecast(
id: 2,
imageId: '${baseAssetURL}assets/day_2.jpeg',
highTemp: 71,
lowTemp: 55,
description: 'Party cloudy.',
),
3 : DailyForecast(
3: DailyForecast(
id: 3,
imageId: '${baseAssetURL}assets/day_3.jpeg',
highTemp: 74,
lowTemp: 60,
description: 'Thunderstorms in the evening.',
),
4 : DailyForecast(
4: DailyForecast(
id: 4,
imageId: '${baseAssetURL}assets/day_4.jpeg',
highTemp: 67,
lowTemp: 60,
description: 'Severe thunderstorm warning.',
),
5 : DailyForecast(
5: DailyForecast(
id: 5,
imageId: '${baseAssetURL}assets/day_5.jpeg',
highTemp: 73,
lowTemp: 57,
description: 'Cloudy with showers in the morning.',
),
6 : DailyForecast(
6: DailyForecast(
id: 6,
imageId: '${baseAssetURL}assets/day_6.jpeg',
highTemp: 75,
Expand All @@ -123,7 +125,8 @@ const Map<int, DailyForecast> _kDummyData = {
};

class Server {
static List<DailyForecast> getDailyForecastList() => _kDummyData.values.toList();
static List<DailyForecast> getDailyForecastList() =>
_kDummyData.values.toList();

static DailyForecast getDailyForecastByID(int id) {
assert(id >= 0 && id <= 6);
Expand All @@ -139,6 +142,7 @@ class DailyForecast {
required this.lowTemp,
required this.description,
});

final int id;
final String imageId;
final int highTemp;
Expand Down Expand Up @@ -168,14 +172,19 @@ class ConstantScrollBehavior extends ScrollBehavior {
const ConstantScrollBehavior();

@override
Widget buildScrollbar(BuildContext context, Widget child, ScrollableDetails details) => child;
Widget buildScrollbar(
BuildContext context, Widget child, ScrollableDetails details) =>
child;

@override
Widget buildOverscrollIndicator(BuildContext context, Widget child, ScrollableDetails details) => child;
Widget buildOverscrollIndicator(
BuildContext context, Widget child, ScrollableDetails details) =>
child;

@override
TargetPlatform getPlatform(BuildContext context) => TargetPlatform.macOS;

@override
ScrollPhysics getScrollPhysics(BuildContext context) => const BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics());
ScrollPhysics getScrollPhysics(BuildContext context) =>
const BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics());
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class HorizonsApp extends StatelessWidget {
backgroundColor: Colors.teal[800],
),
body: WeeklyForecastList(),
)
),
);
}
}
Expand All @@ -36,7 +36,7 @@ class WeeklyForecastList extends StatelessWidget {
Widget build(BuildContext context) {
final DateTime currentDate = DateTime.now();
final TextTheme textTheme = Theme.of(context).textTheme;

// This Scrollable will lazily load widgets as they come into view.
return ListView.builder(
itemCount: 7,
Expand All @@ -59,61 +59,63 @@ class WeeklyForecastList extends StatelessWidget {
),
),
);
}
},
);
}
}

// --------------------------------------------
// Below this line are helper classes and data.

const String baseAssetURL = 'https://dartpad-workshops-io2021.web.app/getting_started_with_slivers/';
const String baseAssetURL =
'https://dartpad-workshops-io2021.web.app/getting_started_with_slivers/';
const String headerImage = '${baseAssetURL}assets/header.jpeg';

const Map<int, DailyForecast> _kDummyData = {
0 : DailyForecast(
0: DailyForecast(
id: 0,
imageId: '${baseAssetURL}assets/day_0.jpeg',
highTemp: 73,
lowTemp: 52,
description: 'Partly cloudy in the morning, with sun appearing in the afternoon.',
description:
'Partly cloudy in the morning, with sun appearing in the afternoon.',
),
1 : DailyForecast(
1: DailyForecast(
id: 1,
imageId: '${baseAssetURL}assets/day_1.jpeg',
highTemp: 70,
lowTemp: 50,
description: 'Partly sunny.',
),
2 : DailyForecast(
2: DailyForecast(
id: 2,
imageId: '${baseAssetURL}assets/day_2.jpeg',
highTemp: 71,
lowTemp: 55,
description: 'Party cloudy.',
),
3 : DailyForecast(
3: DailyForecast(
id: 3,
imageId: '${baseAssetURL}assets/day_3.jpeg',
highTemp: 74,
lowTemp: 60,
description: 'Thunderstorms in the evening.',
),
4 : DailyForecast(
4: DailyForecast(
id: 4,
imageId: '${baseAssetURL}assets/day_4.jpeg',
highTemp: 67,
lowTemp: 60,
description: 'Severe thunderstorm warning.',
),
5 : DailyForecast(
5: DailyForecast(
id: 5,
imageId: '${baseAssetURL}assets/day_5.jpeg',
highTemp: 73,
lowTemp: 57,
description: 'Cloudy with showers in the morning.',
),
6 : DailyForecast(
6: DailyForecast(
id: 6,
imageId: '${baseAssetURL}assets/day_6.jpeg',
highTemp: 75,
Expand All @@ -123,7 +125,8 @@ const Map<int, DailyForecast> _kDummyData = {
};

class Server {
static List<DailyForecast> getDailyForecastList() => _kDummyData.values.toList();
static List<DailyForecast> getDailyForecastList() =>
_kDummyData.values.toList();

static DailyForecast getDailyForecastByID(int id) {
assert(id >= 0 && id <= 6);
Expand All @@ -139,6 +142,7 @@ class DailyForecast {
required this.lowTemp,
required this.description,
});

final int id;
final String imageId;
final int highTemp;
Expand Down Expand Up @@ -168,14 +172,19 @@ class ConstantScrollBehavior extends ScrollBehavior {
const ConstantScrollBehavior();

@override
Widget buildScrollbar(BuildContext context, Widget child, ScrollableDetails details) => child;
Widget buildScrollbar(
BuildContext context, Widget child, ScrollableDetails details) =>
child;

@override
Widget buildOverscrollIndicator(BuildContext context, Widget child, ScrollableDetails details) => child;
Widget buildOverscrollIndicator(
BuildContext context, Widget child, ScrollableDetails details) =>
child;

@override
TargetPlatform getPlatform(BuildContext context) => TargetPlatform.macOS;

@override
ScrollPhysics getScrollPhysics(BuildContext context) => const BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics());
ScrollPhysics getScrollPhysics(BuildContext context) =>
const BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics());
}
Loading

0 comments on commit d0a8417

Please sign in to comment.