mirror of
https://github.com/flutter/samples.git
synced 2026-04-07 12:14:27 +00:00
Dart 3.9 / Flutter 3.35 [first LLM release] (#2714)
I got carried away with Gemini and basically rewrote CI and the release process for the new LLM reality. This work was largely completed by Gemini. - Bump all SDK versions to the current beta (3.9.0-0) - Run `flutter channel beta` - Wrote `ci_script.dart` to replace the bash scripts - Converted repository to pub workspace #2499 - Added llm.md and release.md - Added redirect for deprecated Samples Index ## Pre-launch Checklist - [x] I read the [Flutter Style Guide] _recently_, and have followed its advice. - [x] I signed the [CLA]. - [x] I read the [Contributors Guide]. - [x] I have added sample code updates to the [changelog]. - [x] I updated/added relevant documentation (doc comments with `///`).
This commit is contained in:
41
add_to_app/fullscreen/flutter_module_fullscreen/.gitignore
vendored
Normal file
41
add_to_app/fullscreen/flutter_module_fullscreen/.gitignore
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
.DS_Store
|
||||
.dart_tool/
|
||||
|
||||
.packages
|
||||
.pub/
|
||||
|
||||
.idea/
|
||||
.vagrant/
|
||||
.sconsign.dblite
|
||||
.svn/
|
||||
|
||||
*.swp
|
||||
profile
|
||||
|
||||
DerivedData/
|
||||
|
||||
.generated/
|
||||
|
||||
*.pbxuser
|
||||
*.mode1v3
|
||||
*.mode2v3
|
||||
*.perspectivev3
|
||||
|
||||
!default.pbxuser
|
||||
!default.mode1v3
|
||||
!default.mode2v3
|
||||
!default.perspectivev3
|
||||
|
||||
xcuserdata
|
||||
|
||||
*.moved-aside
|
||||
|
||||
*.pyc
|
||||
*sync/
|
||||
Icon?
|
||||
.tags*
|
||||
|
||||
build/
|
||||
.android/
|
||||
.ios/
|
||||
.flutter-plugins
|
||||
10
add_to_app/fullscreen/flutter_module_fullscreen/.metadata
Normal file
10
add_to_app/fullscreen/flutter_module_fullscreen/.metadata
Normal file
@@ -0,0 +1,10 @@
|
||||
# This file tracks properties of this Flutter project.
|
||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||
#
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
|
||||
version:
|
||||
revision: 532a8fed41a4f6595965f02f3edf9666ba5ebf44
|
||||
channel: master
|
||||
|
||||
project_type: module
|
||||
14
add_to_app/fullscreen/flutter_module_fullscreen/README.md
Normal file
14
add_to_app/fullscreen/flutter_module_fullscreen/README.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# flutter_module
|
||||
|
||||
An example Flutter module used in the Flutter add-to-app samples. For more
|
||||
information on how to use it, see the [README.md](../README.md) parent
|
||||
directory.
|
||||
|
||||
## Getting Started
|
||||
|
||||
For more information about Flutter, check out
|
||||
[flutter.dev](https://flutter.dev).
|
||||
|
||||
For instructions on how to integrate Flutter modules into your existing
|
||||
applications, see Flutter's
|
||||
[add-to-app documentation](https://flutter.dev/docs/development/add-to-app).
|
||||
@@ -0,0 +1 @@
|
||||
include: package:analysis_defaults/flutter.yaml
|
||||
156
add_to_app/fullscreen/flutter_module_fullscreen/lib/main.dart
Normal file
156
add_to_app/fullscreen/flutter_module_fullscreen/lib/main.dart
Normal file
@@ -0,0 +1,156 @@
|
||||
// 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 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
/// The entrypoint for the flutter module.
|
||||
void main() {
|
||||
// This call ensures the Flutter binding has been set up before creating the
|
||||
// MethodChannel-based model.
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
final model = CounterModel();
|
||||
|
||||
runApp(ChangeNotifierProvider.value(value: model, child: const MyApp()));
|
||||
}
|
||||
|
||||
/// A simple model that uses a [MethodChannel] as the source of truth for the
|
||||
/// state of a counter.
|
||||
///
|
||||
/// Rather than storing app state data within the Flutter module itself (where
|
||||
/// the native portions of the app can't access it), this module passes messages
|
||||
/// back to the containing app whenever it needs to increment or retrieve the
|
||||
/// value of the counter.
|
||||
class CounterModel extends ChangeNotifier {
|
||||
CounterModel() {
|
||||
_channel.setMethodCallHandler(_handleMessage);
|
||||
_channel.invokeMethod<void>('requestCounter');
|
||||
}
|
||||
|
||||
final _channel = const MethodChannel('dev.flutter.example/counter');
|
||||
|
||||
int _count = 0;
|
||||
|
||||
int get count => _count;
|
||||
|
||||
void increment() {
|
||||
_channel.invokeMethod<void>('incrementCounter');
|
||||
}
|
||||
|
||||
Future<dynamic> _handleMessage(MethodCall call) async {
|
||||
if (call.method == 'reportCounter') {
|
||||
_count = call.arguments as int;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The "app" displayed by this module.
|
||||
///
|
||||
/// It offers two routes, one suitable for displaying as a full screen and
|
||||
/// another designed to be part of a larger UI.class MyApp extends StatelessWidget {
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Flutter Module Title',
|
||||
theme: ThemeData.light(),
|
||||
routes: {
|
||||
'/': (context) => const FullScreenView(),
|
||||
'/mini': (context) => const Contents(),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Wraps [Contents] in a Material [Scaffold] so it looks correct when displayed
|
||||
/// full-screen.
|
||||
class FullScreenView extends StatelessWidget {
|
||||
const FullScreenView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Full-screen Flutter')),
|
||||
body: const Contents(showExit: true),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The actual content displayed by the module.
|
||||
///
|
||||
/// This widget displays info about the state of a counter and how much room (in
|
||||
/// logical pixels) it's been given. It also offers buttons to increment the
|
||||
/// counter and (optionally) close the Flutter view.
|
||||
class Contents extends StatelessWidget {
|
||||
final bool showExit;
|
||||
|
||||
const Contents({this.showExit = false, super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final mediaInfo = MediaQuery.of(context);
|
||||
|
||||
return SizedBox.expand(
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Positioned.fill(
|
||||
child: Opacity(
|
||||
opacity: .25,
|
||||
child: FittedBox(fit: BoxFit.cover, child: FlutterLogo()),
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'Window is ${mediaInfo.size.width.toStringAsFixed(1)} x '
|
||||
'${mediaInfo.size.height.toStringAsFixed(1)}',
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Consumer<CounterModel>(
|
||||
builder: (context, model, child) {
|
||||
return Text(
|
||||
'Taps: ${model.count}',
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Consumer<CounterModel>(
|
||||
builder: (context, model, child) {
|
||||
return ElevatedButton(
|
||||
onPressed: () => model.increment(),
|
||||
child: const Text('Tap me!'),
|
||||
);
|
||||
},
|
||||
),
|
||||
if (showExit) ...[
|
||||
const SizedBox(height: 16),
|
||||
ElevatedButton(
|
||||
onPressed: () => SystemNavigator.pop(animated: true),
|
||||
child: const Text('Exit this screen'),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
35
add_to_app/fullscreen/flutter_module_fullscreen/pubspec.yaml
Normal file
35
add_to_app/fullscreen/flutter_module_fullscreen/pubspec.yaml
Normal file
@@ -0,0 +1,35 @@
|
||||
name: flutter_module_fullscreen
|
||||
description: An example Flutter module.
|
||||
version: 1.0.0+1
|
||||
resolution: workspace
|
||||
|
||||
environment:
|
||||
sdk: ^3.9.0-0
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
provider: ^6.0.2
|
||||
|
||||
dev_dependencies:
|
||||
analysis_defaults:
|
||||
path: ../../../analysis_defaults
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
flutter_driver:
|
||||
sdk: flutter
|
||||
espresso: ">=0.2.0 <0.5.0"
|
||||
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
|
||||
# This section identifies your Flutter project as a module meant for
|
||||
# embedding in a native host app. These identifiers should _not_ ordinarily
|
||||
# be changed after generation - they are used to ensure that the tooling can
|
||||
# maintain consistency when adding or modifying assets and plugins.
|
||||
# They also do not have any bearing on your native host application's
|
||||
# identifiers, which may be completely independent or the same as these.
|
||||
module:
|
||||
androidX: true
|
||||
androidPackage: dev.flutter.example.flutter_module
|
||||
iosBundleIdentifier: dev.flutter.example.flutterModule
|
||||
@@ -0,0 +1,47 @@
|
||||
// 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 'package:flutter/material.dart';
|
||||
import 'package:flutter_module_fullscreen/main.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MockCounterModel extends ChangeNotifier implements CounterModel {
|
||||
int _count = 0;
|
||||
|
||||
@override
|
||||
int get count => _count;
|
||||
|
||||
@override
|
||||
void increment() {
|
||||
_count++;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('MiniView smoke test', (tester) async {
|
||||
// Build our app and trigger a frame.
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: ChangeNotifierProvider<CounterModel>.value(
|
||||
value: MockCounterModel(),
|
||||
child: const Contents(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Verify that our counter starts at 0.
|
||||
expect(find.text('Taps: 0'), findsOneWidget);
|
||||
expect(find.text('Taps: 1'), findsNothing);
|
||||
|
||||
// Tap the '+' icon and trigger a frame.
|
||||
await tester.tap(find.text('Tap me!'));
|
||||
await tester.pump();
|
||||
|
||||
// Verify that our counter has incremented.
|
||||
expect(find.text('Taps: 0'), findsNothing);
|
||||
expect(find.text('Taps: 1'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// 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 'package:flutter_driver/driver_extension.dart';
|
||||
import 'package:flutter_module_fullscreen/main.dart' as app;
|
||||
|
||||
// This alternate entrypoint is used for espresso testing. See
|
||||
// https://pub.dev/packages/espresso for details.
|
||||
void main() {
|
||||
enableFlutterDriverExtension();
|
||||
app.main();
|
||||
}
|
||||
Reference in New Issue
Block a user