Skip to content

Commit

Permalink
dartpad_codelabs: Convert into Flutter project for lints in CI (flu…
Browse files Browse the repository at this point in the history
  • Loading branch information
domesticmouse committed Jan 6, 2022
1 parent 5870090 commit 93ed3d4
Show file tree
Hide file tree
Showing 52 changed files with 1,257 additions and 792 deletions.
9 changes: 9 additions & 0 deletions dartpad_codelabs/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include: ../analysis_options.yaml

analyzer:
strong-mode:
implicit-dynamic: true

linter:
rules:
avoid_print: false
160 changes: 160 additions & 0 deletions dartpad_codelabs/pubspec.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.2"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_lints:
dependency: "direct dev"
description:
name: flutter_lints
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
lints:
dependency: transitive
description:
name: lints
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
sky_engine:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
source_span:
dependency: transitive
description:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.3"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
sdks:
dart: ">=2.15.1 <3.0.0"
19 changes: 19 additions & 0 deletions dartpad_codelabs/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: dartpad_codelabs
description: A new Flutter project.
publish_to: 'none'
version: 1.0.0+1

environment:
sdk: ">=2.15.1 <3.0.0"

dependencies:
flutter:
sdk: flutter

dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^1.0.0

flutter:
uses-material-design: true
15 changes: 10 additions & 5 deletions dartpad_codelabs/src/example_flutter/step_01/snippet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// TODO: Remove the following line
// ignore_for_file: unused_field, prefer_const_literals_to_create_immutables

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return MaterialApp(
Expand All @@ -15,13 +20,13 @@ class MyApp extends StatelessWidget {
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);
const MyHomePage({Key? key, required this.title}) : super(key: key);

final String title;

Expand All @@ -47,15 +52,15 @@ class _MyHomePageState extends State<MyHomePage> {
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
children: [
// Add Code Here
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
child: const Icon(Icons.add),
),
);
}
Expand Down
14 changes: 8 additions & 6 deletions dartpad_codelabs/src/example_flutter/step_01/solution.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return MaterialApp(
Expand All @@ -15,13 +17,13 @@ class MyApp extends StatelessWidget {
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);
const MyHomePage({Key? key, required this.title}) : super(key: key);

final String title;

Expand All @@ -47,8 +49,8 @@ class _MyHomePageState extends State<MyHomePage> {
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
children: [
const Text(
'You have pushed the button this many times:',
),
Text(
Expand All @@ -61,7 +63,7 @@ class _MyHomePageState extends State<MyHomePage> {
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
child: const Icon(Icons.add),
),
);
}
Expand Down
4 changes: 3 additions & 1 deletion dartpad_codelabs/src/example_flutter/step_02/snippet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import 'package:flutter/material.dart';

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

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

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
var title = 'Web Images';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import 'package:flutter/material.dart';

void main() {
runApp(HorizonsApp());
runApp(const HorizonsApp());
}

class HorizonsApp extends StatelessWidget {
const HorizonsApp({Key? key}) : super(key: key);

// This widget is the root of your application.
@override
Widget build(BuildContext context) {
Expand All @@ -22,16 +24,18 @@ class HorizonsApp extends StatelessWidget {
title: 'Horizons Weather',
home: Scaffold(
appBar: AppBar(
title: Text('Horizons'),
title: const Text('Horizons'),
backgroundColor: Colors.teal[800],
),
body: WeeklyForecastList(),
body: const WeeklyForecastList(),
),
);
}
}

class WeeklyForecastList extends StatelessWidget {
const WeeklyForecastList({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
final DateTime currentDate = DateTime.now();
Expand All @@ -40,7 +44,7 @@ class WeeklyForecastList extends StatelessWidget {

return SingleChildScrollView(
child: Column(
children: forecasts.map((DailyForecast dailyForecast) {
children: forecasts.map((dailyForecast) {
return Card(
child: ListTile(
leading: Text(
Expand Down
Loading

0 comments on commit 93ed3d4

Please sign in to comment.