Skip to content

Commit

Permalink
Beta (flutter#1234)
Browse files Browse the repository at this point in the history
  • Loading branch information
domesticmouse authored May 11, 2022
1 parent fb00d0a commit ccd68f3
Show file tree
Hide file tree
Showing 242 changed files with 1,724 additions and 1,435 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/verify-web-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ jobs:
verify-web-demos:
runs-on: ubuntu-latest
if: github.repository == 'flutter/samples'
strategy:
matrix:
flutter_version:
- stable
- beta
steps:
- name: Checkout
uses: actions/checkout@d171c3b028d844f2bf14e9fdec0c58114451e4bf
Expand All @@ -16,7 +21,7 @@ jobs:
fetch-depth: 0
- uses: subosito/flutter-action@d8687e6979e8ef66d2b2970e2c92c1d8e801d7bf
with:
channel: stable
channel: ${{ matrix.flutter_version }}
- name: Init scripts
run: dart pub get
working-directory: web/_tool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ class _CellState extends State<Cell> with WidgetsBindingObserver {
}
});
// Keep track of what the current platform lifecycle state is.
WidgetsBinding.instance!.addObserver(this);
WidgetsBinding.instance.addObserver(this);
super.initState();
}

@override
void dispose() {
WidgetsBinding.instance!.removeObserver(this);
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}

Expand Down
27 changes: 10 additions & 17 deletions add_to_app/android_view/flutter_module_using_plugin/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
version: "1.16.0"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.0"
flutter:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -78,7 +78,7 @@ packages:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3"
version: "0.6.4"
lints:
dependency: transitive
description:
Expand All @@ -99,7 +99,7 @@ packages:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
version: "0.1.4"
meta:
dependency: transitive
description:
Expand All @@ -120,7 +120,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.1"
plugin_platform_interface:
dependency: transitive
description:
Expand Down Expand Up @@ -153,7 +153,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.2"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -188,14 +188,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.8"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "0.4.9"
url_launcher:
dependency: "direct main"
description:
Expand All @@ -209,7 +202,7 @@ packages:
name: url_launcher_android
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.15"
version: "6.0.16"
url_launcher_ios:
dependency: transitive
description:
Expand Down Expand Up @@ -258,7 +251,7 @@ packages:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
version: "2.1.2"
sdks:
dart: ">=2.14.0 <3.0.0"
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=2.10.0"
191 changes: 110 additions & 81 deletions add_to_app/books/flutter_module_books/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:flutter_module_books/api.dart';
void main() => runApp(const MyApp());

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

@override
Widget build(BuildContext context) {
Expand All @@ -30,30 +30,28 @@ class FlutterBookApiHandler extends FlutterBookApi {

@override
void displayBookDetails(Book book) {
assert(
book != null,
'Non-null book expected from FlutterBookApi.displayBookDetails call.',
);
callback(book);
}
}

class BookDetail extends StatefulWidget {
const BookDetail({this.hostApi, this.flutterApi, Key key}) : super(key: key);
const BookDetail({Key? key, this.hostApi, this.flutterApi, this.book})
: super(key: key);

// These are the outgoing and incoming APIs that are here for injection for
// tests.
final HostBookApi hostApi;
final FlutterBookApi flutterApi;
final HostBookApi? hostApi;
final FlutterBookApi? flutterApi;
final Book? book;

@override
_BookDetailState createState() => _BookDetailState();
State<BookDetail> createState() => _BookDetailState();
}

class _BookDetailState extends State<BookDetail> {
Book book;
Book? book;

HostBookApi hostApi;
late HostBookApi hostApi;

FocusNode textFocusNode = FocusNode();
TextEditingController titleTextController = TextEditingController();
Expand All @@ -63,6 +61,7 @@ class _BookDetailState extends State<BookDetail> {
@override
void initState() {
super.initState();
book = widget.book;

// This `HostBookApi` class instance lets us make outgoing calls to the
// platform.
Expand All @@ -80,19 +79,19 @@ class _BookDetailState extends State<BookDetail> {
// This book model is what we're going to return to Kotlin eventually.
// Keep it bound to the UI.
this.book = book;
titleTextController.text = book.title;
titleTextController.text = book.title ?? '';
titleTextController.addListener(() {
this.book?.title = titleTextController.text;
this.book!.title = titleTextController.text;
});
// Subtitle could be null.
// TODO(gaaclarke): https://github.com/flutter/flutter/issues/59118.
subtitleTextController.text = book.subtitle ?? '';
subtitleTextController.addListener(() {
this.book?.subtitle = subtitleTextController.text;
this.book!.subtitle = subtitleTextController.text;
});
authorTextController.text = book.author;
authorTextController.text = book.author ?? '';
authorTextController.addListener(() {
this.book?.author = authorTextController.text;
this.book!.author = authorTextController.text;
});
});
}));
Expand Down Expand Up @@ -123,81 +122,111 @@ class _BookDetailState extends State<BookDetail> {
IconButton(
icon: const Icon(Icons.check),
// Pressing save sends the updated book to the platform.
onPressed: () {
hostApi.finishEditingBook(book);
clear();
},
onPressed: book != null
? () {
hostApi.finishEditingBook(book!);
clear();
}
: null,
),
],
),
body: book == null
// Draw a spinner until the platform gives us the book to show details
// for.
? const Center(child: CircularProgressIndicator())
: Focus(
: BookForm(
book: book!,
focusNode: textFocusNode,
child: ListView(
padding: const EdgeInsets.all(24),
children: [
TextField(
controller: titleTextController,
decoration: const InputDecoration(
border: OutlineInputBorder(),
filled: true,
hintText: "Title",
labelText: "Title",
),
),
const SizedBox(height: 24),
TextField(
controller: subtitleTextController,
maxLines: 2,
decoration: const InputDecoration(
border: OutlineInputBorder(),
filled: true,
hintText: "Subtitle",
labelText: "Subtitle",
),
),
const SizedBox(height: 24),
TextField(
controller: authorTextController,
decoration: const InputDecoration(
border: OutlineInputBorder(),
filled: true,
hintText: "Author",
labelText: "Author",
),
),
const SizedBox(height: 32),
const Divider(),
Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'${book.pageCount} pages ~ published ${book.publishDate}'),
),
),
const Divider(),
const SizedBox(height: 32),
const Center(
child: Text(
'BOOK DESCRIPTION',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
decoration: TextDecoration.underline,
),
),
),
const SizedBox(height: 12),
Text(
book.summary,
style: TextStyle(color: Colors.grey.shade600, height: 1.24),
),
],
authorTextController: authorTextController,
subtitleTextController: subtitleTextController,
titleTextController: titleTextController,
),
);
}
}

class BookForm extends StatelessWidget {
const BookForm({
Key? key,
required this.book,
required this.focusNode,
required this.authorTextController,
required this.subtitleTextController,
required this.titleTextController,
}) : super(key: key);

final Book book;
final FocusNode focusNode;
final TextEditingController titleTextController;
final TextEditingController subtitleTextController;
final TextEditingController authorTextController;

@override
Widget build(BuildContext context) {
return Focus(
focusNode: focusNode,
child: ListView(
padding: const EdgeInsets.all(24),
children: [
TextField(
controller: titleTextController,
decoration: const InputDecoration(
border: OutlineInputBorder(),
filled: true,
hintText: "Title",
labelText: "Title",
),
),
const SizedBox(height: 24),
TextField(
controller: subtitleTextController,
maxLines: 2,
decoration: const InputDecoration(
border: OutlineInputBorder(),
filled: true,
hintText: "Subtitle",
labelText: "Subtitle",
),
),
const SizedBox(height: 24),
TextField(
controller: authorTextController,
decoration: const InputDecoration(
border: OutlineInputBorder(),
filled: true,
hintText: "Author",
labelText: "Author",
),
),
const SizedBox(height: 32),
const Divider(),
Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'${book.pageCount} pages ~ published ${book.publishDate}'),
),
),
const Divider(),
const SizedBox(height: 32),
const Center(
child: Text(
'BOOK DESCRIPTION',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
decoration: TextDecoration.underline,
),
),
),
const SizedBox(height: 12),
Text(
book.summary ?? '',
style: TextStyle(color: Colors.grey.shade600, height: 1.24),
),
],
),
);
}
}
Loading

0 comments on commit ccd68f3

Please sign in to comment.