text
stringlengths
6
13.6M
id
stringlengths
13
176
metadata
dict
__index_level_0__
int64
0
1.69k
import 'package:flutter/material.dart'; // #docregion Starter // Define a custom Form widget. class MyCustomForm extends StatefulWidget { const MyCustomForm({super.key}); @override State<MyCustomForm> createState() => _MyCustomFormState(); } // Define a corresponding State class. // This class holds the data related to the Form. class _MyCustomFormState extends State<MyCustomForm> { // Create a text controller and use it to retrieve the current value // of the TextField. final myController = TextEditingController(); @override void dispose() { // Clean up the controller when the widget is disposed. myController.dispose(); super.dispose(); } @override Widget build(BuildContext context) { // Fill this out in the next step. return Container(); } } // #enddocregion Starter
website/examples/cookbook/forms/retrieve_input/lib/starter.dart/0
{ "file_path": "website/examples/cookbook/forms/retrieve_input/lib/starter.dart", "repo_id": "website", "token_count": 242 }
1,371
import 'dart:async'; import 'package:games_services/games_services.dart'; import 'package:logging/logging.dart'; /// Allows awarding achievements and leaderboard scores, /// and also showing the platforms' UI overlays for achievements /// and leaderboards. /// /// A facade of `package:games_services`. class GamesServicesController { static final Logger _log = Logger('GamesServicesController'); final Completer<bool> _signedInCompleter = Completer(); Future<bool> get signedIn => _signedInCompleter.future; /// Unlocks an achievement on Game Center / Play Games. /// /// You must provide the achievement ids via the [iOS] and [android] /// parameters. /// /// Does nothing when the game isn't signed into the underlying /// games service. Future<void> awardAchievement( {required String iOS, required String android}) async { if (!await signedIn) { _log.warning('Trying to award achievement when not logged in.'); return; } try { await GamesServices.unlock( achievement: Achievement( androidID: android, iOSID: iOS, ), ); } catch (e) { _log.severe('Cannot award achievement: $e'); } } /// Signs into the underlying games service. Future<void> initialize() async { try { await GamesServices.signIn(); // The API is unclear so we're checking to be sure. The above call // returns a String, not a boolean, and there's no documentation // as to whether every non-error result means we're safely signed in. final signedIn = await GamesServices.isSignedIn; _signedInCompleter.complete(signedIn); } catch (e) { _log.severe('Cannot log into GamesServices: $e'); _signedInCompleter.complete(false); } } /// Launches the platform's UI overlay with achievements. Future<void> showAchievements() async { if (!await signedIn) { _log.severe('Trying to show achievements when not logged in.'); return; } try { await GamesServices.showAchievements(); } catch (e) { _log.severe('Cannot show achievements: $e'); } } /// Launches the platform's UI overlay with leaderboard(s). Future<void> showLeaderboard() async { if (!await signedIn) { _log.severe('Trying to show leaderboard when not logged in.'); return; } try { await GamesServices.showLeaderboards( // TODO: When ready, change both these leaderboard IDs. iOSLeaderboardID: 'some_id_from_app_store', androidLeaderboardID: 'sOmE_iD_fRoM_gPlAy', ); } catch (e) { _log.severe('Cannot show leaderboard: $e'); } } /// Submits [score] to the leaderboard. Future<void> submitLeaderboardScore(int score) async { if (!await signedIn) { _log.warning('Trying to submit leaderboard when not logged in.'); return; } _log.info('Submitting $score to leaderboard.'); try { await GamesServices.submitScore( score: Score( // TODO: When ready, change these leaderboard IDs. iOSLeaderboardID: 'some_id_from_app_store', androidLeaderboardID: 'sOmE_iD_fRoM_gPlAy', value: score, ), ); } catch (e) { _log.severe('Cannot submit leaderboard score: $e'); } } }
website/examples/cookbook/games/achievements_leaderboards/lib/games_services_controller.dart/0
{ "file_path": "website/examples/cookbook/games/achievements_leaderboards/lib/games_services_controller.dart", "repo_id": "website", "token_count": 1220 }
1,372
import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } // MyApp is a StatefulWidget. This allows updating the state of the // widget when an item is removed. class MyApp extends StatefulWidget { const MyApp({super.key}); @override MyAppState createState() { return MyAppState(); } } class MyAppState extends State<MyApp> { final items = List<String>.generate(20, (i) => 'Item ${i + 1}'); @override Widget build(BuildContext context) { const title = 'Dismissing Items'; return MaterialApp( title: title, theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), ), home: Scaffold( appBar: AppBar( title: const Text(title), ), body: ListView.builder( itemCount: items.length, // #docregion Dismissible itemBuilder: (context, index) { final item = items[index]; return Dismissible( // Each Dismissible must contain a Key. Keys allow Flutter to // uniquely identify widgets. key: Key(item), // Provide a function that tells the app // what to do after an item has been swiped away. onDismissed: (direction) { // Remove the item from the data source. setState(() { items.removeAt(index); }); // Then show a snackbar. ScaffoldMessenger.of(context) .showSnackBar(SnackBar(content: Text('$item dismissed'))); }, child: ListTile( title: Text(item), ), ); }, // #enddocregion Dismissible ), ), ); } }
website/examples/cookbook/gestures/dismissible/lib/step2.dart/0
{ "file_path": "website/examples/cookbook/gestures/dismissible/lib/step2.dart", "repo_id": "website", "token_count": 851 }
1,373
import 'package:flutter/material.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { const title = 'Horizontal List'; return MaterialApp( title: title, home: Scaffold( appBar: AppBar( title: const Text(title), ), body: Container( margin: const EdgeInsets.symmetric(vertical: 20), height: 200, // #docregion ListView child: ListView( // This next line does the trick. scrollDirection: Axis.horizontal, children: <Widget>[ Container( width: 160, color: Colors.red, ), Container( width: 160, color: Colors.blue, ), Container( width: 160, color: Colors.green, ), Container( width: 160, color: Colors.yellow, ), Container( width: 160, color: Colors.orange, ), ], ), // #enddocregion ListView ), ), ); } }
website/examples/cookbook/lists/horizontal_list/lib/main.dart/0
{ "file_path": "website/examples/cookbook/lists/horizontal_list/lib/main.dart", "repo_id": "website", "token_count": 717 }
1,374
import 'package:flutter/material.dart'; void main() => runApp(const HeroApp()); class HeroApp extends StatelessWidget { const HeroApp({super.key}); @override Widget build(BuildContext context) { return const MaterialApp( title: 'Transition Demo', home: MainScreen(), ); } } class MainScreen extends StatelessWidget { const MainScreen({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Main Screen'), ), body: GestureDetector( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) { return const DetailScreen(); })); }, // #docregion Hero1 child: Hero( tag: 'imageHero', child: Image.network( 'https://picsum.photos/250?image=9', ), ), // #enddocregion Hero1 ), ); } } class DetailScreen extends StatelessWidget { const DetailScreen({super.key}); @override Widget build(BuildContext context) { return Scaffold( body: GestureDetector( onTap: () { Navigator.pop(context); }, child: Center( // #docregion Hero2 child: Hero( tag: 'imageHero', child: Image.network( 'https://picsum.photos/250?image=9', ), ), // #enddocregion Hero2 ), ), ); } }
website/examples/cookbook/navigation/hero_animations/lib/main.dart/0
{ "file_path": "website/examples/cookbook/navigation/hero_animations/lib/main.dart", "repo_id": "website", "token_count": 684 }
1,375
name: background_parsing description: Background parsing environment: sdk: ^3.3.0 dependencies: flutter: sdk: flutter http: ^1.2.0 dev_dependencies: example_utils: path: ../../../example_utils flutter: uses-material-design: true
website/examples/cookbook/networking/background_parsing/pubspec.yaml/0
{ "file_path": "website/examples/cookbook/networking/background_parsing/pubspec.yaml", "repo_id": "website", "token_count": 97 }
1,376
import 'dart:async'; import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; Future<Album> fetchAlbum() async { final response = await http.get( Uri.parse('https://jsonplaceholder.typicode.com/albums/1'), ); if (response.statusCode == 200) { // If the server did return a 200 OK response, // then parse the JSON. return Album.fromJson(jsonDecode(response.body) as Map<String, dynamic>); } else { // If the server did not return a 200 OK response, // then throw an exception. throw Exception('Failed to load album'); } } Future<Album> updateAlbum(String title) async { final response = await http.put( Uri.parse('https://jsonplaceholder.typicode.com/albums/1'), headers: <String, String>{ 'Content-Type': 'application/json; charset=UTF-8', }, body: jsonEncode(<String, String>{ 'title': title, }), ); if (response.statusCode == 200) { // If the server did return a 200 OK response, // then parse the JSON. return Album.fromJson(jsonDecode(response.body) as Map<String, dynamic>); } else { // If the server did not return a 200 OK response, // then throw an exception. throw Exception('Failed to update album.'); } } class Album { final int id; final String title; const Album({required this.id, required this.title}); factory Album.fromJson(Map<String, dynamic> json) { return switch (json) { { 'id': int id, 'title': String title, } => Album( id: id, title: title, ), _ => throw const FormatException('Failed to load album.'), }; } } void main() { runApp(const MyApp()); } class MyApp extends StatefulWidget { const MyApp({super.key}); @override State<MyApp> createState() { return _MyAppState(); } } class _MyAppState extends State<MyApp> { final TextEditingController _controller = TextEditingController(); late Future<Album> _futureAlbum; @override void initState() { super.initState(); _futureAlbum = fetchAlbum(); } @override Widget build(BuildContext context) { return MaterialApp( title: 'Update Data Example', theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), ), home: Scaffold( appBar: AppBar( title: const Text('Update Data Example'), ), body: Container( alignment: Alignment.center, padding: const EdgeInsets.all(8), ), ), ); } void futureBuilder() { // #docregion FutureBuilder FutureBuilder<Album>( future: _futureAlbum, builder: (context, snapshot) { if (snapshot.hasData) { return Text(snapshot.data!.title); } else if (snapshot.hasError) { return Text('${snapshot.error}'); } return const CircularProgressIndicator(); }, ); // #enddocregion FutureBuilder } void column() { // #docregion Column Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Padding( padding: const EdgeInsets.all(8), child: TextField( controller: _controller, decoration: const InputDecoration(hintText: 'Enter Title'), ), ), ElevatedButton( onPressed: () { setState(() { _futureAlbum = updateAlbum(_controller.text); }); }, child: const Text('Update Data'), ), ], ); // #enddocregion Column } }
website/examples/cookbook/networking/update_data/lib/main_step5.dart/0
{ "file_path": "website/examples/cookbook/networking/update_data/lib/main_step5.dart", "repo_id": "website", "token_count": 1485 }
1,377
class Dog { final int id; final String name; final int age; const Dog({ required this.id, required this.name, required this.age, }); }
website/examples/cookbook/persistence/sqlite/lib/step2.dart/0
{ "file_path": "website/examples/cookbook/persistence/sqlite/lib/step2.dart", "repo_id": "website", "token_count": 59 }
1,378
name: play_video description: A new Flutter project. publish_to: none # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: sdk: ^3.3.0 dependencies: flutter: sdk: flutter video_player: ^2.8.2 dev_dependencies: example_utils: path: ../../../example_utils flutter_test: sdk: flutter flutter: uses-material-design: true
website/examples/cookbook/plugins/play_video/pubspec.yaml/0
{ "file_path": "website/examples/cookbook/plugins/play_video/pubspec.yaml", "repo_id": "website", "token_count": 147 }
1,379
import 'package:counter_app/counter.dart'; import 'package:test/test.dart'; void main() { group('Test start, increment, decrement', () { test('value should start at 0', () { expect(Counter().value, 0); }); test('value should be incremented', () { final counter = Counter(); counter.increment(); expect(counter.value, 1); }); test('value should be decremented', () { final counter = Counter(); counter.decrement(); expect(counter.value, -1); }); }); }
website/examples/cookbook/testing/unit/counter_app/test/group.dart/0
{ "file_path": "website/examples/cookbook/testing/unit/counter_app/test/group.dart", "repo_id": "website", "token_count": 196 }
1,380
// Used to generate `generated_pigeon.dart` with: // ignore_for_file: one_member_abstracts // dart run pigeon --input lib/pigeon_source.dart --dart_out lib/generated_pigeon.dart // #docregion Search import 'package:pigeon/pigeon.dart'; class SearchRequest { final String query; SearchRequest({required this.query}); } class SearchReply { final String result; SearchReply({required this.result}); } @HostApi() abstract class Api { @async SearchReply search(SearchRequest request); } // #enddocregion Search
website/examples/development/platform_integration/lib/pigeon_source.dart/0
{ "file_path": "website/examples/development/platform_integration/lib/pigeon_source.dart", "repo_id": "website", "token_count": 173 }
1,381
// ignore_for_file: avoid_print // #docregion Const const foo = 1; int get bar => foo; // ...or provide a getter. void onClick() { print(foo); print(bar); } // #enddocregion Const
website/examples/development/tools/lib/hot-reload/getter.dart/0
{ "file_path": "website/examples/development/tools/lib/hot-reload/getter.dart", "repo_id": "website", "token_count": 66 }
1,382
name: codelab_web description: Sample codelab for web publish_to: none version: 1.0.0+1 environment: sdk: ^3.3.0 dependencies: flutter: sdk: flutter cupertino_icons: ^1.0.6 dev_dependencies: example_utils: path: ../../example_utils integration_test: sdk: flutter flutter_test: sdk: flutter
website/examples/get-started/codelab_web/pubspec.yaml/0
{ "file_path": "website/examples/get-started/codelab_web/pubspec.yaml", "repo_id": "website", "token_count": 139 }
1,383
import 'dart:async'; import 'dart:convert'; import 'dart:isolate'; import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; void main() { runApp(const SampleApp()); } class SampleApp extends StatelessWidget { const SampleApp({super.key}); @override Widget build(BuildContext context) { return const MaterialApp( title: 'Sample App', home: SampleAppPage(), ); } } class SampleAppPage extends StatefulWidget { const SampleAppPage({super.key}); @override State<SampleAppPage> createState() => _SampleAppPageState(); } class _SampleAppPageState extends State<SampleAppPage> { List<Map<String, dynamic>> data = <Map<String, dynamic>>[]; @override void initState() { super.initState(); loadData(); } bool get showLoadingDialog => data.isEmpty; // #docregion loadData Future<void> loadData() async { final ReceivePort receivePort = ReceivePort(); await Isolate.spawn(dataLoader, receivePort.sendPort); // The 'echo' isolate sends its SendPort as the first message. final SendPort sendPort = await receivePort.first as SendPort; final List<Map<String, dynamic>> msg = await sendReceive( sendPort, 'https://jsonplaceholder.typicode.com/posts', ); setState(() { data = msg; }); } // The entry point for the isolate. static Future<void> dataLoader(SendPort sendPort) async { // Open the ReceivePort for incoming messages. final ReceivePort port = ReceivePort(); // Notify any other isolates what port this isolate listens to. sendPort.send(port.sendPort); await for (final dynamic msg in port) { final String url = msg[0] as String; final SendPort replyTo = msg[1] as SendPort; final Uri dataURL = Uri.parse(url); final http.Response response = await http.get(dataURL); // Lots of JSON to parse replyTo.send(jsonDecode(response.body) as List<Map<String, dynamic>>); } } Future<List<Map<String, dynamic>>> sendReceive(SendPort port, String msg) { final ReceivePort response = ReceivePort(); port.send(<dynamic>[msg, response.sendPort]); return response.first as Future<List<Map<String, dynamic>>>; } // #enddocregion loadData Widget getBody() { bool showLoadingDialog = data.isEmpty; if (showLoadingDialog) { return getProgressDialog(); } else { return getListView(); } } Widget getProgressDialog() { return const Center(child: CircularProgressIndicator()); } ListView getListView() { return ListView.builder( itemCount: data.length, itemBuilder: (context, position) { return getRow(position); }, ); } Widget getRow(int i) { return Padding( padding: const EdgeInsets.all(10), child: Text("Row ${data[i]["title"]}"), ); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Sample App'), ), body: getBody(), ); } }
website/examples/get-started/flutter-for/ios_devs/lib/isolates.dart/0
{ "file_path": "website/examples/get-started/flutter-for/ios_devs/lib/isolates.dart", "repo_id": "website", "token_count": 1086 }
1,384
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; void main() { runApp( const MaterialApp( home: Scaffold( body: Center( child: ElevatedButton( onPressed: _incrementCounter, child: Text('Increment Counter'), ), ), ), ), ); } Future<void> _incrementCounter() async { SharedPreferences prefs = await SharedPreferences.getInstance(); int counter = (prefs.getInt('counter') ?? 0) + 1; await prefs.setInt('counter', counter); }
website/examples/get-started/flutter-for/ios_devs/lib/shared_prefs.dart/0
{ "file_path": "website/examples/get-started/flutter-for/ios_devs/lib/shared_prefs.dart", "repo_id": "website", "token_count": 244 }
1,385
// ignore_for_file: avoid_print import 'dart:convert'; // #docregion ImportDartIO import 'dart:io'; // #enddocregion ImportDartIO // #docregion PackageImport import 'package:flutter/material.dart'; // #enddocregion PackageImport // #docregion SharedPrefs import 'package:shared_preferences/shared_preferences.dart'; // #enddocregion SharedPrefs // #docregion Main // Dart void main() { print('Hello, this is the main function.'); } // #enddocregion Main class MyWidget extends StatelessWidget { const MyWidget({super.key}); @override Widget build(BuildContext context) { // #docregion ImageAsset return Image.asset('assets/background.png'); // #enddocregion ImageAsset } } class NetworkImage extends StatelessWidget { const NetworkImage({super.key}); @override Widget build(BuildContext context) { // #docregion ImageNetwork return Image.network('https://docs.flutter.dev/assets/images/docs/owl.jpg'); // #enddocregion ImageNetwork } } class ListViewExample extends StatelessWidget { const ListViewExample({super.key}); @override Widget build(BuildContext context) { // #docregion ListView var data = [ 'Hello', 'World', ]; return ListView.builder( itemCount: data.length, itemBuilder: (context, index) { return Text(data[index]); }, ); // #enddocregion ListView } } // #docregion CustomPaint class MyCanvasPainter extends CustomPainter { const MyCanvasPainter(); @override void paint(Canvas canvas, Size size) { final Paint paint = Paint()..color = Colors.amber; canvas.drawCircle(const Offset(100, 200), 40, paint); final Paint paintRect = Paint()..color = Colors.lightBlue; final Rect rect = Rect.fromPoints( const Offset(150, 300), const Offset(300, 400), ); canvas.drawRect(rect, paintRect); } @override bool shouldRepaint(MyCanvasPainter oldDelegate) => false; } class MyCanvasWidget extends StatelessWidget { const MyCanvasWidget({super.key}); @override Widget build(BuildContext context) { return const Scaffold( body: CustomPaint(painter: MyCanvasPainter()), ); } } // #enddocregion CustomPaint class TextStyleExample extends StatelessWidget { const TextStyleExample({super.key}); @override Widget build(BuildContext context) { // #docregion TextStyle const TextStyle textStyle = TextStyle( color: Colors.cyan, fontSize: 32, fontWeight: FontWeight.w600, ); return const Center( child: Column( children: <Widget>[ Text('Sample text', style: textStyle), Padding( padding: EdgeInsets.all(20), child: Icon( Icons.lightbulb_outline, size: 48, color: Colors.redAccent, ), ), ], ), ); // #enddocregion TextStyle } } class IconExample extends StatelessWidget { const IconExample({super.key}); @override Widget build(BuildContext context) { // #docregion Icon return const Icon(Icons.lightbulb_outline, color: Colors.redAccent); // #enddocregion Icon } } // #docregion Swatch class SampleApp extends StatelessWidget { const SampleApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Sample App', theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), textSelectionTheme: const TextSelectionThemeData(selectionColor: Colors.red)), home: const SampleAppPage(), ); } } // #enddocregion Swatch class ThemeExample extends StatelessWidget { const ThemeExample({super.key}); // #docregion Theme @override Widget build(BuildContext context) { return MaterialApp( theme: ThemeData( primaryColor: Colors.cyan, brightness: Brightness.dark, ), home: const StylingPage(), ); } // #enddocregion Theme } class StylingPage extends StatelessWidget { const StylingPage({super.key}); @override Widget build(BuildContext context) { return const Text('Hello World!'); } } class SampleAppPage extends StatelessWidget { const SampleAppPage({super.key}); @override Widget build(BuildContext context) { return const Text('Hello World!'); } } class ThemeDataExample extends StatelessWidget { const ThemeDataExample({super.key, required this.brightness}); final Brightness brightness; // #docregion ThemeData @override Widget build(BuildContext context) { return Theme( data: ThemeData( primaryColor: Colors.cyan, brightness: brightness, ), child: Scaffold( backgroundColor: Theme.of(context).primaryColor, //... ), ); } // #enddocregion ThemeData } class SharedPrefsExample extends StatefulWidget { const SharedPrefsExample({super.key}); @override State<SharedPrefsExample> createState() => _SharedPrefsExampleState(); } class _SharedPrefsExampleState extends State<SharedPrefsExample> { int? _counter; // #docregion SharedPrefsUpdate Future<void> updateCounter() async { final prefs = await SharedPreferences.getInstance(); int? counter = prefs.getInt('counter'); if (counter is int) { await prefs.setInt('counter', ++counter); } setState(() { _counter = counter; }); } // #enddocregion SharedPrefsUpdate @override Widget build(BuildContext context) { return Text(_counter.toString()); } } class DrawerExample extends StatelessWidget { const DrawerExample({super.key}); // #docregion Drawer @override Widget build(BuildContext context) { return Drawer( elevation: 20, child: ListTile( leading: const Icon(Icons.change_history), title: const Text('Screen2'), onTap: () { Navigator.of(context).pushNamed('/b'); }, ), ); } // #enddocregion Drawer } class ScaffoldExample extends StatelessWidget { const ScaffoldExample({super.key}); // #docregion Scaffold @override Widget build(BuildContext context) { return Scaffold( drawer: Drawer( elevation: 20, child: ListTile( leading: const Icon(Icons.change_history), title: const Text('Screen2'), onTap: () { Navigator.of(context).pushNamed('/b'); }, ), ), appBar: AppBar(title: const Text('Home')), body: Container(), ); } // #enddocregion Scaffold } class GestureDetectorExample extends StatelessWidget { const GestureDetectorExample({super.key}); // #docregion GestureDetector @override Widget build(BuildContext context) { return GestureDetector( child: Scaffold( appBar: AppBar(title: const Text('Gestures')), body: const Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text('Tap, Long Press, Swipe Horizontally or Vertically'), ], )), ), onTap: () { print('Tapped'); }, onLongPress: () { print('Long Pressed'); }, onVerticalDragEnd: (value) { print('Swiped Vertically'); }, onHorizontalDragEnd: (value) { print('Swiped Horizontally'); }, ); } // #enddocregion GestureDetector } class HttpExample extends StatefulWidget { const HttpExample({super.key}); @override State<HttpExample> createState() => _HttpExampleState(); } class _HttpExampleState extends State<HttpExample> { String _ipAddress = ''; // #docregion HTTP final url = Uri.parse('https://httpbin.org/ip'); final httpClient = HttpClient(); Future<void> getIPAddress() async { final request = await httpClient.getUrl(url); final response = await request.close(); final responseBody = await response.transform(utf8.decoder).join(); final ip = jsonDecode(responseBody)['origin'] as String; setState(() { _ipAddress = ip; }); } // #enddocregion HTTP @override Widget build(BuildContext context) { return Text(_ipAddress); } } class TextEditingExample extends StatefulWidget { const TextEditingExample({super.key}); @override State<TextEditingExample> createState() => _TextEditingExampleState(); } class _TextEditingExampleState extends State<TextEditingExample> { // #docregion TextEditingController final TextEditingController _controller = TextEditingController(); @override Widget build(BuildContext context) { return Column(children: [ TextField( controller: _controller, decoration: const InputDecoration( hintText: 'Type something', labelText: 'Text Field', ), ), ElevatedButton( child: const Text('Submit'), onPressed: () { showDialog( context: context, builder: (context) { return AlertDialog( title: const Text('Alert'), content: Text('You typed ${_controller.text}'), ); }); }, ), ]); } // #enddocregion TextEditingController } class FormExample extends StatefulWidget { const FormExample({super.key}); @override State<FormExample> createState() => _FormExampleState(); } class _FormExampleState extends State<FormExample> { final formKey = GlobalKey<FormState>(); String? _email = ''; final String _password = ''; // #docregion FormSubmit void _submit() { final form = formKey.currentState; if (form != null && form.validate()) { form.save(); showDialog( context: context, builder: (context) { return AlertDialog( title: const Text('Alert'), content: Text('Email: $_email, password: $_password')); }, ); } } // #enddocregion FormSubmit // #docregion FormState @override Widget build(BuildContext context) { return Form( key: formKey, child: Column( children: <Widget>[ TextFormField( validator: (value) { if (value != null && value.contains('@')) { return null; } return 'Not a valid email.'; }, onSaved: (val) { _email = val; }, decoration: const InputDecoration( hintText: 'Enter your email', labelText: 'Email', ), ), ElevatedButton( onPressed: _submit, child: const Text('Login'), ), ], ), ); } // #enddocregion FormState } class PlatformExample extends StatelessWidget { const PlatformExample({super.key}); String whichPlatform(BuildContext context) { // #docregion Platform final platform = Theme.of(context).platform; if (platform == TargetPlatform.iOS) { return 'iOS'; } if (platform == TargetPlatform.android) { return 'android'; } if (platform == TargetPlatform.fuchsia) { return 'fuchsia'; } return 'not recognized '; // #enddocregion Platform } @override Widget build(BuildContext context) { return Text(whichPlatform(context)); } } class DismissableWidgets extends StatefulWidget { const DismissableWidgets({super.key}); @override State<DismissableWidgets> createState() => _DismissableWidgetsState(); } class _DismissableWidgetsState extends State<DismissableWidgets> { final List<Card> cards = [ const Card( child: Text('Hello!'), ), const Card( child: Text('World!'), ) ]; @override Widget build(BuildContext context) { // #docregion Dismissable return Dismissible( key: Key(widget.key.toString()), onDismissed: (dismissDirection) { cards.removeLast(); }, child: Container( //... ), ); // #enddocregion Dismissable } }
website/examples/get-started/flutter-for/react_native_devs/lib/examples.dart/0
{ "file_path": "website/examples/get-started/flutter-for/react_native_devs/lib/examples.dart", "repo_id": "website", "token_count": 4740 }
1,386
import 'dart:async'; import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; void main() { runApp(const SampleApp()); } class SampleApp extends StatelessWidget { const SampleApp({super.key}); @override Widget build(BuildContext context) { return const MaterialApp( title: 'Sample App', home: SampleAppPage(), ); } } class SampleAppPage extends StatefulWidget { const SampleAppPage({super.key}); @override State<SampleAppPage> createState() => _SampleAppPageState(); } class _SampleAppPageState extends State<SampleAppPage> { List<Map<String, dynamic>> data = <Map<String, dynamic>>[]; @override void initState() { super.initState(); loadData(); } bool get showLoadingDialog => data.isEmpty; Future<void> loadData() async { final Uri dataURL = Uri.parse( 'https://jsonplaceholder.typicode.com/posts', ); final http.Response response = await http.get(dataURL); setState(() { data = jsonDecode(response.body); }); } Widget getBody() { if (showLoadingDialog) { return getProgressDialog(); } return getListView(); } Widget getProgressDialog() { return const Center(child: CircularProgressIndicator()); } ListView getListView() { return ListView.builder( itemCount: data.length, itemBuilder: (context, index) { return getRow(index); }, ); } Widget getRow(int index) { return Padding( padding: const EdgeInsets.all(10), child: Text('Row ${data[index]['title']}'), ); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const Text('Sample App')), body: getBody(), ); } }
website/examples/get-started/flutter-for/xamarin_devs/lib/loading.dart/0
{ "file_path": "website/examples/get-started/flutter-for/xamarin_devs/lib/loading.dart", "repo_id": "website", "token_count": 655 }
1,387
// 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/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), ), home: const MyHomePage(title: 'Flutter Demo Home Page'), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({ super.key, required this.title, }); final String title; @override State<MyHomePage> createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { int _counter = 0; void _incrementCounter() { setState(() { _counter++; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(widget.title), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ const Text( 'You have pushed the button this many times:', ), Text( '$_counter', style: Theme.of(context).textTheme.headlineMedium, ), ], ), ), floatingActionButton: FloatingActionButton( // Provide a Key to this button. This allows finding this // specific button inside the test suite, and tapping it. key: const Key('increment'), onPressed: _incrementCounter, tooltip: 'Increment', child: const Icon(Icons.add), ), ); } }
website/examples/integration_test/lib/main.dart/0
{ "file_path": "website/examples/integration_test/lib/main.dart", "repo_id": "website", "token_count": 746 }
1,388
import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'nn_intl.dart'; void main() { runApp( // #docregion MaterialApp const MaterialApp( localizationsDelegates: [ GlobalWidgetsLocalizations.delegate, GlobalMaterialLocalizations.delegate, NnMaterialLocalizations.delegate, // Add the newly created delegate ], supportedLocales: [ Locale('en', 'US'), Locale('nn'), ], home: Home(), ), // #enddocregion MaterialApp ); } class Home extends StatelessWidget { const Home({super.key}); @override Widget build(BuildContext context) { return Localizations.override( context: context, locale: const Locale('nn'), child: Scaffold( appBar: AppBar(), drawer: Drawer( child: ListTile( leading: const Icon(Icons.change_history), title: const Text('Change history'), onTap: () { Navigator.pop(context); // close the drawer }, ), ), body: const Center( child: Padding( padding: EdgeInsets.all(50), child: Text( 'Long press hamburger icon in the app bar (aka the drawer menu)' 'to see a localized tooltip for the `nn` locale. '), ), ), ), ); } }
website/examples/internationalization/add_language/lib/main.dart/0
{ "file_path": "website/examples/internationalization/add_language/lib/main.dart", "repo_id": "website", "token_count": 636 }
1,389
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart // This is a library that provides messages for a en locale. All the // messages from the main program should be duplicated here with the same // function name. // Ignore issues from commonly used lints in this file. // ignore_for_file:unnecessary_brace_in_string_interps // ignore_for_file:prefer_single_quotes,comment_references, directives_ordering // ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases // ignore_for_file:unused_import, file_names import 'package:intl/intl.dart'; import 'package:intl/message_lookup_by_library.dart'; final messages = MessageLookup(); typedef String? MessageIfAbsent(String? messageStr, List<Object>? args); class MessageLookup extends MessageLookupByLibrary { @override String get localeName => 'en'; @override final Map<String, dynamic> messages = _notInlinedMessages(_notInlinedMessages); static Map<String, dynamic> _notInlinedMessages(_) => {'title': MessageLookupByLibrary.simpleMessage('Hello World')}; }
website/examples/internationalization/intl_example/lib/l10n/messages_en.dart/0
{ "file_path": "website/examples/internationalization/intl_example/lib/l10n/messages_en.dart", "repo_id": "website", "token_count": 333 }
1,390
// Basic Flutter widget test. Learn more at https://docs.flutter.dev/testing. import 'package:flutter_test/flutter_test.dart'; import 'package:layout/main.dart'; void main() { testWidgets('Codelab smoke test', (tester) async { await tester.pumpWidget(const MyApp()); expect(find.text('Hello World'), findsOneWidget); }); }
website/examples/layout/base/test/widget_test.dart/0
{ "file_path": "website/examples/layout/base/test/widget_test.dart", "repo_id": "website", "token_count": 116 }
1,391
import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart' show debugPaintSizeEnabled; void main() { debugPaintSizeEnabled = false; // Set to true for visual layout runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter layout demo', home: Scaffold( appBar: AppBar( title: const Text('Flutter layout demo'), ), body: Center(child: _buildImageColumn()), ), ); } // #docregion column Widget _buildImageColumn() { return Container( decoration: const BoxDecoration( color: Colors.black26, ), child: Column( children: [ _buildImageRow(1), _buildImageRow(3), ], ), ); } // #enddocregion column // #docregion row Widget _buildDecoratedImage(int imageIndex) => Expanded( child: Container( decoration: BoxDecoration( border: Border.all(width: 10, color: Colors.black38), borderRadius: const BorderRadius.all(Radius.circular(8)), ), margin: const EdgeInsets.all(4), child: Image.asset('images/pic$imageIndex.jpg'), ), ); Widget _buildImageRow(int imageIndex) => Row( children: [ _buildDecoratedImage(imageIndex), _buildDecoratedImage(imageIndex + 1), ], ); // #enddocregion row }
website/examples/layout/container/lib/main.dart/0
{ "file_path": "website/examples/layout/container/lib/main.dart", "repo_id": "website", "token_count": 645 }
1,392
# 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: "367f9ea16bfae1ca451b9cc27c1366870b187ae2" channel: "stable" project_type: app # Tracks metadata for the flutter migrate command migration: platforms: - platform: root create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 - platform: macos create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 # User provided section # List of Local paths (relative to this file) that should be # ignored by the migrate tool. # # Files that are not part of the templates will be ignored by default. unmanaged_files: - 'lib/main.dart' - 'ios/Runner.xcodeproj/project.pbxproj'
website/examples/testing/code_debugging/.metadata/0
{ "file_path": "website/examples/testing/code_debugging/.metadata", "repo_id": "website", "token_count": 352 }
1,393
import 'package:flutter/material.dart'; class ProblemWidget extends StatelessWidget { const ProblemWidget({super.key}); @override // #docregion Problem Widget build(BuildContext context) { return Row( children: [ const Icon(Icons.message), Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('Title', style: Theme.of(context).textTheme.headlineMedium), const Text( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed ' 'do eiusmod tempor incididunt ut labore et dolore magna ' 'aliqua. Ut enim ad minim veniam, quis nostrud ' 'exercitation ullamco laboris nisi ut aliquip ex ea ' 'commodo consequat.', ), ], ), ], ); } // #enddocregion Problem } class SolutionWidget extends StatelessWidget { const SolutionWidget({super.key}); @override Widget build(BuildContext context) { // #docregion Fix return const Row( children: [ Icon(Icons.message), Expanded( child: Column( // code omitted ), ), ], ); // #enddocregion Fix } }
website/examples/testing/common_errors/lib/renderflex_overflow.dart/0
{ "file_path": "website/examples/testing/common_errors/lib/renderflex_overflow.dart", "repo_id": "website", "token_count": 592 }
1,394
name: errors description: An error handling example. publish_to: none environment: sdk: ^3.3.0 dependencies: flutter: sdk: flutter firebase_core: ^2.25.4 dev_dependencies: example_utils: path: ../../example_utils integration_test: sdk: flutter flutter_test: sdk: flutter flutter: uses-material-design: true
website/examples/testing/errors/pubspec.yaml/0
{ "file_path": "website/examples/testing/errors/pubspec.yaml", "repo_id": "website", "token_count": 136 }
1,395
name: focus description: Sample focus system code. publish_to: none environment: sdk: ^3.3.0 dependencies: flutter: sdk: flutter dev_dependencies: example_utils: path: ../../../example_utils flutter: uses-material-design: true
website/examples/ui/advanced/focus/pubspec.yaml/0
{ "file_path": "website/examples/ui/advanced/focus/pubspec.yaml", "repo_id": "website", "token_count": 95 }
1,396
// ignore_for_file: non_constant_identifier_names /// Shows 3 types of layout: /// - A vertical for narrow screens /// - Wide for wide screens /// - A mixed mode library; import 'package:flextras/flextras.dart'; import 'package:flutter/material.dart'; import '../global/device_type.dart'; import '../widgets/scroll_view_with_scrollbars.dart'; enum ReflowMode { vertical, horizontal, mixed } class AdaptiveReflowPage extends StatelessWidget { const AdaptiveReflowPage({super.key}); @override Widget build(BuildContext context) { return LayoutBuilder(builder: (_, constraints) { /// Decide which mode to show in ReflowMode reflowMode = ReflowMode.mixed; if (constraints.maxWidth < 800) { reflowMode = ReflowMode.vertical; } else if (constraints.maxHeight < 800) { reflowMode = ReflowMode.horizontal; } // In mixed mode, use a mix of Colum and Row if (reflowMode == ReflowMode.mixed) { return Column( children: [ Expanded( child: Row( children: [ Expanded(child: _ContentPanel1()), Expanded(child: _ContentPanel2()), ], ), ), Expanded(child: _ContentPanel3()), ], ); } // In vertical or horizontal mode, use a ExpandedScrollingFlex with the same set of children else { Axis direction = reflowMode == ReflowMode.horizontal ? Axis.horizontal : Axis.vertical; return ExpandedScrollingFlex( scrollViewBuilder: (axis, child) => ScrollViewWithScrollbars(axis: axis, child: child), direction: direction, children: [ _ContentPanel1(), _ContentPanel2(), _ContentPanel3(), ].map((c) => Expanded(child: c)).toList()); } }); } } /// For demo purposes, simulate 3 different content areas Widget _ContentPanel1() => const _ContentPanel('Panel 1'); Widget _ContentPanel2() => const _ContentPanel('Panel 2'); Widget _ContentPanel3() => const _ContentPanel('Panel 3'); class _ContentPanel extends StatelessWidget { const _ContentPanel(this.label); final String label; @override Widget build(BuildContext context) { // #docregion VisualDensityOwnView VisualDensity density = Theme.of(context).visualDensity; // #enddocregion VisualDensityOwnView return ConstrainedBox( constraints: const BoxConstraints(minHeight: 300, minWidth: 300), child: Padding( padding: EdgeInsets.all(Insets.large + density.vertical * 6), child: Container( alignment: Alignment.center, color: Colors.purple.shade100, child: Text(label), ), ), ); } }
website/examples/ui/layout/adaptive_app_demos/lib/pages/adaptive_reflow_page.dart/0
{ "file_path": "website/examples/ui/layout/adaptive_app_demos/lib/pages/adaptive_reflow_page.dart", "repo_id": "website", "token_count": 1175 }
1,397
import 'package:flutter/material.dart'; class Product { const Product({required this.name}); final String name; } typedef CartChangedCallback = Function(Product product, bool inCart); class ShoppingListItem extends StatelessWidget { ShoppingListItem({ required this.product, required this.inCart, required this.onCartChanged, }) : super(key: ObjectKey(product)); final Product product; final bool inCart; final CartChangedCallback onCartChanged; Color _getColor(BuildContext context) { // The theme depends on the BuildContext because different // parts of the tree can have different themes. // The BuildContext indicates where the build is // taking place and therefore which theme to use. return inCart // ? Colors.black54 : Theme.of(context).primaryColor; } TextStyle? _getTextStyle(BuildContext context) { if (!inCart) return null; return const TextStyle( color: Colors.black54, decoration: TextDecoration.lineThrough, ); } @override Widget build(BuildContext context) { return ListTile( onTap: () { onCartChanged(product, inCart); }, leading: CircleAvatar( backgroundColor: _getColor(context), child: Text(product.name[0]), ), title: Text( product.name, style: _getTextStyle(context), ), ); } } class ShoppingList extends StatefulWidget { const ShoppingList({required this.products, super.key}); final List<Product> products; // The framework calls createState the first time // a widget appears at a given location in the tree. // If the parent rebuilds and uses the same type of // widget (with the same key), the framework re-uses // the State object instead of creating a new State object. @override State<ShoppingList> createState() => _ShoppingListState(); } class _ShoppingListState extends State<ShoppingList> { final _shoppingCart = <Product>{}; void _handleCartChanged(Product product, bool inCart) { setState(() { // When a user changes what's in the cart, you need // to change _shoppingCart inside a setState call to // trigger a rebuild. // The framework then calls build, below, // which updates the visual appearance of the app. if (!inCart) { _shoppingCart.add(product); } else { _shoppingCart.remove(product); } }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Shopping List'), ), body: ListView( padding: const EdgeInsets.symmetric(vertical: 8), children: widget.products.map((product) { return ShoppingListItem( product: product, inCart: _shoppingCart.contains(product), onCartChanged: _handleCartChanged, ); }).toList(), ), ); } } void main() { runApp(const MaterialApp( title: 'Shopping App', home: ShoppingList( products: [ Product(name: 'Eggs'), Product(name: 'Flour'), Product(name: 'Chocolate chips'), ], ), )); }
website/examples/ui/widgets_intro/lib/main_shoppinglist.dart/0
{ "file_path": "website/examples/ui/widgets_intro/lib/main_shoppinglist.dart", "repo_id": "website", "token_count": 1162 }
1,398
[ { "name": "Basics", "description": "Widgets you absolutely need to know before building your first Flutter app.", "priority": "high", "id": "basics" }, { "name": "Material components", "description": "Visual, behavioral, and motion-rich widgets implementing the <a href=\"https://m3.material.io/get-started\">Material 3</a> design specification.<br /><br />Material 3 is the default Flutter interface as of Flutter 3.16. To learn more about this transition, check out <a href=\"https://m3.material.io/develop/flutter\">Flutter support for Material 3</a>.", "pagecontent": "Eventually, Material 2 will be deprecated, but in the short term, you can opt out of Material 3 by setting the <a href=\"https://api.flutter.dev/flutter/material/ThemeData/useMaterial3.html\"><code>useMaterial3</code></a> flag to <code>false</code> in your theme.<br /><br />To migrate your widgets to Material 3, check out the <a href=\"/release/breaking-changes/material-3-migration\">migration guide.</a><br /><br />To catch these widgets in action, check out our live Material 3 <a href=\"https://flutter.github.io/samples/web/material_3_demo\" target=\"_blank\" rel=\"noopener noreferrer\">demo app</a>.<br /><br />You can still check out our legacy <a href=\"/ui/widgets/material2\">Material 2 widgets</a> over at their catalog page.", "subcategories": [ { "name": "Actions", "color": "#D9E7CB" }, { "name": "Communication", "color": "#F9DBDA" }, { "name": "Containment", "color": "#F9DBDA" }, { "name": "Navigation", "color": "#E5E4C2" }, { "name": "Selection", "color": "#D9E7CB" }, { "name": "Text Inputs", "color": "#E5E4C2" } ], "id": "material" }, { "name": "Material 2 components", "description": "Widgets implementing the <a href=\"https://m2.material.io/design\">Material 2 Design guidelines</a>.", "pagecontent": "Material 3 (M3), the latest version of Material Design, is Flutter's default as of Flutter 3.16. Material 2 will eventually be deprecated. Check out the <a href=\"/ui/widgets/material/\">M3 widget catalog</a>.", "subcategories": [ { "name": "App structure and navigation" }, { "name": "Buttons" }, { "name": "Input and selections" }, { "name": "Dialogs, alerts, and panels" }, { "name": "Information displays" }, { "name": "Layout" } ], "id": "material2" }, { "name": "Cupertino (iOS-style widgets)", "description": "Beautiful and high-fidelity widgets for current iOS design language.", "id": "cupertino" }, { "name": "Layout", "description": "Arrange other widgets columns, rows, grids, and many other layouts.", "subcategories": [ { "name": "Single-child layout widgets", "description": "These widgets take a single child and manipulate the layout of the child." }, { "name": "Multi-child layout widgets", "description": "These widgets take multiple children and arrange them in different ways." }, { "name": "Sliver widgets", "description": "These widgets take a portion of a CustomScrollView and apply a layout to that portion." } ], "id": "layout" }, { "name": "Text", "description": "Display and style text.", "id": "text" }, { "name": "Assets, Images, and Icons", "description": "Manage assets, display images, and show icons.", "id": "assets" }, { "name": "Input", "description": "Take user input in addition to input widgets in Material components and Cupertino.", "id": "input" }, { "name": "Animation and Motion", "description": "Bring animations to your app.", "id": "animation" }, { "name": "Interaction Models", "description": "Respond to touch events and route users to different views.", "subcategories": [ { "name": "Touch interactions" }, { "name": "Routing" } ], "id": "interaction" }, { "name": "Styling", "description": "Manage the theme of your app, makes your app responsive to screen sizes, or add padding.", "id": "styling" }, { "name": "Painting and effects", "description": "These widgets apply visual effects to the children without changing their layout, size, or position.", "id": "painting" }, { "name": "Async", "description": "Async patterns to your Flutter application.", "id": "async" }, { "name": "Scrolling", "description": "Scroll multiple widgets as children of the parent.", "id": "scrolling" }, { "name": "Accessibility", "description": "Make your app accessible.", "id": "accessibility" } ]
website/src/_data/catalog/index.json/0
{ "file_path": "website/src/_data/catalog/index.json", "repo_id": "website", "token_count": 1892 }
1,399
<!-- Material 3 Catalog Page --> {% for section in site.data.catalog.index %} {% if section.name == include.category %} {% assign category = section %} {% break %} {% endif %} {% endfor %} <div class="catalog"> <div class="category-description"> <p>{{category.description}}</p> </div> {% if category.subcategories and category.subcategories.size != 0 -%} <ul> {% for sub in category.subcategories -%} <li><a href="#{{sub.name}}">{{sub.name}}</a></li> {% endfor -%} </ul> {% endif -%} <p> {{ category.pagecontent }}</p> {% assign components = site.data.catalog.widgets | where_exp:"comp","comp.categories contains include.category" -%} {% if category.subcategories and category.subcategories.size != 0 -%} {% for sub in category.subcategories -%} {% assign components = site.data.catalog.widgets | where_exp:"comp","comp.subcategories contains sub.name" -%} {% if components.size != 0 -%} <h2 id="{{sub.name}}">{{sub.name}}</h2> <div class="card-deck card-deck--responsive"> {% for comp in components -%} <div class="card"> <a href="{{comp.link}}"> <div class="card-image-holder-material-3" style="--bg-color: {{sub.color}}"> {{ comp.image }} <div class="card-image-material-3-hover"> {{ comp.hoverimage }} </div> </div> </a> <div class="card-body"> <a href="{{comp.link}}"><header class="card-title card-title-material-3">{{comp.name}}</header></a> <p class="card-text">{{ comp.description | truncatewords: 25 }}</p> </div> </div> {% endfor -%} </div> {% endif -%} {% endfor -%} {% endif -%} <p>Check out more widgets in the <a href="/ui/widgets">widget catalog</a>.</p> </div>
website/src/_includes/docs/catalogpage-material.html/0
{ "file_path": "website/src/_includes/docs/catalogpage-material.html", "repo_id": "website", "token_count": 1051 }
1,400
{% assign os=include.os %} {% assign target = include.target %} {% assign terminal=include.terminal %} {% case target %} {% when 'mobile-ios' %} {% assign v-target = 'iOS' %} {% when 'mobile-android','mobile' %} {% assign v-target = 'Android' %} {% else %} {% assign v-target = target %} {% endcase %} ## Install the Flutter SDK To install the Flutter SDK, you can use the VS Code Flutter extension or download and install the Flutter bundle yourself. {% comment %} Nav tabs {% endcomment -%} <ul class="nav nav-tabs" id="flutter-install" role="tablist"> <li class="nav-item"> <a class="nav-link active" id="vscode-tab" href="#vscode" role="tab" aria-controls="vscode" aria-selected="true">Use VS Code to install</a> </li> <li class="nav-item"> <a class="nav-link" id="download-tab" href="#download" role="tab" aria-controls="download" aria-selected="false">Download and install</a> </li> </ul> {% comment %} Tab panes {% endcomment -%} <div class="tab-content"> <div class="tab-pane active" id="vscode" role="tabpanel" aria-labelledby="vscode-tab" markdown="1"> {% include docs/install/flutter/vscode.md os=os terminal=terminal target=v-target %} </div> <div class="tab-pane" id="download" role="tabpanel" aria-labelledby="download-tab" markdown="1"> {% include docs/install/flutter/download.md os=os terminal=terminal target=v-target%} </div> </div> {% comment %} End: Tab panes. {% endcomment -%}
website/src/_includes/docs/install/flutter-sdk.md/0
{ "file_path": "website/src/_includes/docs/install/flutter-sdk.md", "repo_id": "website", "token_count": 546 }
1,401
{% if include.target == 'desktop' -%} 36.0 | 56.0 | {% elsif include.target == 'mobile-ios' -%} 36.0 | 56.0 | {% elsif include.target == 'mobile-android' -%} 10.0 | 18.0 | {% elsif include.target == 'web' -%} 2.5 | 2.5 | {% else -%} 44.0 | 70.0 | {% endif -%} {:.table.table-striped}
website/src/_includes/docs/install/reqs/macos/storage.md/0
{ "file_path": "website/src/_includes/docs/install/reqs/macos/storage.md", "repo_id": "website", "token_count": 136 }
1,402
{{site.alert.note}} To learn how to use the **Performance View** (part of Flutter DevTools) for debugging performance issues, see [Using the Performance view][]. {{site.alert.end}} [Using the Performance view]: /tools/devtools/performance
website/src/_includes/docs/performance.md/0
{ "file_path": "website/src/_includes/docs/performance.md", "repo_id": "website", "token_count": 70 }
1,403
{% for entry in include.children -%} {% if entry.permalink -%} {% if include.active_entries and forloop.index == include.active_entries[3] -%} {% assign isActive = true -%} {% assign class = 'nav-link active' -%} {% else -%} {% assign isActive = false -%} {% assign class = 'nav-link' -%} {% endif -%} {% if entry.permalink contains '://' -%} {% assign isExternal = true -%} {% else -%} {% assign isExternal = false -%} {% endif -%} <li class="nav-item"> <a class="{{class}}" href="{{entry.permalink}}" {%- if isExternal %} target="_blank" rel="noopener" {%- endif -%} >{{entry.title}}</a> </li> {% endif -%} {% endfor -%}
website/src/_includes/sidenav-level-4.html/0
{ "file_path": "website/src/_includes/sidenav-level-4.html", "repo_id": "website", "token_count": 287 }
1,404
module DartSite class Util def self.get_indentation_string(s) s.match(/^[ \t]*/)[0] end # String to string transformation. def self.trim_min_leading_space(code) lines = code.split(/\n/); non_blank_lines = lines.reject { |s| s.match(/^\s*$/) } # Length of leading spaces to be trimmed len = non_blank_lines.map{ |s| matches = s.match(/^[ \t]*/) matches ? matches[0].length : 0 }.min len == 0 ? code : lines.map{|s| s.length < len ? s : s[len..-1]}.join("\n") end # This method is for trimming the content of Jekyll blocks. # # @return a copy of the input lines array, with lines unindented by the # maximal amount of whitespace possible without affecting relative # (non-whitespace) line indentation. Also trim off leading and trailing blank lines. def self.block_trim_leading_whitespace(lines) # 1. Trim leading blank lines while lines.first =~ /^\s*$/ do lines.shift; end # 2. Trim trailing blank lines. Also determine minimal # indentation for the entire block. # Last line should consist of the indentation of the end tag # (when it is on a separate line). last_line = lines.last =~ /^\s*$/ ? lines.pop : '' while lines.last =~ /^\s*$/ do lines.pop end min_len = last_line.length non_blank_lines = lines.reject { |s| s.match(/^\s*$/) } # 3. Determine length of leading spaces to be trimmed len = non_blank_lines.map{ |s| matches = s.match(/^[ \t]*/) matches ? matches[0].length : 0 }.min # Only trim the excess relative to min_len len = len < min_len ? min_len : len - min_len len == 0 ? lines : lines.map{|s| s.length < len ? s : s.sub(/^[ \t]{#{len}}/, '')} end end end
website/src/_plugins/dart_site_util.rb/0
{ "file_path": "website/src/_plugins/dart_site_util.rb", "repo_id": "website", "token_count": 731 }
1,405
@use '../base/variables' as *; @use '../vendor/bootstrap'; // Material design icons @mixin md-icon-content($icon-name, $width: '', $bottom: true) { font-family: $site-font-family-icon; content: $icon-name; @if $width != '' { max-width: $width; // Improves UX by minimizing flicker due to delay in font rendering } @if $bottom { vertical-align: bottom; } } @mixin md-icon-before($icon-name, $bottom: true) { &:before { @include md-icon-content($icon-name, '', $bottom); } } .site-content { padding-bottom: $site-content-top-padding; padding-top: $site-content-top-padding; .container { max-width: $site-content-max-width; img, iframe { max-width: 100%; } } @include bootstrap.media-breakpoint-up(md) { border-left: 1px solid $site-color-light-grey; min-height: calc(100vh - #{$site-header-height} - #{$site-footer-md-default-height}); } &__title { margin-bottom: bootstrap.bs-spacer(8); @at-root { #page-github-links { float: right; .btn { padding: 0 (bootstrap.$btn-padding-x * 0.5); border: none; box-shadow: none; &:hover, &:focus-visible { color: $site-color-primary; } &:active { color: $flutter-color-dark-blue; } } .material-symbols { font-size: 18px; } } } h1 { margin-bottom: 0; } } h1, h2, h3, h4, h5, h6 { text-wrap: balance; $icon-size: 1.5rem; $anchor-padding: 0.25rem; > a.anchor { float: left; margin-left: -($icon-size + $anchor-padding); padding-right: $anchor-padding; overflow: hidden; text-decoration: none; .octicon-link { transition: all 0.2s ease-in-out; @include md-icon-before("tag", false); font-size: $icon-size; color: $site-color-body; opacity: 0; &:hover { color: lighten($site-color-primary, 20%); } } &:focus .octicon-link { opacity: 1 } } &:hover > .anchor > .octicon-link { opacity: 1 } } // Embedded DartPad iframe { border: 1px solid #ccc; } } .video-card { flex: 0 0 calc((100% / 2) - 1rem); position: relative; display: flex; flex-direction: column; min-width: 0; word-wrap: break-word; background-color: #fff; background-clip: border-box; border: 1px solid rgba(0, 0, 0, 0.125); border-radius: 4px; margin-bottom: 1rem; margin-left: 0.5rem; margin-right: 0.5rem; } .full-width { width: 100%; } iframe.full-width { aspect-ratio: 16 / 9; }
website/src/_sass/components/_content.scss/0
{ "file_path": "website/src/_sass/components/_content.scss", "repo_id": "website", "token_count": 1234 }
1,406
--- title: Add a Flutter Fragment to an Android app short-title: Add a Flutter Fragment description: Learn how to add a Flutter Fragment to your existing Android app. --- <img src='/assets/images/docs/development/add-to-app/android/add-flutter-fragment/add-flutter-fragment_header.png' class="mw-100" alt="Add Flutter Fragment Header"> This guide describes how to add a Flutter `Fragment` to an existing Android app. In Android, a [`Fragment`][] represents a modular piece of a larger UI. A `Fragment` might be used to present a sliding drawer, tabbed content, a page in a `ViewPager`, or it might simply represent a normal screen in a single-`Activity` app. Flutter provides a [`FlutterFragment`][] so that developers can present a Flutter experience any place that they can use a regular `Fragment`. If an `Activity` is equally applicable for your application needs, consider [using a `FlutterActivity`][] instead of a `FlutterFragment`, which is quicker and easier to use. `FlutterFragment` allows developers to control the following details of the Flutter experience within the `Fragment`: * Initial Flutter route * Dart entrypoint to execute * Opaque vs translucent background * Whether `FlutterFragment` should control its surrounding `Activity` * Whether a new [`FlutterEngine`][] or a cached `FlutterEngine` should be used `FlutterFragment` also comes with a number of calls that must be forwarded from its surrounding `Activity`. These calls allow Flutter to react appropriately to OS events. All varieties of `FlutterFragment`, and its requirements, are described in this guide. ## Add a `FlutterFragment` to an `Activity` with a new `FlutterEngine` The first thing to do to use a `FlutterFragment` is to add it to a host `Activity`. To add a `FlutterFragment` to a host `Activity`, instantiate and attach an instance of `FlutterFragment` in `onCreate()` within the `Activity`, or at another time that works for your app: {% samplecode add-fragment %} {% sample Java %} <?code-excerpt title="MyActivity.java"?> ```java public class MyActivity extends FragmentActivity { // Define a tag String to represent the FlutterFragment within this // Activity's FragmentManager. This value can be whatever you'd like. private static final String TAG_FLUTTER_FRAGMENT = "flutter_fragment"; // Declare a local variable to reference the FlutterFragment so that you // can forward calls to it later. private FlutterFragment flutterFragment; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Inflate a layout that has a container for your FlutterFragment. // For this example, assume that a FrameLayout exists with an ID of // R.id.fragment_container. setContentView(R.layout.my_activity_layout); // Get a reference to the Activity's FragmentManager to add a new // FlutterFragment, or find an existing one. FragmentManager fragmentManager = getSupportFragmentManager(); // Attempt to find an existing FlutterFragment, // in case this is not the first time that onCreate() was run. flutterFragment = (FlutterFragment) fragmentManager .findFragmentByTag(TAG_FLUTTER_FRAGMENT); // Create and attach a FlutterFragment if one does not exist. if (flutterFragment == null) { flutterFragment = FlutterFragment.createDefault(); fragmentManager .beginTransaction() .add( R.id.fragment_container, flutterFragment, TAG_FLUTTER_FRAGMENT ) .commit(); } } } ``` {% sample Kotlin %} <?code-excerpt title="MyActivity.kt"?> ```kotlin class MyActivity : FragmentActivity() { companion object { // Define a tag String to represent the FlutterFragment within this // Activity's FragmentManager. This value can be whatever you'd like. private const val TAG_FLUTTER_FRAGMENT = "flutter_fragment" } // Declare a local variable to reference the FlutterFragment so that you // can forward calls to it later. private var flutterFragment: FlutterFragment? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // Inflate a layout that has a container for your FlutterFragment. For // this example, assume that a FrameLayout exists with an ID of // R.id.fragment_container. setContentView(R.layout.my_activity_layout) // Get a reference to the Activity's FragmentManager to add a new // FlutterFragment, or find an existing one. val fragmentManager: FragmentManager = supportFragmentManager // Attempt to find an existing FlutterFragment, in case this is not the // first time that onCreate() was run. flutterFragment = fragmentManager .findFragmentByTag(TAG_FLUTTER_FRAGMENT) as FlutterFragment? // Create and attach a FlutterFragment if one does not exist. if (flutterFragment == null) { var newFlutterFragment = FlutterFragment.createDefault() flutterFragment = newFlutterFragment fragmentManager .beginTransaction() .add( R.id.fragment_container, newFlutterFragment, TAG_FLUTTER_FRAGMENT ) .commit() } } } ``` {% endsamplecode %} The previous code is sufficient to render a Flutter UI that begins with a call to your `main()` Dart entrypoint, an initial Flutter route of `/`, and a new `FlutterEngine`. However, this code is not sufficient to achieve all expected Flutter behavior. Flutter depends on various OS signals that must be forwarded from your host `Activity` to `FlutterFragment`. These calls are shown in the following example: {% samplecode forward-activity-calls %} {% sample Java %} <?code-excerpt title="MyActivity.java"?> ```java public class MyActivity extends FragmentActivity { @Override public void onPostResume() { super.onPostResume(); flutterFragment.onPostResume(); } @Override protected void onNewIntent(@NonNull Intent intent) { flutterFragment.onNewIntent(intent); } @Override public void onBackPressed() { flutterFragment.onBackPressed(); } @Override public void onRequestPermissionsResult( int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults ) { flutterFragment.onRequestPermissionsResult( requestCode, permissions, grantResults ); } @Override public void onActivityResult( int requestCode, int resultCode, @Nullable Intent data ) { super.onActivityResult(requestCode, resultCode, data); flutterFragment.onActivityResult( requestCode, resultCode, data ); } @Override public void onUserLeaveHint() { flutterFragment.onUserLeaveHint(); } @Override public void onTrimMemory(int level) { super.onTrimMemory(level); flutterFragment.onTrimMemory(level); } } ``` {% sample Kotlin %} <?code-excerpt title="MyActivity.kt"?> ```kotlin class MyActivity : FragmentActivity() { override fun onPostResume() { super.onPostResume() flutterFragment!!.onPostResume() } override fun onNewIntent(@NonNull intent: Intent) { flutterFragment!!.onNewIntent(intent) } override fun onBackPressed() { flutterFragment!!.onBackPressed() } override fun onRequestPermissionsResult( requestCode: Int, permissions: Array<String?>, grantResults: IntArray ) { flutterFragment!!.onRequestPermissionsResult( requestCode, permissions, grantResults ) } override fun onActivityResult( requestCode: Int, resultCode: Int, data: Intent? ) { super.onActivityResult(requestCode, resultCode, data) flutterFragment!!.onActivityResult( requestCode, resultCode, data ) } override fun onUserLeaveHint() { flutterFragment!!.onUserLeaveHint() } override fun onTrimMemory(level: Int) { super.onTrimMemory(level) flutterFragment!!.onTrimMemory(level) } } ``` {% endsamplecode %} With the OS signals forwarded to Flutter, your `FlutterFragment` works as expected. You have now added a `FlutterFragment` to your existing Android app. The simplest integration path uses a new `FlutterEngine`, which comes with a non-trivial initialization time, leading to a blank UI until Flutter is initialized and rendered the first time. Most of this time overhead can be avoided by using a cached, pre-warmed `FlutterEngine`, which is discussed next. ## Using a pre-warmed `FlutterEngine` By default, a `FlutterFragment` creates its own instance of a `FlutterEngine`, which requires non-trivial warm-up time. This means your user sees a blank `Fragment` for a brief moment. You can mitigate most of this warm-up time by using an existing, pre-warmed instance of `FlutterEngine`. To use a pre-warmed `FlutterEngine` in a `FlutterFragment`, instantiate a `FlutterFragment` with the `withCachedEngine()` factory method. {% samplecode use-prewarmed-engine %} {% sample Java %} <?code-excerpt title="MyApplication.java"?> ```java // Somewhere in your app, before your FlutterFragment is needed, // like in the Application class ... // Instantiate a FlutterEngine. FlutterEngine flutterEngine = new FlutterEngine(context); // Start executing Dart code in the FlutterEngine. flutterEngine.getDartExecutor().executeDartEntrypoint( DartEntrypoint.createDefault() ); // Cache the pre-warmed FlutterEngine to be used later by FlutterFragment. FlutterEngineCache .getInstance() .put("my_engine_id", flutterEngine); ``` <?code-excerpt title="MyActivity.java"?> ```java FlutterFragment.withCachedEngine("my_engine_id").build(); ``` {% sample Kotlin %} <?code-excerpt title="MyApplication.kt"?> ```kotlin // Somewhere in your app, before your FlutterFragment is needed, // like in the Application class ... // Instantiate a FlutterEngine. val flutterEngine = FlutterEngine(context) // Start executing Dart code in the FlutterEngine. flutterEngine.getDartExecutor().executeDartEntrypoint( DartEntrypoint.createDefault() ) // Cache the pre-warmed FlutterEngine to be used later by FlutterFragment. FlutterEngineCache .getInstance() .put("my_engine_id", flutterEngine) ``` <?code-excerpt title="MyActivity.java"?> ```kotlin FlutterFragment.withCachedEngine("my_engine_id").build() ``` {% endsamplecode %} `FlutterFragment` internally knows about [`FlutterEngineCache`][] and retrieves the pre-warmed `FlutterEngine` based on the ID given to `withCachedEngine()`. By providing a pre-warmed `FlutterEngine`, as previously shown, your app renders the first Flutter frame as quickly as possible. #### Initial route with a cached engine {% include_relative _initial-route-cached-engine.md %} ## Display a splash screen The initial display of Flutter content requires some wait time, even if a pre-warmed `FlutterEngine` is used. To help improve the user experience around this brief waiting period, Flutter supports the display of a splash screen (also known as "launch screen") until Flutter renders its first frame. For instructions about how to show a launch screen, see the [splash screen guide][]. ## Run Flutter with a specified initial route An Android app might contain many independent Flutter experiences, running in different `FlutterFragment`s, with different `FlutterEngine`s. In these scenarios, it's common for each Flutter experience to begin with different initial routes (routes other than `/`). To facilitate this, `FlutterFragment`'s `Builder` allows you to specify a desired initial route, as shown: {% samplecode launch-with-initial-route %} {% sample Java %} <?code-excerpt title="MyActivity.java"?> ```java // With a new FlutterEngine. FlutterFragment flutterFragment = FlutterFragment.withNewEngine() .initialRoute("myInitialRoute/") .build(); ``` {% sample Kotlin %} <?code-excerpt title="MyActivity.kt"?> ```kotlin // With a new FlutterEngine. val flutterFragment = FlutterFragment.withNewEngine() .initialRoute("myInitialRoute/") .build() ``` {% endsamplecode %} {{site.alert.note}} `FlutterFragment`'s initial route property has no effect when a pre-warmed `FlutterEngine` is used because the pre-warmed `FlutterEngine` already chose an initial route. The initial route can be chosen explicitly when pre-warming a `FlutterEngine`. {{site.alert.end}} ## Run Flutter from a specified entrypoint Similar to varying initial routes, different `FlutterFragment`s might want to execute different Dart entrypoints. In a typical Flutter app, there is only one Dart entrypoint: `main()`, but you can define other entrypoints. `FlutterFragment` supports specification of the desired Dart entrypoint to execute for the given Flutter experience. To specify an entrypoint, build `FlutterFragment`, as shown: {% samplecode launch-with-custom-entrypoint %} {% sample Java %} <?code-excerpt title="MyActivity.java"?> ```java FlutterFragment flutterFragment = FlutterFragment.withNewEngine() .dartEntrypoint("mySpecialEntrypoint") .build(); ``` {% sample Kotlin %} <?code-excerpt title="MyActivity.kt"?> ```kotlin val flutterFragment = FlutterFragment.withNewEngine() .dartEntrypoint("mySpecialEntrypoint") .build() ``` {% endsamplecode %} The `FlutterFragment` configuration results in the execution of a Dart entrypoint called `mySpecialEntrypoint()`. Notice that the parentheses `()` are not included in the `dartEntrypoint` `String` name. {{site.alert.note}} `FlutterFragment`'s Dart entrypoint property has no effect when a pre-warmed `FlutterEngine` is used because the pre-warmed `FlutterEngine` already executed a Dart entrypoint. The Dart entrypoint can be chosen explicitly when pre-warming a `FlutterEngine`. {{site.alert.end}} ## Control `FlutterFragment`'s render mode `FlutterFragment` can either use a `SurfaceView` to render its Flutter content, or it can use a `TextureView`. The default is `SurfaceView`, which is significantly better for performance than `TextureView`. However, `SurfaceView` can't be interleaved in the middle of an Android `View` hierarchy. A `SurfaceView` must either be the bottommost `View` in the hierarchy, or the topmost `View` in the hierarchy. Additionally, on Android versions before Android N, `SurfaceView`s can't be animated because their layout and rendering aren't synchronized with the rest of the `View` hierarchy. If either of these use cases are requirements for your app, then you need to use `TextureView` instead of `SurfaceView`. Select a `TextureView` by building a `FlutterFragment` with a `texture` `RenderMode`: {% samplecode launch-with-rendermode %} {% sample Java %} <?code-excerpt title="MyActivity.java"?> ```java // With a new FlutterEngine. FlutterFragment flutterFragment = FlutterFragment.withNewEngine() .renderMode(FlutterView.RenderMode.texture) .build(); // With a cached FlutterEngine. FlutterFragment flutterFragment = FlutterFragment.withCachedEngine("my_engine_id") .renderMode(FlutterView.RenderMode.texture) .build(); ``` {% sample Kotlin %} <?code-excerpt title="MyActivity.kt"?> ```kotlin // With a new FlutterEngine. val flutterFragment = FlutterFragment.withNewEngine() .renderMode(FlutterView.RenderMode.texture) .build() // With a cached FlutterEngine. val flutterFragment = FlutterFragment.withCachedEngine("my_engine_id") .renderMode(FlutterView.RenderMode.texture) .build() ``` {% endsamplecode %} Using the configuration shown, the resulting `FlutterFragment` renders its UI to a `TextureView`. ## Display a `FlutterFragment` with transparency By default, `FlutterFragment` renders with an opaque background, using a `SurfaceView`. (See "Control `FlutterFragment`'s render mode.") That background is black for any pixels that aren't painted by Flutter. Rendering with an opaque background is the preferred rendering mode for performance reasons. Flutter rendering with transparency on Android negatively affects performance. However, there are many designs that require transparent pixels in the Flutter experience that show through to the underlying Android UI. For this reason, Flutter supports translucency in a `FlutterFragment`. {{site.alert.note}} Both `SurfaceView` and `TextureView` support transparency. However, when a `SurfaceView` is instructed to render with transparency, it positions itself at a higher z-index than all other Android `View`s, which means it appears above all other `View`s. This is a limitation of `SurfaceView`. If it's acceptable to render your Flutter experience on top of all other content, then `FlutterFragment`'s default `RenderMode` of `surface` is the `RenderMode` that you should use. However, if you need to display Android `View`s both above and below your Flutter experience, then you must specify a `RenderMode` of `texture`. See "Control `FlutterFragment`'s render mode" for information about controlling the `RenderMode`. {{site.alert.end}} To enable transparency for a `FlutterFragment`, build it with the following configuration: {% samplecode launch-with-transparency %} {% sample Java %} <?code-excerpt title="MyActivity.java"?> ```java // Using a new FlutterEngine. FlutterFragment flutterFragment = FlutterFragment.withNewEngine() .transparencyMode(FlutterView.TransparencyMode.transparent) .build(); // Using a cached FlutterEngine. FlutterFragment flutterFragment = FlutterFragment.withCachedEngine("my_engine_id") .transparencyMode(FlutterView.TransparencyMode.transparent) .build(); ``` {% sample Kotlin %} <?code-excerpt title="MyActivity.kt"?> ```kotlin // Using a new FlutterEngine. val flutterFragment = FlutterFragment.withNewEngine() .transparencyMode(FlutterView.TransparencyMode.transparent) .build() // Using a cached FlutterEngine. val flutterFragment = FlutterFragment.withCachedEngine("my_engine_id") .transparencyMode(FlutterView.TransparencyMode.transparent) .build() ``` {% endsamplecode %} ## The relationship between `FlutterFragment` and its `Activity` Some apps choose to use `Fragment`s as entire Android screens. In these apps, it would be reasonable for a `Fragment` to control system chrome like Android's status bar, navigation bar, and orientation. <img src='/assets/images/docs/development/add-to-app/android/add-flutter-fragment/add-flutter-fragment_fullscreen.png' class="mw-100" alt="Fullscreen Flutter"> In other apps, `Fragment`s are used to represent only a portion of a UI. A `FlutterFragment` might be used to implement the inside of a drawer, a video player, or a single card. In these situations, it would be inappropriate for the `FlutterFragment` to affect Android's system chrome because there are other UI pieces within the same `Window`. <img src='/assets/images/docs/development/add-to-app/android/add-flutter-fragment/add-flutter-fragment_partial-ui.png' class="mw-100" alt="Flutter as Partial UI"> `FlutterFragment` comes with a concept that helps differentiate between the case when a `FlutterFragment` should be able to control its host `Activity`, and the cases when a `FlutterFragment` should only affect its own behavior. To prevent a `FlutterFragment` from exposing its `Activity` to Flutter plugins, and to prevent Flutter from controlling the `Activity`'s system UI, use the `shouldAttachEngineToActivity()` method in `FlutterFragment`'s `Builder`, as shown: {% samplecode attach-to-activity %} {% sample Java %} <?code-excerpt title="MyActivity.java"?> ```java // Using a new FlutterEngine. FlutterFragment flutterFragment = FlutterFragment.withNewEngine() .shouldAttachEngineToActivity(false) .build(); // Using a cached FlutterEngine. FlutterFragment flutterFragment = FlutterFragment.withCachedEngine("my_engine_id") .shouldAttachEngineToActivity(false) .build(); ``` {% sample Kotlin %} <?code-excerpt title="MyActivity.kt"?> ```kotlin // Using a new FlutterEngine. val flutterFragment = FlutterFragment.withNewEngine() .shouldAttachEngineToActivity(false) .build() // Using a cached FlutterEngine. val flutterFragment = FlutterFragment.withCachedEngine("my_engine_id") .shouldAttachEngineToActivity(false) .build() ``` {% endsamplecode %} Passing `false` to the `shouldAttachEngineToActivity()` `Builder` method prevents Flutter from interacting with the surrounding `Activity`. The default value is `true`, which allows Flutter and Flutter plugins to interact with the surrounding `Activity`. {{site.alert.note}} Some plugins might expect or require an `Activity` reference. Ensure that none of your plugins require an `Activity` before you disable access. {{site.alert.end}} [`Fragment`]: {{site.android-dev}}/guide/components/fragments [`FlutterFragment`]: {{site.api}}/javadoc/io/flutter/embedding/android/FlutterFragment.html [using a `FlutterActivity`]: /add-to-app/android/add-flutter-screen [`FlutterEngine`]: {{site.api}}/javadoc/io/flutter/embedding/engine/FlutterEngine.html [`FlutterEngineCache`]: {{site.api}}/javadoc/io/flutter/embedding/engine/FlutterEngineCache.html [splash screen guide]: /platform-integration/android/splash-screen
website/src/add-to-app/android/add-flutter-fragment.md/0
{ "file_path": "website/src/add-to-app/android/add-flutter-fragment.md", "repo_id": "website", "token_count": 6857 }
1,407
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!-- Generator: Adobe Illustrator 27.7.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <svg version="1.1" id="Layer_1" x="0px" y="0px" width="2in" height="2.2in" viewBox="0 0 191.99386 211.19325" xml:space="preserve" sodipodi:docname="macos.svg" inkscape:version="1.3.2 (091e20e, 2023-11-25)" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"><defs id="defs1" /><sodipodi:namedview id="namedview1" pagecolor="#ffffff" bordercolor="#000000" borderopacity="0.25" inkscape:showpageshadow="2" inkscape:pageopacity="0.0" inkscape:pagecheckerboard="0" inkscape:deskcolor="#d1d1d1" inkscape:zoom="1.5605469" inkscape:cx="192.2403" inkscape:cy="256" inkscape:window-width="1248" inkscape:window-height="942" inkscape:window-x="0" inkscape:window-y="25" inkscape:window-maximized="0" inkscape:current-layer="Layer_1" inkscape:document-units="in" /> <style type="text/css" id="style1"> .st0{fill:#027DFD;} </style> <path class="st0" d="m 149.03327,111.47397 c -0.0857,-15.734595 7.03127,-27.610565 21.43678,-36.356775 -8.06023,-11.532972 -20.23631,-17.878252 -36.31389,-19.121587 -15.22011,-1.20046 -31.85504,8.874823 -37.943081,8.874823 -6.431036,0 -21.179533,-8.446084 -32.755385,-8.446084 -23.923438,0.385857 -49.347445,19.078718 -49.347445,57.107553 0,11.23286 2.05793,22.85159 6.173792,34.81331 5.487809,15.73459 25.295386,54.32077 45.960431,53.67767 10.804132,-0.25723 18.435619,-7.67436 32.498143,-7.67436 13.633785,0 20.707925,7.67436 32.755385,7.67436 20.83654,-0.30011 38.75768,-35.37067 43.98825,-51.14813 -27.95355,-13.16217 -26.45298,-38.58618 -26.45298,-39.40078 z M 124.76686,41.075616 C 136.47133,27.184588 135.3995,14.536895 135.0565,9.9923037 124.72399,10.59253 112.76227,17.023566 105.94537,24.955171 98.442496,33.444128 94.026526,43.948142 94.969744,55.781239 106.15973,56.638709 116.36364,50.893655 124.76686,41.075616 Z" id="path1" style="fill:#027dfd;fill-opacity:1;stroke-width:0.428736" /> </svg>
website/src/assets/images/docs/brand-svg/macos.svg/0
{ "file_path": "website/src/assets/images/docs/brand-svg/macos.svg", "repo_id": "website", "token_count": 1118 }
1,408
--- title: Design description: A catalog of recipes for designing your Flutter app. --- {% include docs/cookbook-group-index.md %}
website/src/cookbook/design/index.md/0
{ "file_path": "website/src/cookbook/design/index.md", "repo_id": "website", "token_count": 39 }
1,409
--- title: Create a typing indicator description: How to implement a typing indicator. js: - defer: true url: https://old-dartpad-3ce3f.web.app/inject_embed.dart.js --- <?code-excerpt path-base="cookbook/effects/typing_indicator"?> Modern chat apps display indicators when other users are actively typing responses. These indicators help prevent rapid and conflicting responses between you and the other person. In this recipe, you build a speech bubble typing indicator that animates in and out of view. The following animation shows the app's behavior: ![The typing indicator is turned on and off](/assets/images/docs/cookbook/effects/TypingIndicator.gif){:.site-mobile-screenshot} ## Define the typing indicator widget The typing indicator exists within its own widget so that it can be used anywhere in your app. As with any widget that controls animations, the typing indicator needs to be a stateful widget. The widget accepts a boolean value that determines whether the indicator is visible. This speech-bubble-typing indicator accepts a color for the bubbles and two colors for the light and dark phases of the flashing circles within the large speech bubble. Define a new stateful widget called `TypingIndicator`. <?code-excerpt "lib/excerpt1.dart (TypingIndicator)"?> ```dart class TypingIndicator extends StatefulWidget { const TypingIndicator({ super.key, this.showIndicator = false, this.bubbleColor = const Color(0xFF646b7f), this.flashingCircleDarkColor = const Color(0xFF333333), this.flashingCircleBrightColor = const Color(0xFFaec1dd), }); final bool showIndicator; final Color bubbleColor; final Color flashingCircleDarkColor; final Color flashingCircleBrightColor; @override State<TypingIndicator> createState() => _TypingIndicatorState(); } class _TypingIndicatorState extends State<TypingIndicator> { @override Widget build(BuildContext context) { // TODO: return const SizedBox(); } } ``` ## Make room for the typing indicator The typing indicator doesn't occupy any space when it isn't displayed. Therefore, the indicator needs to grow in height when it appears, and shrink in height when it disappears. The height of the typing indicator could be the natural height of the speech bubbles within the typing indicator. However, the speech bubbles expand with an elastic curve. This elasticity would be too visually jarring if it quickly pushed all the conversation messages up or down. Instead, the height of the typing indicator animates on its own, smoothly expanding before the bubbles appear. When the bubbles disappear, the height smoothly contracts to zero. This behavior requires an [explicit animation][] for the height of the typing indicator. Define an animation for the height of the typing indicator, and then apply that animated value to the `SizedBox` widget within the typing indicator. <?code-excerpt "lib/excerpt2.dart (TypingIndicatorState)"?> ```dart class _TypingIndicatorState extends State<TypingIndicator> with TickerProviderStateMixin { late AnimationController _appearanceController; late Animation<double> _indicatorSpaceAnimation; @override void initState() { super.initState(); _appearanceController = AnimationController( vsync: this, ); _indicatorSpaceAnimation = CurvedAnimation( parent: _appearanceController, curve: const Interval(0.0, 0.4, curve: Curves.easeOut), reverseCurve: const Interval(0.0, 1.0, curve: Curves.easeOut), ).drive(Tween<double>( begin: 0.0, end: 60.0, )); if (widget.showIndicator) { _showIndicator(); } } @override void didUpdateWidget(TypingIndicator oldWidget) { super.didUpdateWidget(oldWidget); if (widget.showIndicator != oldWidget.showIndicator) { if (widget.showIndicator) { _showIndicator(); } else { _hideIndicator(); } } } @override void dispose() { _appearanceController.dispose(); super.dispose(); } void _showIndicator() { _appearanceController ..duration = const Duration(milliseconds: 750) ..forward(); } void _hideIndicator() { _appearanceController ..duration = const Duration(milliseconds: 150) ..reverse(); } @override Widget build(BuildContext context) { return AnimatedBuilder( animation: _indicatorSpaceAnimation, builder: (context, child) { return SizedBox( height: _indicatorSpaceAnimation.value, ); }, ); } } ``` The `TypingIndicator` runs an animation forward or backward depending on whether the incoming `showIndicator` variable is `true` or `false`, respectively. The animation that controls the height uses different animation curves depending on its direction. When the animation moves forward, it needs to quickly make space for the speech bubbles. For this reason, the forward curve runs the entire height animation within the first 40% of the overall appearance animation. When the animation reverses, it needs to give the speech bubbles enough time to disappear before contracting the height. An ease-out curve that uses all the available time is a good way to accomplish this behavior. {{site.alert.note}} The `AnimatedBuilder` widget rebuilds the `SizedBox` widget as the `_indicatorSpaceAnimation` changes. The alternative to using `AnimatedBuilder` is to invoke `setState()` every time the animation changes, and then rebuild the entire widget tree within `TypingIndicator`. Invoking `setState()` in this manner is acceptable, but as other widgets are added to this widget tree, rebuilding the entire tree just to change the height of the `SizedBox` widget wastes CPU cycles. {{site.alert.end}} ## Animate the speech bubbles The typing indicator displays three speech bubbles. The first two bubbles are small and round. The third bubble is oblong and contains a few flashing circles. These bubbles are staggered in position from the lower left of the available space. Each bubble appears by animating its scale from 0% to 100%, and each bubble does this at slightly different times so that it looks like each bubble appears after the one before it. This is called a [staggered animation][]. Paint the three bubbles in the desired positions from the lower left. Then, animate the scale of the bubbles so that the bubbles are staggered whenever the `showIndicator` property changes. <?code-excerpt "lib/excerpt3.dart (Bubbles)"?> ```dart class _TypingIndicatorState extends State<TypingIndicator> with TickerProviderStateMixin { late AnimationController _appearanceController; late Animation<double> _indicatorSpaceAnimation; late Animation<double> _smallBubbleAnimation; late Animation<double> _mediumBubbleAnimation; late Animation<double> _largeBubbleAnimation; late AnimationController _repeatingController; final List<Interval> _dotIntervals = const [ Interval(0.25, 0.8), Interval(0.35, 0.9), Interval(0.45, 1.0), ]; @override void initState() { super.initState(); _appearanceController = AnimationController( vsync: this, )..addListener(() { setState(() {}); }); _indicatorSpaceAnimation = CurvedAnimation( parent: _appearanceController, curve: const Interval(0.0, 0.4, curve: Curves.easeOut), reverseCurve: const Interval(0.0, 1.0, curve: Curves.easeOut), ).drive(Tween<double>( begin: 0.0, end: 60.0, )); _smallBubbleAnimation = CurvedAnimation( parent: _appearanceController, curve: const Interval(0.0, 0.5, curve: Curves.elasticOut), reverseCurve: const Interval(0.0, 0.3, curve: Curves.easeOut), ); _mediumBubbleAnimation = CurvedAnimation( parent: _appearanceController, curve: const Interval(0.2, 0.7, curve: Curves.elasticOut), reverseCurve: const Interval(0.2, 0.6, curve: Curves.easeOut), ); _largeBubbleAnimation = CurvedAnimation( parent: _appearanceController, curve: const Interval(0.3, 1.0, curve: Curves.elasticOut), reverseCurve: const Interval(0.5, 1.0, curve: Curves.easeOut), ); if (widget.showIndicator) { _showIndicator(); } } @override void didUpdateWidget(TypingIndicator oldWidget) { super.didUpdateWidget(oldWidget); if (widget.showIndicator != oldWidget.showIndicator) { if (widget.showIndicator) { _showIndicator(); } else { _hideIndicator(); } } } @override void dispose() { _appearanceController.dispose(); super.dispose(); } void _showIndicator() { _appearanceController ..duration = const Duration(milliseconds: 750) ..forward(); } void _hideIndicator() { _appearanceController ..duration = const Duration(milliseconds: 150) ..reverse(); } @override Widget build(BuildContext context) { return AnimatedBuilder( animation: _indicatorSpaceAnimation, builder: (context, child) { return SizedBox( height: _indicatorSpaceAnimation.value, child: child, ); }, child: Stack( children: [ AnimatedBubble( animation: _smallBubbleAnimation, left: 8, bottom: 8, bubble: CircleBubble( size: 8, bubbleColor: widget.bubbleColor, ), ), AnimatedBubble( animation: _mediumBubbleAnimation, left: 10, bottom: 10, bubble: CircleBubble( size: 16, bubbleColor: widget.bubbleColor, ), ), AnimatedBubble( animation: _largeBubbleAnimation, left: 12, bottom: 12, bubble: StatusBubble( dotIntervals: _dotIntervals, flashingCircleDarkColor: widget.flashingCircleDarkColor, flashingCircleBrightColor: widget.flashingCircleBrightColor, bubbleColor: widget.bubbleColor, ), ), ], ), ); } } class CircleBubble extends StatelessWidget { const CircleBubble({ super.key, required this.size, required this.bubbleColor, }); final double size; final Color bubbleColor; @override Widget build(BuildContext context) { return Container( width: size, height: size, decoration: BoxDecoration( shape: BoxShape.circle, color: bubbleColor, ), ); } } class AnimatedBubble extends StatelessWidget { const AnimatedBubble({ super.key, required this.animation, required this.left, required this.bottom, required this.bubble, }); final Animation<double> animation; final double left; final double bottom; final Widget bubble; @override Widget build(BuildContext context) { return Positioned( left: left, bottom: bottom, child: AnimatedBuilder( animation: animation, builder: (context, child) { return Transform.scale( scale: animation.value, alignment: Alignment.bottomLeft, child: child, ); }, child: bubble, ), ); } } class StatusBubble extends StatelessWidget { const StatusBubble({ super.key, required this.dotIntervals, required this.flashingCircleBrightColor, required this.flashingCircleDarkColor, required this.bubbleColor, }); final List<Interval> dotIntervals; final Color flashingCircleDarkColor; final Color flashingCircleBrightColor; final Color bubbleColor; @override Widget build(BuildContext context) { return Container( width: 85, height: 44, padding: const EdgeInsets.symmetric(horizontal: 8), decoration: BoxDecoration( borderRadius: BorderRadius.circular(27), color: bubbleColor, ), ); } } ``` ## Animate the flashing circles Within the large speech bubble, the typing indicator displays three small circles that flash repeatedly. Each circle flashes at a slightly different time, giving the impression that a single light source is moving behind each circle. This flashing animation repeats indefinitely. Introduce a repeating `AnimationController` to implement the circle flashing and pass it to the `StatusBubble`. <?code-excerpt "lib/excerpt4.dart (AnimationController)"?> ```dart class _TypingIndicatorState extends State<TypingIndicator> with TickerProviderStateMixin { late AnimationController _appearanceController; late Animation<double> _indicatorSpaceAnimation; late Animation<double> _smallBubbleAnimation; late Animation<double> _mediumBubbleAnimation; late Animation<double> _largeBubbleAnimation; late AnimationController _repeatingController; final List<Interval> _dotIntervals = const [ Interval(0.25, 0.8), Interval(0.35, 0.9), Interval(0.45, 1.0), ]; @override void initState() { super.initState(); // other initializations... _repeatingController = AnimationController( vsync: this, duration: const Duration(milliseconds: 1500), ); if (widget.showIndicator) { _showIndicator(); } } @override void dispose() { _appearanceController.dispose(); _repeatingController.dispose(); super.dispose(); } void _showIndicator() { _appearanceController ..duration = const Duration(milliseconds: 750) ..forward(); _repeatingController.repeat(); // <-- Add this } void _hideIndicator() { _appearanceController ..duration = const Duration(milliseconds: 150) ..reverse(); _repeatingController.stop(); // <-- Add this } @override Widget build(BuildContext context) { return AnimatedBuilder( animation: _indicatorSpaceAnimation, builder: (context, child) { return SizedBox( height: _indicatorSpaceAnimation.value, child: child, ); }, child: Stack( children: [ AnimatedBubble( animation: _smallBubbleAnimation, left: 8, bottom: 8, bubble: CircleBubble( size: 8, bubbleColor: widget.bubbleColor, ), ), AnimatedBubble( animation: _mediumBubbleAnimation, left: 10, bottom: 10, bubble: CircleBubble( size: 16, bubbleColor: widget.bubbleColor, ), ), AnimatedBubble( animation: _largeBubbleAnimation, left: 12, bottom: 12, bubble: StatusBubble( repeatingController: _repeatingController, // <-- Add this dotIntervals: _dotIntervals, flashingCircleDarkColor: widget.flashingCircleDarkColor, flashingCircleBrightColor: widget.flashingCircleBrightColor, bubbleColor: widget.bubbleColor, ), ), ], ), ); } } class StatusBubble extends StatelessWidget { const StatusBubble({ super.key, required this.repeatingController, required this.dotIntervals, required this.flashingCircleBrightColor, required this.flashingCircleDarkColor, required this.bubbleColor, }); final AnimationController repeatingController; final List<Interval> dotIntervals; final Color flashingCircleDarkColor; final Color flashingCircleBrightColor; final Color bubbleColor; @override Widget build(BuildContext context) { return Container( width: 85, height: 44, padding: const EdgeInsets.symmetric(horizontal: 8), decoration: BoxDecoration( borderRadius: BorderRadius.circular(27), color: bubbleColor, ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ FlashingCircle( index: 0, repeatingController: repeatingController, dotIntervals: dotIntervals, flashingCircleDarkColor: flashingCircleDarkColor, flashingCircleBrightColor: flashingCircleBrightColor, ), FlashingCircle( index: 1, repeatingController: repeatingController, dotIntervals: dotIntervals, flashingCircleDarkColor: flashingCircleDarkColor, flashingCircleBrightColor: flashingCircleBrightColor, ), FlashingCircle( index: 2, repeatingController: repeatingController, dotIntervals: dotIntervals, flashingCircleDarkColor: flashingCircleDarkColor, flashingCircleBrightColor: flashingCircleBrightColor, ), ], ), ); } } class FlashingCircle extends StatelessWidget { const FlashingCircle({ super.key, required this.index, required this.repeatingController, required this.dotIntervals, required this.flashingCircleBrightColor, required this.flashingCircleDarkColor, }); final int index; final AnimationController repeatingController; final List<Interval> dotIntervals; final Color flashingCircleDarkColor; final Color flashingCircleBrightColor; @override Widget build(BuildContext context) { return AnimatedBuilder( animation: repeatingController, builder: (context, child) { final circleFlashPercent = dotIntervals[index].transform( repeatingController.value, ); final circleColorPercent = sin(pi * circleFlashPercent); return Container( width: 12, height: 12, decoration: BoxDecoration( shape: BoxShape.circle, color: Color.lerp( flashingCircleDarkColor, flashingCircleBrightColor, circleColorPercent, ), ), ); }, ); } } ``` Each circle calculates its color using a sine (`sin`) function so that the color changes gradually at the minimum and maximum points. Additionally, each circle animates its color within a specified interval that takes up a portion of the overall animation time. The position of these intervals generates the visual effect of a single light source moving behind the three dots. Congratulations! You now have a typing indicator that lets users know when someone else is typing. The indicator animates in and out, and displays a repeating animation while the other user is typing. ## Interactive example Run the app: * Click the round on/off switch at the bottom of the screen to turn the typing indicator bubble on and off. <!-- Start DartPad --> <?code-excerpt "lib/main.dart"?> ```run-dartpad:theme-light:mode-flutter:run-true:width-100%:height-600px:split-60:ga_id-interactive_example import 'dart:math'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; void main() { runApp( const MaterialApp( home: ExampleIsTyping(), debugShowCheckedModeBanner: false, ), ); } const _backgroundColor = Color(0xFF333333); class ExampleIsTyping extends StatefulWidget { const ExampleIsTyping({ super.key, }); @override State<ExampleIsTyping> createState() => _ExampleIsTypingState(); } class _ExampleIsTypingState extends State<ExampleIsTyping> { bool _isSomeoneTyping = false; @override Widget build(BuildContext context) { return Scaffold( backgroundColor: _backgroundColor, appBar: AppBar( title: const Text('Typing Indicator'), ), body: Column( children: [ Expanded( child: ListView.builder( padding: const EdgeInsets.symmetric(vertical: 8), itemCount: 25, reverse: true, itemBuilder: (context, index) { return Padding( padding: const EdgeInsets.only(left: 100), child: FakeMessage(isBig: index.isOdd), ); }, ), ), Align( alignment: Alignment.bottomLeft, child: TypingIndicator( showIndicator: _isSomeoneTyping, ), ), Container( color: Colors.grey, padding: const EdgeInsets.all(16), child: Center( child: CupertinoSwitch( onChanged: (newValue) { setState(() { _isSomeoneTyping = newValue; }); }, value: _isSomeoneTyping, ), ), ), ], ), ); } } class TypingIndicator extends StatefulWidget { const TypingIndicator({ super.key, this.showIndicator = false, this.bubbleColor = const Color(0xFF646b7f), this.flashingCircleDarkColor = const Color(0xFF333333), this.flashingCircleBrightColor = const Color(0xFFaec1dd), }); final bool showIndicator; final Color bubbleColor; final Color flashingCircleDarkColor; final Color flashingCircleBrightColor; @override State<TypingIndicator> createState() => _TypingIndicatorState(); } class _TypingIndicatorState extends State<TypingIndicator> with TickerProviderStateMixin { late AnimationController _appearanceController; late Animation<double> _indicatorSpaceAnimation; late Animation<double> _smallBubbleAnimation; late Animation<double> _mediumBubbleAnimation; late Animation<double> _largeBubbleAnimation; late AnimationController _repeatingController; final List<Interval> _dotIntervals = const [ Interval(0.25, 0.8), Interval(0.35, 0.9), Interval(0.45, 1.0), ]; @override void initState() { super.initState(); _appearanceController = AnimationController( vsync: this, )..addListener(() { setState(() {}); }); _indicatorSpaceAnimation = CurvedAnimation( parent: _appearanceController, curve: const Interval(0.0, 0.4, curve: Curves.easeOut), reverseCurve: const Interval(0.0, 1.0, curve: Curves.easeOut), ).drive(Tween<double>( begin: 0.0, end: 60.0, )); _smallBubbleAnimation = CurvedAnimation( parent: _appearanceController, curve: const Interval(0.0, 0.5, curve: Curves.elasticOut), reverseCurve: const Interval(0.0, 0.3, curve: Curves.easeOut), ); _mediumBubbleAnimation = CurvedAnimation( parent: _appearanceController, curve: const Interval(0.2, 0.7, curve: Curves.elasticOut), reverseCurve: const Interval(0.2, 0.6, curve: Curves.easeOut), ); _largeBubbleAnimation = CurvedAnimation( parent: _appearanceController, curve: const Interval(0.3, 1.0, curve: Curves.elasticOut), reverseCurve: const Interval(0.5, 1.0, curve: Curves.easeOut), ); _repeatingController = AnimationController( vsync: this, duration: const Duration(milliseconds: 1500), ); if (widget.showIndicator) { _showIndicator(); } } @override void didUpdateWidget(TypingIndicator oldWidget) { super.didUpdateWidget(oldWidget); if (widget.showIndicator != oldWidget.showIndicator) { if (widget.showIndicator) { _showIndicator(); } else { _hideIndicator(); } } } @override void dispose() { _appearanceController.dispose(); _repeatingController.dispose(); super.dispose(); } void _showIndicator() { _appearanceController ..duration = const Duration(milliseconds: 750) ..forward(); _repeatingController.repeat(); } void _hideIndicator() { _appearanceController ..duration = const Duration(milliseconds: 150) ..reverse(); _repeatingController.stop(); } @override Widget build(BuildContext context) { return AnimatedBuilder( animation: _indicatorSpaceAnimation, builder: (context, child) { return SizedBox( height: _indicatorSpaceAnimation.value, child: child, ); }, child: Stack( children: [ AnimatedBubble( animation: _smallBubbleAnimation, left: 8, bottom: 8, bubble: CircleBubble( size: 8, bubbleColor: widget.bubbleColor, ), ), AnimatedBubble( animation: _mediumBubbleAnimation, left: 10, bottom: 10, bubble: CircleBubble( size: 16, bubbleColor: widget.bubbleColor, ), ), AnimatedBubble( animation: _largeBubbleAnimation, left: 12, bottom: 12, bubble: StatusBubble( repeatingController: _repeatingController, dotIntervals: _dotIntervals, flashingCircleDarkColor: widget.flashingCircleDarkColor, flashingCircleBrightColor: widget.flashingCircleBrightColor, bubbleColor: widget.bubbleColor, ), ), ], ), ); } } class CircleBubble extends StatelessWidget { const CircleBubble({ super.key, required this.size, required this.bubbleColor, }); final double size; final Color bubbleColor; @override Widget build(BuildContext context) { return Container( width: size, height: size, decoration: BoxDecoration( shape: BoxShape.circle, color: bubbleColor, ), ); } } class AnimatedBubble extends StatelessWidget { const AnimatedBubble({ super.key, required this.animation, required this.left, required this.bottom, required this.bubble, }); final Animation<double> animation; final double left; final double bottom; final Widget bubble; @override Widget build(BuildContext context) { return Positioned( left: left, bottom: bottom, child: AnimatedBuilder( animation: animation, builder: (context, child) { return Transform.scale( scale: animation.value, alignment: Alignment.bottomLeft, child: child, ); }, child: bubble, ), ); } } class StatusBubble extends StatelessWidget { const StatusBubble({ super.key, required this.repeatingController, required this.dotIntervals, required this.flashingCircleBrightColor, required this.flashingCircleDarkColor, required this.bubbleColor, }); final AnimationController repeatingController; final List<Interval> dotIntervals; final Color flashingCircleDarkColor; final Color flashingCircleBrightColor; final Color bubbleColor; @override Widget build(BuildContext context) { return Container( width: 85, height: 44, padding: const EdgeInsets.symmetric(horizontal: 8), decoration: BoxDecoration( borderRadius: BorderRadius.circular(27), color: bubbleColor, ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ FlashingCircle( index: 0, repeatingController: repeatingController, dotIntervals: dotIntervals, flashingCircleDarkColor: flashingCircleDarkColor, flashingCircleBrightColor: flashingCircleBrightColor, ), FlashingCircle( index: 1, repeatingController: repeatingController, dotIntervals: dotIntervals, flashingCircleDarkColor: flashingCircleDarkColor, flashingCircleBrightColor: flashingCircleBrightColor, ), FlashingCircle( index: 2, repeatingController: repeatingController, dotIntervals: dotIntervals, flashingCircleDarkColor: flashingCircleDarkColor, flashingCircleBrightColor: flashingCircleBrightColor, ), ], ), ); } } class FlashingCircle extends StatelessWidget { const FlashingCircle({ super.key, required this.index, required this.repeatingController, required this.dotIntervals, required this.flashingCircleBrightColor, required this.flashingCircleDarkColor, }); final int index; final AnimationController repeatingController; final List<Interval> dotIntervals; final Color flashingCircleDarkColor; final Color flashingCircleBrightColor; @override Widget build(BuildContext context) { return AnimatedBuilder( animation: repeatingController, builder: (context, child) { final circleFlashPercent = dotIntervals[index].transform( repeatingController.value, ); final circleColorPercent = sin(pi * circleFlashPercent); return Container( width: 12, height: 12, decoration: BoxDecoration( shape: BoxShape.circle, color: Color.lerp( flashingCircleDarkColor, flashingCircleBrightColor, circleColorPercent, ), ), ); }, ); } } class FakeMessage extends StatelessWidget { const FakeMessage({ super.key, required this.isBig, }); final bool isBig; @override Widget build(BuildContext context) { return Container( margin: const EdgeInsets.symmetric(vertical: 8, horizontal: 24), height: isBig ? 128 : 36, decoration: BoxDecoration( borderRadius: const BorderRadius.all(Radius.circular(8)), color: Colors.grey.shade300, ), ); } } ``` [explicit animation]: /ui/animations#tween-animation [staggered animation]: /ui/animations/staggered-animations
website/src/cookbook/effects/typing-indicator.md/0
{ "file_path": "website/src/cookbook/effects/typing-indicator.md", "repo_id": "website", "token_count": 11577 }
1,410
--- title: Display images from the internet description: How to display images from the internet. js: - defer: true url: https://old-dartpad-3ce3f.web.app/inject_embed.dart.js --- <?code-excerpt path-base="cookbook/images/network_image"?> Displaying images is fundamental for most mobile apps. Flutter provides the [`Image`][] widget to display different types of images. To work with images from a URL, use the [`Image.network()`][] constructor. <?code-excerpt "lib/main.dart (ImageNetwork)" replace="/^body\: //g"?> ```dart Image.network('https://picsum.photos/250?image=9'), ``` ## Bonus: animated gifs One useful thing about the `Image` widget: It supports animated gifs. <?code-excerpt "lib/gif.dart (Gif)" replace="/^return\ //g"?> ```dart Image.network( 'https://docs.flutter.dev/assets/images/dash/dash-fainting.gif'); ``` ## Image fade in with placeholders The default `Image.network` constructor doesn't handle more advanced functionality, such as fading images in after loading. To accomplish this task, check out [Fade in images with a placeholder][]. * [Fade in images with a placeholder][] ## Interactive example <?code-excerpt "lib/main.dart"?> ```run-dartpad:theme-light:mode-flutter:run-true:width-100%:height-600px:split-60:ga_id-interactive_example import 'package:flutter/material.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { var title = 'Web Images'; return MaterialApp( title: title, home: Scaffold( appBar: AppBar( title: Text(title), ), body: Image.network('https://picsum.photos/250?image=9'), ), ); } } ``` <noscript> <img src="/assets/images/docs/cookbook/network-image.png" alt="Network image demo" class="site-mobile-screenshot" /> </noscript> [Fade in images with a placeholder]: /cookbook/images/fading-in-images [`Image`]: {{site.api}}/flutter/widgets/Image-class.html [`Image.network()`]: {{site.api}}/flutter/widgets/Image/Image.network.html
website/src/cookbook/images/network-image.md/0
{ "file_path": "website/src/cookbook/images/network-image.md", "repo_id": "website", "token_count": 735 }
1,411
--- title: Navigate with named routes description: How to implement named routes for navigating between screens. js: - defer: true url: https://old-dartpad-3ce3f.web.app/inject_embed.dart.js --- <?code-excerpt path-base="cookbook/navigation/named_routes"?> {{site.alert.note}} Named routes are no longer recommended for most applications. For more information, see [Limitations][] in the [navigation overview][] page. {{site.alert.end}} [Limitations]: /ui/navigation#limitations [navigation overview]: /ui/navigation In the [Navigate to a new screen and back][] recipe, you learned how to navigate to a new screen by creating a new route and pushing it to the [`Navigator`][]. However, if you need to navigate to the same screen in many parts of your app, this approach can result in code duplication. The solution is to define a _named route_, and use the named route for navigation. To work with named routes, use the [`Navigator.pushNamed()`][] function. This example replicates the functionality from the original recipe, demonstrating how to use named routes using the following steps: 1. Create two screens. 2. Define the routes. 3. Navigate to the second screen using `Navigator.pushNamed()`. 4. Return to the first screen using `Navigator.pop()`. ## 1. Create two screens First, create two screens to work with. The first screen contains a button that navigates to the second screen. The second screen contains a button that navigates back to the first. <?code-excerpt "lib/main_original.dart"?> ```dart import 'package:flutter/material.dart'; class FirstScreen extends StatelessWidget { const FirstScreen({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('First Screen'), ), body: Center( child: ElevatedButton( onPressed: () { // Navigate to the second screen when tapped. }, child: const Text('Launch screen'), ), ), ); } } class SecondScreen extends StatelessWidget { const SecondScreen({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Second Screen'), ), body: Center( child: ElevatedButton( onPressed: () { // Navigate back to first screen when tapped. }, child: const Text('Go back!'), ), ), ); } } ``` ## 2. Define the routes Next, define the routes by providing additional properties to the [`MaterialApp`][] constructor: the `initialRoute` and the `routes` themselves. The `initialRoute` property defines which route the app should start with. The `routes` property defines the available named routes and the widgets to build when navigating to those routes. {% comment %} RegEx removes the trailing comma {% endcomment %} <?code-excerpt "lib/main.dart (MaterialApp)" replace="/,$//g"?> ```dart MaterialApp( title: 'Named Routes Demo', // Start the app with the "/" named route. In this case, the app starts // on the FirstScreen widget. initialRoute: '/', routes: { // When navigating to the "/" route, build the FirstScreen widget. '/': (context) => const FirstScreen(), // When navigating to the "/second" route, build the SecondScreen widget. '/second': (context) => const SecondScreen(), }, ) ``` {{site.alert.warning}} When using `initialRoute`, **don't** define a `home` property. {{site.alert.end}} ## 3. Navigate to the second screen With the widgets and routes in place, trigger navigation by using the [`Navigator.pushNamed()`][] method. This tells Flutter to build the widget defined in the `routes` table and launch the screen. In the `build()` method of the `FirstScreen` widget, update the `onPressed()` callback: {% comment %} RegEx removes the trailing comma {% endcomment %} <?code-excerpt "lib/main.dart (PushNamed)" replace="/,$//g"?> ```dart // Within the `FirstScreen` widget onPressed: () { // Navigate to the second screen using a named route. Navigator.pushNamed(context, '/second'); } ``` ## 4. Return to the first screen To navigate back to the first screen, use the [`Navigator.pop()`][] function. {% comment %} RegEx removes the trailing comma {% endcomment %} <?code-excerpt "lib/main.dart (Pop)" replace="/,$//g"?> ```dart // Within the SecondScreen widget onPressed: () { // Navigate back to the first screen by popping the current route // off the stack. Navigator.pop(context); } ``` ## Interactive example <?code-excerpt "lib/main.dart"?> ```run-dartpad:theme-light:mode-flutter:run-true:width-100%:height-600px:split-60:ga_id-interactive_example import 'package:flutter/material.dart'; void main() { runApp( MaterialApp( title: 'Named Routes Demo', // Start the app with the "/" named route. In this case, the app starts // on the FirstScreen widget. initialRoute: '/', routes: { // When navigating to the "/" route, build the FirstScreen widget. '/': (context) => const FirstScreen(), // When navigating to the "/second" route, build the SecondScreen widget. '/second': (context) => const SecondScreen(), }, ), ); } class FirstScreen extends StatelessWidget { const FirstScreen({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('First Screen'), ), body: Center( child: ElevatedButton( // Within the `FirstScreen` widget onPressed: () { // Navigate to the second screen using a named route. Navigator.pushNamed(context, '/second'); }, child: const Text('Launch screen'), ), ), ); } } class SecondScreen extends StatelessWidget { const SecondScreen({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Second Screen'), ), body: Center( child: ElevatedButton( // Within the SecondScreen widget onPressed: () { // Navigate back to the first screen by popping the current route // off the stack. Navigator.pop(context); }, child: const Text('Go back!'), ), ), ); } } ``` <noscript> <img src="/assets/images/docs/cookbook/navigation-basics.gif" alt="Navigation Basics Demo" class="site-mobile-screenshot" /> </noscript> [`MaterialApp`]: {{site.api}}/flutter/material/MaterialApp-class.html [Navigate to a new screen and back]: /cookbook/navigation/navigation-basics [`Navigator`]: {{site.api}}/flutter/widgets/Navigator-class.html [`Navigator.pop()`]: {{site.api}}/flutter/widgets/Navigator/pop.html [`Navigator.pushNamed()`]: {{site.api}}/flutter/widgets/Navigator/pushNamed.html
website/src/cookbook/navigation/named-routes.md/0
{ "file_path": "website/src/cookbook/navigation/named-routes.md", "repo_id": "website", "token_count": 2438 }
1,412
--- title: Store key-value data on disk description: >- Learn how to use the shared_preferences package to store key-value data. --- <?code-excerpt path-base="cookbook/persistence/key_value/"?> If you have a relatively small collection of key-values to save, you can use the [`shared_preferences`][] plugin. Normally, you would have to write native platform integrations for storing data on each platform. Fortunately, the [`shared_preferences`][] plugin can be used to persist key-value data to disk on each platform Flutter supports. This recipe uses the following steps: 1. Add the dependency. 2. Save data. 3. Read data. 4. Remove data. {{site.alert.note}} To learn more, watch this short Package of the Week video on the `shared_preferences` package: <iframe class="full-width" src="{{site.yt.embed}}/sa_U0jffQII" title="Learn about the shared_preferences Flutter package" {{site.yt.set}}></iframe> {{site.alert.end}} ## 1. Add the dependency Before starting, add the [`shared_preferences`][] package as a dependency. To add the `shared_preferences` package as a dependency, run `flutter pub add`: ```terminal flutter pub add shared_preferences ``` ## 2. Save data To persist data, use the setter methods provided by the `SharedPreferences` class. Setter methods are available for various primitive types, such as `setInt`, `setBool`, and `setString`. Setter methods do two things: First, synchronously update the key-value pair in memory. Then, persist the data to disk. <?code-excerpt "lib/partial_excerpts.dart (Step2)"?> ```dart // Load and obtain the shared preferences for this app. final prefs = await SharedPreferences.getInstance(); // Save the counter value to persistent storage under the 'counter' key. await prefs.setInt('counter', counter); ``` ## 3. Read data To read data, use the appropriate getter method provided by the `SharedPreferences` class. For each setter there is a corresponding getter. For example, you can use the `getInt`, `getBool`, and `getString` methods. <?code-excerpt "lib/partial_excerpts.dart (Step3)"?> ```dart final prefs = await SharedPreferences.getInstance(); // Try reading the counter value from persistent storage. // If not present, null is returned, so default to 0. final counter = prefs.getInt('counter') ?? 0; ``` Note that the getter methods throw an exception if the persisted value has a different type than the getter method expects. ## 4. Remove data To delete data, use the `remove()` method. <?code-excerpt "lib/partial_excerpts.dart (Step4)"?> ```dart final prefs = await SharedPreferences.getInstance(); // Remove the counter key-value pair from persistent storage. await prefs.remove('counter'); ``` ## Supported types Although the key-value storage provided by `shared_preferences` is easy and convenient to use, it has limitations: * Only primitive types can be used: `int`, `double`, `bool`, `String`, and `List<String>`. * It's not designed to store large amounts of data. * There is no guarantee that data will be persisted across app restarts. ## Testing support It's a good idea to test code that persists data using `shared_preferences`. To enable this, the package provides an in-memory mock implementation of the preference store. To set up your tests to use the mock implementation, call the `setMockInitialValues` static method in a `setUpAll()` method in your test files. Pass in a map of key-value pairs to use as the initial values. <?code-excerpt "test/prefs_test.dart (setup)"?> ```dart SharedPreferences.setMockInitialValues(<String, Object>{ 'counter': 2, }); ``` ## Complete example <?code-excerpt "lib/main.dart"?> ```dart import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return const MaterialApp( title: 'Shared preferences demo', home: MyHomePage(title: 'Shared preferences demo'), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({super.key, required this.title}); final String title; @override State<MyHomePage> createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { int _counter = 0; @override void initState() { super.initState(); _loadCounter(); } /// Load the initial counter value from persistent storage on start, /// or fallback to 0 if it doesn't exist. Future<void> _loadCounter() async { final prefs = await SharedPreferences.getInstance(); setState(() { _counter = prefs.getInt('counter') ?? 0; }); } /// After a click, increment the counter state and /// asynchronously save it to persistent storage. Future<void> _incrementCounter() async { final prefs = await SharedPreferences.getInstance(); setState(() { _counter = (prefs.getInt('counter') ?? 0) + 1; prefs.setInt('counter', _counter); }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(widget.title), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ const Text( 'You have pushed the button this many times: ', ), Text( '$_counter', style: Theme.of(context).textTheme.headlineMedium, ), ], ), ), floatingActionButton: FloatingActionButton( onPressed: _incrementCounter, tooltip: 'Increment', child: const Icon(Icons.add), ), ); } } ``` [`shared_preferences`]: {{site.pub-pkg}}/shared_preferences
website/src/cookbook/persistence/key-value.md/0
{ "file_path": "website/src/cookbook/persistence/key-value.md", "repo_id": "website", "token_count": 1921 }
1,413
--- title: An introduction to widget testing description: Learn more about widget testing in Flutter. short-title: Introduction --- <?code-excerpt path-base="cookbook/testing/widget/introduction/"?> {% assign api = site.api | append: '/flutter' -%} In the [introduction to unit testing][] recipe, you learned how to test Dart classes using the `test` package. To test widget classes, you need a few additional tools provided by the [`flutter_test`][] package, which ships with the Flutter SDK. The `flutter_test` package provides the following tools for testing widgets: * The [`WidgetTester`][] allows building and interacting with widgets in a test environment. * The [`testWidgets()`][] function automatically creates a new `WidgetTester` for each test case, and is used in place of the normal `test()` function. * The [`Finder`][] classes allow searching for widgets in the test environment. * Widget-specific [`Matcher`][] constants help verify whether a `Finder` locates a widget or multiple widgets in the test environment. If this sounds overwhelming, don't worry. Learn how all of these pieces fit together throughout this recipe, which uses the following steps: 1. Add the `flutter_test` dependency. 2. Create a widget to test. 3. Create a `testWidgets` test. 4. Build the widget using the `WidgetTester`. 5. Search for the widget using a `Finder`. 6. Verify the widget using a `Matcher`. ### 1. Add the `flutter_test` dependency Before writing tests, include the `flutter_test` dependency in the `dev_dependencies` section of the `pubspec.yaml` file. If creating a new Flutter project with the command line tools or a code editor, this dependency should already be in place. ```yaml dev_dependencies: flutter_test: sdk: flutter ``` ### 2. Create a widget to test Next, create a widget for testing. For this recipe, create a widget that displays a `title` and `message`. <?code-excerpt "test/main_test.dart (widget)"?> ```dart class MyWidget extends StatelessWidget { const MyWidget({ super.key, required this.title, required this.message, }); final String title; final String message; @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', home: Scaffold( appBar: AppBar( title: Text(title), ), body: Center( child: Text(message), ), ), ); } } ``` ### 3. Create a `testWidgets` test With a widget to test, begin by writing your first test. Use the [`testWidgets()`][] function provided by the `flutter_test` package to define a test. The `testWidgets` function allows you to define a widget test and creates a `WidgetTester` to work with. This test verifies that `MyWidget` displays a given title and message. It is titled accordingly, and it will be populated in the next section. <?code-excerpt "test/main_step3_test.dart (main)"?> ```dart void main() { // Define a test. The TestWidgets function also provides a WidgetTester // to work with. The WidgetTester allows you to build and interact // with widgets in the test environment. testWidgets('MyWidget has a title and message', (tester) async { // Test code goes here. }); } ``` ### 4. Build the widget using the `WidgetTester` Next, build `MyWidget` inside the test environment by using the [`pumpWidget()`][] method provided by `WidgetTester`. The `pumpWidget` method builds and renders the provided widget. Create a `MyWidget` instance that displays "T" as the title and "M" as the message. <?code-excerpt "test/main_step4_test.dart (main)"?> ```dart void main() { testWidgets('MyWidget has a title and message', (tester) async { // Create the widget by telling the tester to build it. await tester.pumpWidget(const MyWidget(title: 'T', message: 'M')); }); } ``` #### Notes about the pump() methods After the initial call to `pumpWidget()`, the `WidgetTester` provides additional ways to rebuild the same widget. This is useful if you're working with a `StatefulWidget` or animations. For example, tapping a button calls `setState()`, but Flutter won't automatically rebuild your widget in the test environment. Use one of the following methods to ask Flutter to rebuild the widget. [`tester.pump(Duration duration)`][] : Schedules a frame and triggers a rebuild of the widget. If a `Duration` is specified, it advances the clock by that amount and schedules a frame. It does not schedule multiple frames even if the duration is longer than a single frame. {{site.alert.note}} To kick off the animation, you need to call `pump()` once (with no duration specified) to start the ticker. Without it, the animation does not start. {{site.alert.end}} [`tester.pumpAndSettle()`][] : Repeatedly calls `pump()` with the given duration until there are no longer any frames scheduled. This, essentially, waits for all animations to complete. These methods provide fine-grained control over the build lifecycle, which is particularly useful while testing. ### 5. Search for our widget using a `Finder` With a widget in the test environment, search through the widget tree for the `title` and `message` Text widgets using a `Finder`. This allows verification that the widgets are being displayed correctly. For this purpose, use the top-level [`find()`][] method provided by the `flutter_test` package to create the `Finders`. Since you know you're looking for `Text` widgets, use the [`find.text()`][] method. For more information about `Finder` classes, see the [Finding widgets in a widget test][] recipe. <?code-excerpt "test/main_step5_test.dart (main)"?> ```dart void main() { testWidgets('MyWidget has a title and message', (tester) async { await tester.pumpWidget(const MyWidget(title: 'T', message: 'M')); // Create the Finders. final titleFinder = find.text('T'); final messageFinder = find.text('M'); }); } ``` ### 6. Verify the widget using a `Matcher` Finally, verify the title and message `Text` widgets appear on screen using the `Matcher` constants provided by `flutter_test`. `Matcher` classes are a core part of the `test` package, and provide a common way to verify a given value meets expectations. Ensure that the widgets appear on screen exactly one time. For this purpose, use the [`findsOneWidget`][] `Matcher`. <?code-excerpt "test/main_step6_test.dart (main)"?> ```dart void main() { testWidgets('MyWidget has a title and message', (tester) async { await tester.pumpWidget(const MyWidget(title: 'T', message: 'M')); final titleFinder = find.text('T'); final messageFinder = find.text('M'); // Use the `findsOneWidget` matcher provided by flutter_test to verify // that the Text widgets appear exactly once in the widget tree. expect(titleFinder, findsOneWidget); expect(messageFinder, findsOneWidget); }); } ``` #### Additional Matchers In addition to `findsOneWidget`, `flutter_test` provides additional matchers for common cases. [`findsNothing`][] : Verifies that no widgets are found. [`findsWidgets`][] : Verifies that one or more widgets are found. [`findsNWidgets`][] : Verifies that a specific number of widgets are found. [`matchesGoldenFile`][] : Verifies that a widget's rendering matches a particular bitmap image ("golden file" testing). ### Complete example <?code-excerpt "test/main_test.dart"?> ```dart import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { // Define a test. The TestWidgets function also provides a WidgetTester // to work with. The WidgetTester allows building and interacting // with widgets in the test environment. testWidgets('MyWidget has a title and message', (tester) async { // Create the widget by telling the tester to build it. await tester.pumpWidget(const MyWidget(title: 'T', message: 'M')); // Create the Finders. final titleFinder = find.text('T'); final messageFinder = find.text('M'); // Use the `findsOneWidget` matcher provided by flutter_test to // verify that the Text widgets appear exactly once in the widget tree. expect(titleFinder, findsOneWidget); expect(messageFinder, findsOneWidget); }); } class MyWidget extends StatelessWidget { const MyWidget({ super.key, required this.title, required this.message, }); final String title; final String message; @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', home: Scaffold( appBar: AppBar( title: Text(title), ), body: Center( child: Text(message), ), ), ); } } ``` [`find()`]: {{api}}/flutter_test/find-constant.html [`find.text()`]: {{api}}/flutter_test/CommonFinders/text.html [`findsNothing`]: {{api}}/flutter_test/findsNothing-constant.html [`findsOneWidget`]: {{api}}/flutter_test/findsOneWidget-constant.html [`findsNWidgets`]: {{api}}/flutter_test/findsNWidgets.html [`findsWidgets`]: {{api}}/flutter_test/findsWidgets-constant.html [`matchesGoldenFile`]: {{api}}/flutter_test/matchesGoldenFile.html [`Finder`]: {{api}}/flutter_test/Finder-class.html [Finding widgets in a widget test]: /cookbook/testing/widget/finders [`flutter_test`]: {{api}}/flutter_test/flutter_test-library.html [introduction to unit testing]: /cookbook/testing/unit/introduction [`Matcher`]: {{api}}/package-matcher_matcher/Matcher-class.html [`pumpWidget()`]: {{api}}/flutter_test/WidgetTester/pumpWidget.html [`tester.pump(Duration duration)`]: {{api}}/flutter_test/TestWidgetsFlutterBinding/pump.html [`tester.pumpAndSettle()`]: {{api}}/flutter_test/WidgetTester/pumpAndSettle.html [`testWidgets()`]: {{api}}/flutter_test/testWidgets.html [`WidgetTester`]: {{api}}/flutter_test/WidgetTester-class.html
website/src/cookbook/testing/widget/introduction.md/0
{ "file_path": "website/src/cookbook/testing/widget/introduction.md", "repo_id": "website", "token_count": 3185 }
1,414
--- title: Simple app state management description: A simple form of state management. prev: title: Ephemeral versus app state path: /development/data-and-backend/state-mgmt/ephemeral-vs-app next: title: List of approaches path: /development/data-and-backend/state-mgmt/options --- <?code-excerpt path-base="state_mgmt/simple/"?> Now that you know about [declarative UI programming][] and the difference between [ephemeral and app state][], you are ready to learn about simple app state management. On this page, we are going to be using the `provider` package. If you are new to Flutter and you don't have a strong reason to choose another approach (Redux, Rx, hooks, etc.), this is probably the approach you should start with. The `provider` package is easy to understand and it doesn't use much code. It also uses concepts that are applicable in every other approach. That said, if you have a strong background in state management from other reactive frameworks, you can find packages and tutorials listed on the [options page][]. ## Our example <img src='/assets/images/docs/development/data-and-backend/state-mgmt/model-shopper-screencast.gif' alt='An animated gif showing a Flutter app in use. It starts with the user on a login screen. They log in and are taken to the catalog screen, with a list of items. The click on several items, and as they do so, the items are marked as "added". The user clicks on a button and gets taken to the cart view. They see the items there. They go back to the catalog, and the items they bought still show "added". End of animation.' class='site-image-right'> For illustration, consider the following simple app. The app has two separate screens: a catalog, and a cart (represented by the `MyCatalog`, and `MyCart` widgets, respectively). It could be a shopping app, but you can imagine the same structure in a simple social networking app (replace catalog for "wall" and cart for "favorites"). The catalog screen includes a custom app bar (`MyAppBar`) and a scrolling view of many list items (`MyListItems`). Here's the app visualized as a widget tree. <img src='/assets/images/docs/development/data-and-backend/state-mgmt/simple-widget-tree.png' width="100%" alt="A widget tree with MyApp at the top, and MyCatalog and MyCart below it. MyCart area leaf nodes, but MyCatalog have two children: MyAppBar and a list of MyListItems."> {% comment %} Source drawing for the png above: https://docs.google.com/drawings/d/1KXxAl_Ctxc-avhR4uE58BXBM6Tyhy0pQMCsSMFHVL_0/edit?zx=y4m1lzbhsrvx {% endcomment %} So we have at least 5 subclasses of `Widget`. Many of them need access to state that "belongs" elsewhere. For example, each `MyListItem` needs to be able to add itself to the cart. It might also want to see whether the currently displayed item is already in the cart. This takes us to our first question: where should we put the current state of the cart? ## Lifting state up In Flutter, it makes sense to keep the state above the widgets that use it. Why? In declarative frameworks like Flutter, if you want to change the UI, you have to rebuild it. There is no easy way to have `MyCart.updateWith(somethingNew)`. In other words, it's hard to imperatively change a widget from outside, by calling a method on it. And even if you could make this work, you would be fighting the framework instead of letting it help you. ```dart // BAD: DO NOT DO THIS void myTapHandler() { var cartWidget = somehowGetMyCartWidget(); cartWidget.updateWith(item); } ``` Even if you get the above code to work, you would then have to deal with the following in the `MyCart` widget: ```dart // BAD: DO NOT DO THIS Widget build(BuildContext context) { return SomeWidget( // The initial state of the cart. ); } void updateWith(Item item) { // Somehow you need to change the UI from here. } ``` You would need to take into consideration the current state of the UI and apply the new data to it. It's hard to avoid bugs this way. In Flutter, you construct a new widget every time its contents change. Instead of `MyCart.updateWith(somethingNew)` (a method call) you use `MyCart(contents)` (a constructor). Because you can only construct new widgets in the build methods of their parents, if you want to change `contents`, it needs to live in `MyCart`'s parent or above. <?code-excerpt "lib/src/provider.dart (myTapHandler)"?> ```dart // GOOD void myTapHandler(BuildContext context) { var cartModel = somehowGetMyCartModel(context); cartModel.add(item); } ``` Now `MyCart` has only one code path for building any version of the UI. <?code-excerpt "lib/src/provider.dart (build)"?> ```dart // GOOD Widget build(BuildContext context) { var cartModel = somehowGetMyCartModel(context); return SomeWidget( // Just construct the UI once, using the current state of the cart. // ··· ); } ``` In our example, `contents` needs to live in `MyApp`. Whenever it changes, it rebuilds `MyCart` from above (more on that later). Because of this, `MyCart` doesn't need to worry about lifecycle&mdash;it just declares what to show for any given `contents`. When that changes, the old `MyCart` widget disappears and is completely replaced by the new one. <img src='/assets/images/docs/development/data-and-backend/state-mgmt/simple-widget-tree-with-cart.png' width="100%" alt="Same widget tree as above, but now we show a small 'cart' badge next to MyApp, and there are two arrows here. One comes from one of the MyListItems to the 'cart', and another one goes from the 'cart' to the MyCart widget."> {% comment %} Source drawing for the png above: https://docs.google.com/drawings/d/1ErMyaX4fwfbIW9ABuPAlHELLGMsU6cdxPDFz_elsS9k/edit?zx=j42inp8903pt {% endcomment %} This is what we mean when we say that widgets are immutable. They don't change&mdash;they get replaced. Now that we know where to put the state of the cart, let's see how to access it. ## Accessing the state When a user clicks on one of the items in the catalog, it's added to the cart. But since the cart lives above `MyListItem`, how do we do that? A simple option is to provide a callback that `MyListItem` can call when it is clicked. Dart's functions are first class objects, so you can pass them around any way you want. So, inside `MyCatalog` you can define the following: <?code-excerpt "lib/src/passing_callbacks.dart (methods)"?> ```dart @override Widget build(BuildContext context) { return SomeWidget( // Construct the widget, passing it a reference to the method above. MyListItem(myTapCallback), ); } void myTapCallback(Item item) { print('user tapped on $item'); } ``` This works okay, but for an app state that you need to modify from many different places, you'd have to pass around a lot of callbacks&mdash;which gets old pretty quickly. Fortunately, Flutter has mechanisms for widgets to provide data and services to their descendants (in other words, not just their children, but any widgets below them). As you would expect from Flutter, where _Everything is a Widget™_, these mechanisms are just special kinds of widgets&mdash;`InheritedWidget`, `InheritedNotifier`, `InheritedModel`, and more. We won't be covering those here, because they are a bit low-level for what we're trying to do. Instead, we are going to use a package that works with the low-level widgets but is simple to use. It's called `provider`. Before working with `provider`, don't forget to add the dependency on it to your `pubspec.yaml`. To add the `provider` package as a dependency, run `flutter pub add`: ```terminal $ flutter pub add provider ``` Now you can `import 'package:provider/provider.dart';` and start building. With `provider`, you don't need to worry about callbacks or `InheritedWidgets`. But you do need to understand 3 concepts: * ChangeNotifier * ChangeNotifierProvider * Consumer ## ChangeNotifier `ChangeNotifier` is a simple class included in the Flutter SDK which provides change notification to its listeners. In other words, if something is a `ChangeNotifier`, you can subscribe to its changes. (It is a form of Observable, for those familiar with the term.) In `provider`, `ChangeNotifier` is one way to encapsulate your application state. For very simple apps, you get by with a single `ChangeNotifier`. In complex ones, you'll have several models, and therefore several `ChangeNotifiers`. (You don't need to use `ChangeNotifier` with `provider` at all, but it's an easy class to work with.) In our shopping app example, we want to manage the state of the cart in a `ChangeNotifier`. We create a new class that extends it, like so: <?code-excerpt "lib/src/provider.dart (model)" replace="/ChangeNotifier/[!$&!]/g;/notifyListeners/[!$&!]/g"?> ```dart class CartModel extends [!ChangeNotifier!] { /// Internal, private state of the cart. final List<Item> _items = []; /// An unmodifiable view of the items in the cart. UnmodifiableListView<Item> get items => UnmodifiableListView(_items); /// The current total price of all items (assuming all items cost $42). int get totalPrice => _items.length * 42; /// Adds [item] to cart. This and [removeAll] are the only ways to modify the /// cart from the outside. void add(Item item) { _items.add(item); // This call tells the widgets that are listening to this model to rebuild. [!notifyListeners!](); } /// Removes all items from the cart. void removeAll() { _items.clear(); // This call tells the widgets that are listening to this model to rebuild. [!notifyListeners!](); } } ``` The only code that is specific to `ChangeNotifier` is the call to `notifyListeners()`. Call this method any time the model changes in a way that might change your app's UI. Everything else in `CartModel` is the model itself and its business logic. `ChangeNotifier` is part of `flutter:foundation` and doesn't depend on any higher-level classes in Flutter. It's easily testable (you don't even need to use [widget testing][] for it). For example, here's a simple unit test of `CartModel`: <?code-excerpt "test/model_test.dart (test)"?> ```dart test('adding item increases total cost', () { final cart = CartModel(); final startingPrice = cart.totalPrice; var i = 0; cart.addListener(() { expect(cart.totalPrice, greaterThan(startingPrice)); i++; }); cart.add(Item('Dash')); expect(i, 1); }); ``` ## ChangeNotifierProvider `ChangeNotifierProvider` is the widget that provides an instance of a `ChangeNotifier` to its descendants. It comes from the `provider` package. We already know where to put `ChangeNotifierProvider`: above the widgets that need to access it. In the case of `CartModel`, that means somewhere above both `MyCart` and `MyCatalog`. You don't want to place `ChangeNotifierProvider` higher than necessary (because you don't want to pollute the scope). But in our case, the only widget that is on top of both `MyCart` and `MyCatalog` is `MyApp`. <?code-excerpt "lib/main.dart (main)" replace="/ChangeNotifierProvider/[!$&!]/g"?> ```dart void main() { runApp( [!ChangeNotifierProvider!]( create: (context) => CartModel(), child: const MyApp(), ), ); } ``` Note that we're defining a builder that creates a new instance of `CartModel`. `ChangeNotifierProvider` is smart enough _not_ to rebuild `CartModel` unless absolutely necessary. It also automatically calls `dispose()` on `CartModel` when the instance is no longer needed. If you want to provide more than one class, you can use `MultiProvider`: <?code-excerpt "lib/main.dart (multi-provider-main)" replace="/multiProviderMain/main/g;/MultiProvider/[!$&!]/g"?> ```dart void main() { runApp( [!MultiProvider!]( providers: [ ChangeNotifierProvider(create: (context) => CartModel()), Provider(create: (context) => SomeOtherClass()), ], child: const MyApp(), ), ); } ``` ## Consumer Now that `CartModel` is provided to widgets in our app through the `ChangeNotifierProvider` declaration at the top, we can start using it. This is done through the `Consumer` widget. <?code-excerpt "lib/src/provider.dart (descendant)" replace="/Consumer/[!$&!]/g"?> ```dart return [!Consumer!]<CartModel>( builder: (context, cart, child) { return Text('Total price: ${cart.totalPrice}'); }, ); ``` We must specify the type of the model that we want to access. In this case, we want `CartModel`, so we write `Consumer<CartModel>`. If you don't specify the generic (`<CartModel>`), the `provider` package won't be able to help you. `provider` is based on types, and without the type, it doesn't know what you want. The only required argument of the `Consumer` widget is the builder. Builder is a function that is called whenever the `ChangeNotifier` changes. (In other words, when you call `notifyListeners()` in your model, all the builder methods of all the corresponding `Consumer` widgets are called.) The builder is called with three arguments. The first one is `context`, which you also get in every build method. The second argument of the builder function is the instance of the `ChangeNotifier`. It's what we were asking for in the first place. You can use the data in the model to define what the UI should look like at any given point. The third argument is `child`, which is there for optimization. If you have a large widget subtree under your `Consumer` that _doesn't_ change when the model changes, you can construct it once and get it through the builder. <?code-excerpt "lib/src/performance.dart (child)" replace="/\bchild\b/[!$&!]/g"?> ```dart return Consumer<CartModel>( builder: (context, cart, [!child!]) => Stack( children: [ // Use SomeExpensiveWidget here, without rebuilding every time. if ([!child!] != null) [!child!], Text('Total price: ${cart.totalPrice}'), ], ), // Build the expensive widget here. [!child!]: const SomeExpensiveWidget(), ); ``` It is best practice to put your `Consumer` widgets as deep in the tree as possible. You don't want to rebuild large portions of the UI just because some detail somewhere changed. <?code-excerpt "lib/src/performance.dart (nonLeafDescendant)"?> ```dart // DON'T DO THIS return Consumer<CartModel>( builder: (context, cart, child) { return HumongousWidget( // ... child: AnotherMonstrousWidget( // ... child: Text('Total price: ${cart.totalPrice}'), ), ); }, ); ``` Instead: <?code-excerpt "lib/src/performance.dart (leafDescendant)"?> ```dart // DO THIS return HumongousWidget( // ... child: AnotherMonstrousWidget( // ... child: Consumer<CartModel>( builder: (context, cart, child) { return Text('Total price: ${cart.totalPrice}'); }, ), ), ); ``` ### Provider.of Sometimes, you don't really need the _data_ in the model to change the UI but you still need to access it. For example, a `ClearCart` button wants to allow the user to remove everything from the cart. It doesn't need to display the contents of the cart, it just needs to call the `clear()` method. We could use `Consumer<CartModel>` for this, but that would be wasteful. We'd be asking the framework to rebuild a widget that doesn't need to be rebuilt. For this use case, we can use `Provider.of`, with the `listen` parameter set to `false`. <?code-excerpt "lib/src/performance.dart (nonRebuilding)" replace="/listen: false/[!$&!]/g"?> ```dart Provider.of<CartModel>(context, [!listen: false!]).removeAll(); ``` Using the above line in a build method won't cause this widget to rebuild when `notifyListeners` is called. ## Putting it all together You can [check out the example][] covered in this article. If you want something simpler, see what the simple Counter app looks like when [built with `provider`][]. By following along with these articles, you've greatly improved your ability to create state-based applications. Try building an application with `provider` yourself to master these skills. [built with `provider`]: {{site.repo.samples}}/tree/main/provider_counter [check out the example]: {{site.repo.samples}}/tree/main/provider_shopper [declarative UI programming]: /data-and-backend/state-mgmt/declarative [ephemeral and app state]: /data-and-backend/state-mgmt/ephemeral-vs-app [options page]: /data-and-backend/state-mgmt/options [widget testing]: /testing/overview#widget-tests
website/src/data-and-backend/state-mgmt/simple.md/0
{ "file_path": "website/src/data-and-backend/state-mgmt/simple.md", "repo_id": "website", "token_count": 4933 }
1,415
--- title: Set up an editor description: Configuring an IDE for Flutter. prev: title: Install path: /get-started/install next: title: Test drive path: /get-started/test-drive toc: false --- You can build apps with Flutter using any text editor or integrated development environment (IDE) combined with Flutter's command-line tools. The Flutter team recommends using an editor that supports a Flutter extension or plugin, like VS Code and Android Studio. These plugins provide code completion, syntax highlighting, widget editing assists, run & debug support, and more. You can add a supported plugin for Visual Studio Code, Android Studio, or IntelliJ IDEA Community, Educational, and Ultimate editions. The [Flutter plugin][] _only_ works with Android Studio and the listed editions of IntelliJ IDEA. (The [Dart plugin][] supports eight additional JetBrains IDEs.) [Flutter plugin]: https://plugins.jetbrains.com/plugin/9212-flutter [Dart plugin]: https://plugins.jetbrains.com/plugin/6351-dart Follow these procedures to add the Flutter plugin to VS Code, Android Studio, or IntelliJ. If you choose another IDE, skip ahead to the [next step: Test drive][]. {% comment %} Nav tabs {% endcomment -%} <ul class="nav nav-tabs" id="editor-setup" role="tablist"> <li class="nav-item"> <a class="nav-link active" id="vscode-tab" href="#vscode" role="tab" aria-controls="vscode" aria-selected="true">Visual Studio Code</a> </li> <li class="nav-item"> <a class="nav-link" id="androidstudio-tab" href="#androidstudio" role="tab" aria-controls="androidstudio" aria-selected="false">Android Studio and IntelliJ</a> </li> </ul> {% comment %} Tab panes {% endcomment -%} <div class="tab-content"> <div class="tab-pane active" id="vscode" role="tabpanel" aria-labelledby="vscode-tab" markdown="1"> ## Install VS Code [VS Code][] is a code editor to build and debug apps. With the Flutter extension installed, you can compile, deploy, and debug Flutter apps. To install the latest version of VS Code, follow Microsoft's instructions for the relevant platform: - [Install on macOS][] - [Install on Windows][] - [Install on Linux][] [VS Code]: https://code.visualstudio.com/ [Install on macOS]: https://code.visualstudio.com/docs/setup/mac [Install on Windows]: https://code.visualstudio.com/docs/setup/windows [Install on Linux]: https://code.visualstudio.com/docs/setup/linux ## Install the VS Code Flutter extension 1. Start **VS Code**. 1. Open a browser and go to the [Flutter extension][] page on the Visual Studio Marketplace. 1. Click **Install**. Installing the Flutter extension also installs the Dart extension. [Flutter extension]: https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter ## Validate your VS Code setup 1. Go to **View** <span aria-label="and then">></span> **Command Palette...**. You can also press <kbd>Ctrl</kbd> / <kbd>Cmd</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd>. 1. Type `doctor`. 1. Select the **Flutter: Run Flutter Doctor**. Once you select this command, VS Code does the following. - Opens the **Output** panel. - Displays **flutter (flutter)** in the dropdown on the upper right of this panel. - Displays the output of Flutter Doctor command. </div> <div class="tab-pane" id="androidstudio" role="tabpanel" aria-labelledby="androidstudio-tab" markdown="1"> ## Install Android Studio or IntelliJ IDEA Android Studio and IntelliJ IDEA offer a complete, IDE experience once you install the Flutter plugin. To install the latest version of the following IDEs, follow their instructions: - [Android Studio][] - [IntelliJ IDEA Community][] - [IntelliJ IDEA Ultimate][] ## Install the Flutter plugin The installation instructions vary by platform. ### macOS Use the following instructions for macOS: 1. Start Android Studio or IntelliJ. 1. From the macOS menu bar, go to **Android Studio** (or **IntelliJ**) <span aria-label="and then">></span> **Settings...**. You can also press <kbd>Cmd</kbd> + <kbd>,</kbd>. The **Preferences** dialog opens. 1. From the list at the left, select **Plugins**. 1. From the top of this panel, select **Marketplace**. 1. Type `flutter` in the plugins search field. 1. Select the **Flutter** plugin. 1. Click **Install**. 1. Click **Yes** when prompted to install the plugin. 1. Click **Restart** when prompted. ### Linux or Windows Use the following instructions for Linux or Windows: 1. Go to **File** <span aria-label="and then">></span> **Settings**. You can also press <kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>S</kbd>. The **Preferences** dialog opens. 1. From the list at the left, select **Plugins**. 1. From the top of this panel, select **Marketplace**. 1. Type `flutter` in the plugins search field. 1. Select the **Flutter** plugin. 1. Click **Install**. 1. Click **Yes** when prompted to install the plugin. 1. Click **Restart** when prompted. </div> </div>{% comment %} End: Tab panes. {% endcomment -%} [Android Studio]: {{site.android-dev}}/studio/install [IntelliJ IDEA Community]: https://www.jetbrains.com/idea/download/ [IntelliJ IDEA Ultimate]: https://www.jetbrains.com/idea/download/ [next step: Test drive]: /get-started/test-drive
website/src/get-started/editor.md/0
{ "file_path": "website/src/get-started/editor.md", "repo_id": "website", "token_count": 1674 }
1,416
--- title: Get started description: Get started developing your first app with Flutter! # This is a placeholder page (Firebase redirects this page's URL to another); # it is necessary to allow breadcrumbs to work. ---
website/src/get-started/index.md/0
{ "file_path": "website/src/get-started/index.md", "repo_id": "website", "token_count": 54 }
1,417
--- title: Choose your first type of app description: Configure your system to develop Flutter on ChromeOS. short-title: ChromeOS target-list: [Android, Web] --- {% assign os = 'chromeos' -%} {% assign recommend = 'Android' %} {% capture rec-target -%} [{{recommend}}](/get-started/install/{{os | downcase}}/{{recommend | downcase}}) {%- endcapture %} <div class="card-deck mb-8"> {% for target in page.target-list %} <a class="card card-app-type card-chromeos" id="install-{{os | remove: ' ' | downcase}}" href="/get-started/install/{{os | remove: ' ' | downcase}}/{{target | downcase}}"> <div class="card-body"> <header class="card-title text-center m-0"> <span class="d-block h1"> {% assign icon = target | downcase -%} {% if icon == 'android' -%} <span class="material-symbols">phone_android</span> {% else -%} <span class="material-symbols">web</span> {% endif -%} </span> <span class="text-muted text-nowrap">{{target}}</span> {% if icon == 'android' -%} <div class="card-subtitle">Recommended</div> {% endif %} </header> </div> </a> {% endfor %} </div> Your choice informs which parts of Flutter tooling you configure to run your first Flutter app. You can set up additional platforms later. _If you don't have a preference, choose **{{rec-target}}**._ {% include docs/china-notice.md %}
website/src/get-started/install/chromeos/index.md/0
{ "file_path": "website/src/get-started/install/chromeos/index.md", "repo_id": "website", "token_count": 584 }
1,418
--- title: Start building Flutter web apps on Windows description: Configure your system to develop Flutter web apps on Windows. short-title: Make web apps target: web config: WindowsWeb devos: Windows next: title: Create a test app path: /get-started/test-drive --- {% include docs/install/reqs/windows/base.md os=page.devos target=page.target -%} {% include docs/install/flutter-sdk.md os=page.devos target=page.target terminal='PowerShell' -%} {% include docs/install/flutter-doctor.md devos=page.devos target=page.target config='WindowsWeb' -%} {% include docs/install/next-steps.md devos=page.devos target=page.target config=page.config -%}
website/src/get-started/install/windows/web.md/0
{ "file_path": "website/src/get-started/install/windows/web.md", "repo_id": "website", "token_count": 253 }
1,419
--- title: Performance FAQ description: Frequently asked questions about Flutter performance --- This page collects some frequently asked questions about evaluating and debugging Flutter's performance. * Which performance dashboards have metrics that are related to Flutter? * [Flutter dashboard on appspot][] * [Flutter Skia dashboard][] * [Flutter Engine Skia dashboard][] [Flutter dashboard on appspot]: https://flutter-dashboard.appspot.com/ [Flutter engine Skia dashboard]: https://flutter-engine-perf.skia.org/t/?subset=regressions [Flutter Skia dashboard]: https://flutter-flutter-perf.skia.org/t/?subset=regressions * How do I add a benchmark to Flutter? * [How to write a render speed test for Flutter][speed-test] * [How to write a memory test for Flutter][memory-test] [memory-test]: {{site.repo.flutter}}/wiki/How-to-write-a-memory-test-for-Flutter [speed-test]: {{site.repo.flutter}}/wiki/How-to-write-a-render-speed-test-for-Flutter * What are some tools for capturing and analyzing performance metrics? * [Dart DevTools](/tools/devtools) * [Apple instruments](https://en.wikipedia.org/wiki/Instruments_(software)) * [Linux perf](https://en.wikipedia.org/wiki/Perf_(Linux)) * [Chrome tracing (enter `about:tracing` in your Chrome URL field)][tracing] * [Android systrace (`adb systrace`)][systrace] * [Fuchsia `fx traceutil`][traceutil] * [Perfetto](https://ui.perfetto.dev/) * [speedscope](https://www.speedscope.app/) [systrace]: {{site.android-dev}}/studio/profile/systrace [tracing]: https://www.chromium.org/developers/how-tos/trace-event-profiling-tool [traceutil]: https://fuchsia.dev/fuchsia-src/development/tracing/usage-guide * My Flutter app looks janky or stutters. How do I fix it? * [Improving rendering performance][] [Improving rendering performance]: /perf/rendering-performance * What are some costly performance operations that I need to be careful with? * [`Opacity`][], [`Clip.antiAliasWithSaveLayer`][], or anything that triggers [`saveLayer`][] * [`ImageFilter`][] * Also see [Performance best practices][] [`Clip.antiAliasWithSaveLayer`]: {{site.api}}/flutter/dart-ui/Clip.html#antiAliasWithSaveLayer [`ImageFilter`]: {{site.api}}/flutter/dart-ui/ImageFilter-class.html [`Opacity`]: {{site.api}}/flutter/widgets/Opacity-class.html [Performance best practices]: /perf/best-practices [`savelayer`]: {{site.api}}/flutter/dart-ui/Canvas/saveLayer.html * How do I tell which widgets in my Flutter app are rebuilt in each frame? * Set [`debugProfileBuildsEnabled`][] true in [widgets/debug.dart][debug.dart]. * Alternatively, change the `performRebuild` function in [widgets/framework.dart][framework.dart] to ignore `debugProfileBuildsEnabled` and always call `Timeline.startSync(...)/finish`. * If you use IntelliJ, a GUI view of this data is available. Select **Track widget rebuilds**, and your IDE displays which the widgets rebuild. [`debugProfileBuildsEnabled`]: {{site.api}}/flutter/widgets/debugProfileBuildsEnabled.html [debug.dart]: {{site.repo.flutter}}/blob/master/packages/flutter/lib/src/widgets/debug.dart [framework.dart]: {{site.repo.flutter}}/blob/master/packages/flutter/lib/src/widgets/framework.dart * How do I query the target frames per second (of the display)? * [Get the display refresh rate][] [Get the display refresh rate]: {{site.repo.flutter}}/wiki/Engine-specific-Service-Protocol-extensions#get-the-display-refresh-rate-_fluttergetdisplayrefreshrate * How to solve my app's poor animations caused by an expensive Dart async function call that is blocking the UI thread? * Spawn another isolate using the [`compute()`][] method, as demonstrated in [Parse JSON in the background][] cookbook. [`compute()`]: {{site.api}}/flutter/foundation/compute-constant.html [Parse JSON in the background]: /cookbook/networking/background-parsing * How do I determine my Flutter app's package size that a user will download? * See [Measuring your app's size][] [Measuring your app's size]: /perf/app-size * How do I see the breakdown of the Flutter engine size? * Visit the [binary size dashboard][], and replace the git hash in the URL with a recent commit hash from [GitHub engine repository commits][]. [binary size dashboard]: https://storage.googleapis.com/flutter_infra_release/flutter/241c87ad800beeab545ab867354d4683d5bfb6ce/android-arm-release/sizes/index.html [GitHub engine repository commits]: {{site.repo.engine}}/commits * How can I take a screenshot of an app that is running and export it as a SKP file? * Run `flutter screenshot --type=skia --observatory-uri=...` * Note a known issue viewing screenshots: * [Issue 21237][]: Doesn't record images in real devices. * To analyze and visualize the SKP file, check out the [Skia WASM debugger][]. [Issue 21237]: {{site.repo.flutter}}/issues/21237 [Skia WASM debugger]: https://debugger.skia.org/ * How do I retrieve the shader persistent cache from a device? * On Android, you can do the following: ```terminal adb shell run-as <com.your_app_package_name> cp <your_folder> <some_public_folder, e.g., /sdcard> -r adb pull <some_public_folder/your_folder> ``` * How do I perform a trace in Fuchsia? * See [Fuchsia tracing guidelines][traceutil]
website/src/perf/faq.md/0
{ "file_path": "website/src/perf/faq.md", "repo_id": "website", "token_count": 1751 }
1,420
--- title: Add Android devtools for Flutter from Web on ChromeOS start description: Configure your ChromeOS system to develop Flutter mobile apps for Android. short-title: Starting from Web on ChromeOS --- To add Android as a Flutter app target for ChromeOS, follow this procedure. ## Install Android Studio 1. Allocate a minimum of 7.5 GB of storage for Android Studio. Consider allocating 10 GB of storage for an optimal configuration. 1. Install the following prequisite packages for Android Studio: `libc6:i386`, `libncurses5:i386`, `libstdc++6:i386`, `lib32z1`, `libbz2-1.0:i386` ```terminal $ sudo apt-get install \ libc6:i386 libncurses5:i386 \ libstdc++6:i386 lib32z1 \ libbz2-1.0:i386 ``` 1. Install [Android Studio][] {{site.appmin.android_studio}} to debug and compile Java or Kotlin code for Android. Flutter requires the full version of Android Studio. {% include docs/install/compiler/android.md target='linux' devos='ChromeOS' attempt="first" -%} {% include docs/install/flutter-doctor.md target='Android' devos='ChromeOS' config='ChromeOSAndroidWeb' %} [Android Studio]: https://developer.android.com/studio/install#linux
website/src/platform-integration/android/install-android/install-android-from-web-on-chromeos.md/0
{ "file_path": "website/src/platform-integration/android/install-android/install-android-from-web-on-chromeos.md", "repo_id": "website", "token_count": 417 }
1,421
--- title: Add iOS devtools to Flutter from macOS start description: Configure your system to develop Flutter mobile apps on iOS. short-title: Starting from macOS --- To add iOS as a Flutter app target for macOS, follow this procedure. This procedure presumes you installed [Xcode][] {{site.appnow.xcode}} when your Flutter getting started path began with macOS. {% include docs/install/compiler/xcode.md target='iOS' devos='macOS' attempt="next" -%} {% include docs/install/flutter-doctor.md target='iOS' devos='macOS' config='macOSDesktopiOS' %} [Xcode]: {{site.apple-dev}}/xcode/
website/src/platform-integration/ios/install-ios/install-ios-from-macos.md/0
{ "file_path": "website/src/platform-integration/ios/install-ios/install-ios-from-macos.md", "repo_id": "website", "token_count": 195 }
1,422
--- title: Add macOS devtools to Flutter from Android start description: Configure your system to develop Flutter mobile apps also on macOS. short-title: Starting from Android --- To add macOS desktop as a Flutter app target, follow this procedure. ## Install Xcode 1. Allocate a minimum of 26 GB of storage for Xcode. Consider allocating 42 GB of storage for an optimal configuration. 1. Install [Xcode][] {{site.appnow.xcode}} to debug and compile native Swift or ObjectiveC code. {% include docs/install/compiler/xcode.md target='macOS' devos='macOS' attempt="first" -%} {% include docs/install/flutter-doctor.md target='macOS' devos='macOS' config='macOSDesktopAndroid' %} [Xcode]: {{site.apple-dev}}/xcode/
website/src/platform-integration/macos/install-macos/install-macos-from-android.md/0
{ "file_path": "website/src/platform-integration/macos/install-macos/install-macos-from-android.md", "repo_id": "website", "token_count": 233 }
1,423
--- title: Add Web devtools to Flutter from macOS start description: Configure your system to develop Flutter web apps on macOS. short-title: Starting from macOS desktop --- To add Web as a Flutter app target for macOS desktop, follow this procedure. ## Configure Chrome as the web DevTools tools {% include docs/install/reqs/add-web.md devos='macOS' %} {% include docs/install/flutter-doctor.md target='Web' devos='macOS' config='macOSDesktopWeb' %}
website/src/platform-integration/web/install-web/install-web-from-macos-desktop.md/0
{ "file_path": "website/src/platform-integration/web/install-web/install-web-from-macos-desktop.md", "repo_id": "website", "token_count": 141 }
1,424
--- title: User surveys description: Why users see a survey announcement, how the data is used, and how to disable. --- ## Why do I see a survey announcement? If you have not opted-out of Flutter's [analytics and crash reporting](/reference/crash-reporting), you may receive a survey announcement in your IDE. We run two types of surveys: 1. **Each quarter.** We give all active Flutter and Dart users the option to take this survey. 2. **Ad-hoc.** We design and deploy experimental surveys when we want to learn more about specific topics. If your telemetry data meets the survey criteria, you might see a survey announcement. ## How will my responses be used? We use the responses you submit via survey to improve Flutter and Dart. We store this information independent of the information sent to Google via analytics. To see how we used prior surveys to improve Flutter and Dart, check out our blogs on [Medium][]. ## How can I disable it? To mute survey announcements, you might do one of the following: 1. Click the button on the message. 2. Opt-out of analytics and crash reporting per the steps given in [Disabling analytics reporting](/reference/crash-reporting#disabling-analytics-reporting). [Medium]: {{site.flutter-medium}}/search?q=survey
website/src/reference/user-surveys.md/0
{ "file_path": "website/src/reference/user-surveys.md", "repo_id": "website", "token_count": 340 }
1,425
--- title: Adding TextInputClient.currentAutofillScope property description: > A new getter TextInputClient.currentAutofillScope was added to the TextInputClient interface for autofill support. --- ## Summary A new getter, `TextInputClient.currentAutofillScope`, was added to the `TextInputClient` interface; all `TextInputClient` subclasses must provide a concrete implementation of `currentAutofillScope`. This getter allows the `TextInputClient` to trigger an autofill that involves multiple logically connected input fields. For example, a "username" field can trigger an autofill that fills both itself and the "password" field associated with it. ## Context On many platforms, autofill services are capable of autofilling multiple input fields in a single autofill attempt. For example, username fields and password fields can usually be autofilled in one go. For this reason, a Flutter input field that is about to trigger autofill should also provide the platform with information about other autofillable input fields logically connected to it. `TextInputClient.currentAutofillScope` defines the group of input fields that are logically connected to this `TextInputClient`, and can be autofilled together. ## Description of change `TextInputClient` now has an additional getter that returns the `AutofillScope` that this client belongs to. This getter is used by the input client to collect autofill related information from other autofillable input fields within the same scope. ```dart abstract class TextInputClient { AutofillScope get currentAutofillScope; } ``` If you see the error message "missing concrete implementation of 'getter TextInputClient.currentAutofillScope'" while compiling a Flutter app, follow the migration steps listed below. ## Migration guide If you're not planning to add multifield autofill support to your `TextInputClient` subclass, simply return `null` in the getter: ```dart class CustomTextField implements TextInputClient { // Not having an AutofillScope does not prevent the input field // from being autofilled. However, only this input field is // autofilled when autofill is triggered on it. AutofillScope get currentAutofillScope => null; } ``` If multifield autofill support is desirable, a common `AutofillScope` to use is the `AutofillGroup` widget. To get the closest `AutofillGroup` widget to the text input, use `AutofillGroup.of(context)`: ```dart class CustomTextFieldState extends State<CustomTextField> implements TextInputClient { AutofillScope get currentAutofillScope => AutofillGroup.of(context); } ``` For more information, check out [`AutofillGroup`][]. ## Timeline Landed in version: 1.18.0<br> In stable release: 1.20 ## References API documentation: * [`AutofillGroup`][] * [`TextInputClient.currentAutofillScope`][] Relevant issue: * [Issue 13015: Autofill support][] Relevant PR: * [Framework PR that added autofill support][] [Framework PR that added autofill support]: {{site.repo.flutter}}/pull/52126 [Issue 13015: Autofill support]: {{site.repo.flutter}}/issues/13015 [`AutofillGroup`]: {{site.api}}/flutter/widgets/AutofillGroup-class.html [`TextInputClient.currentAutofillScope`]: {{site.api}}/flutter/services/TextInputClient/currentAutofillScope.html
website/src/release/breaking-changes/add-currentAutofillScope-to-TextInputClient.md/0
{ "file_path": "website/src/release/breaking-changes/add-currentAutofillScope-to-TextInputClient.md", "repo_id": "website", "token_count": 920 }
1,426
--- title: CupertinoTabBar requires Localizations parent description: > In order to provide locale appropriate semantics, the CupertinoTabBar requires a Localizations parent. --- ## Summary Instances of `CupertinoTabBar` must have a `Localizations`parent in order to provide a localized `Semantics` hint. Trying to instantiate a `CupertinoTabBar` without localizations results in an assertion such as the following: ```nocode CupertinoTabBar requires a Localizations parent in order to provide an appropriate Semantics hint for tab indexing. A CupertinoApp provides the DefaultCupertinoLocalizations, or you can instantiate your own Localizations. 'package:flutter/src/cupertino/bottom_tab_bar.dart': Failed assertion: line 213 pos 7: 'localizations != null' ``` ## Context To support localized semantics information, the `CupertinoTabBar` requires localizations. Before this change, the `Semantics` hint provided to the `CupertinoTabBar` was a hard-coded String, 'tab, $index of $total'. The content of the semantics hint was also updated from this original String to 'Tab $index of $total' in English. If your `CupertinoTabBar` is within the scope of a `CupertinoApp`, the `DefaultCupertinoLocalizations` is already instantiated and may suit your needs without having to make a change to your existing code. If your `CupertinoTabBar` is not within a `CupertinoApp`, you may provide the localizations of your choosing using the `Localizations` widget. ## Migration guide If you are seeing a `'localizations != null'` assertion error, make sure locale information is being provided to your `CupertinoTabBar`. Code before migration: ```dart import 'package:flutter/cupertino.dart'; void main() => runApp(Foo()); class Foo extends StatelessWidget { @override Widget build(BuildContext context) { return MediaQuery( data: const MediaQueryData(), child: CupertinoTabBar( items: const <BottomNavigationBarItem>[ BottomNavigationBarItem( icon: Icon(CupertinoIcons.add_circled), label: 'Tab 1', ), BottomNavigationBarItem( icon: Icon(CupertinoIcons.add_circled_solid), label: 'Tab 2', ), ], currentIndex: 1, ), ); } } ``` Code after migration (Providing localizations via the `CupertinoApp`): ```dart import 'package:flutter/cupertino.dart'; void main() => runApp(Foo()); class Foo extends StatelessWidget { @override Widget build(BuildContext context) { return CupertinoApp( home: CupertinoTabBar( items: const <BottomNavigationBarItem>[ BottomNavigationBarItem( icon: Icon(CupertinoIcons.add_circled), label: 'Tab 1', ), BottomNavigationBarItem( icon: Icon(CupertinoIcons.add_circled_solid), label: 'Tab 2', ), ], currentIndex: 1, ), ); } } ``` Code after migration (Providing localizations by using the `Localizations` widget): ```dart import 'package:flutter/cupertino.dart'; void main() => runApp(Foo()); class Foo extends StatelessWidget { @override Widget build(BuildContext context) { return Localizations( locale: const Locale('en', 'US'), delegates: <LocalizationsDelegate<dynamic>>[ DefaultWidgetsLocalizations.delegate, DefaultCupertinoLocalizations.delegate, ], child: MediaQuery( data: const MediaQueryData(), child: CupertinoTabBar( items: const <BottomNavigationBarItem>[ BottomNavigationBarItem( icon: Icon(CupertinoIcons.add_circled), label: 'Tab 1', ), BottomNavigationBarItem( icon: Icon(CupertinoIcons.add_circled_solid), label: 'Tab 2', ), ], currentIndex: 1, ), ), ); } } ``` ## Timeline Landed in version: 1.18.0-9.0.pre<br> In stable release: 1.20.0 ## References API documentation: * [`CupertinoTabBar`][] * [`Localizations`][] * [`DefaultCupertinoLocalizations`][] * [`Semantics`][] * [`CupertinoApp`][] * [Internationalizing Flutter Apps][] Relevant PR: * [PR 55336: Adding tabSemanticsLabel to CupertinoLocalizations][] * [PR 56582: Update Tab semantics in Cupertino to be the same as Material][] [`CupertinoTabBar`]: {{site.api}}/flutter/cupertino/CupertinoTabBar-class.html [`Localizations`]: {{site.api}}/flutter/widgets/Localizations-class.html [`DefaultCupertinoLocalizations`]: {{site.api}}/flutter/cupertino/DefaultCupertinoLocalizations-class.html [`Semantics`]: {{site.api}}/flutter/widgets/Semantics-class.html [`CupertinoApp`]: {{site.api}}/flutter/cupertino/CupertinoApp-class.html [Internationalizing Flutter Apps]: /ui/accessibility-and-internationalization/internationalization [PR 55336: Adding tabSemanticsLabel to CupertinoLocalizations]: {{site.repo.flutter}}/pull/55336 [PR 56582: Update Tab semantics in Cupertino to be the same as Material]: {{site.repo.flutter}}/pull/56582#issuecomment-625497951
website/src/release/breaking-changes/cupertino-tab-bar-localizations.md/0
{ "file_path": "website/src/release/breaking-changes/cupertino-tab-bar-localizations.md", "repo_id": "website", "token_count": 1900 }
1,427
--- title: The forgetChild() method must call super description: > Any element subclasses that override forgetChild are required to call super. --- ## Summary A recent global key duplication detection refactor now requires `Element` subclasses that override the `forgetChild()` to call `super()`. ## Context When encountering a global key duplication that will be cleaned up by an element rebuild later, we must not report global key duplication. Our previous implementation threw an error as soon as duplication was detected, and didn't wait for the rebuild if the element with the duplicated global key would have rebuilt. The new implementation keeps track of all global key duplications during a build cycle, and only verifies global key duplication at the end of the that cycle instead of throwing an error immediately. As part of the refactoring, we implemented a mechanism to remove previous global key duplication in `forgetChild` if the rebuild had happened. This, however, requires all `Element` subclasses that override `forgetChild` to call the `super` method. ## Description of change The `forgetChild` of abstract class `Element` has a base implementation to remove global key reservation, and it is enforced by the `@mustCallSuper` meta tag. All subclasses that override the method have to call `super`; otherwise, the analyzer shows a linting error and global key duplication detection might throw an unexpected error. ## Migration guide In the following example, an app's `Element` subclass overrides the `forgetChild` method. Code before migration: ```dart class CustomElement extends Element { @override void forgetChild(Element child) { ... } } ``` Code after migration: ```dart class CustomElement extends Element { @override void forgetChild(Element child) { ... super.forgetChild(child); } } ``` ## Timeline Landed in version: 1.16.3<br> In stable release: 1.17 ## References API documentation: * [`Element`][] * [`forgetChild()`][] Relevant issues: * [Issue 43780][] Relevant PRs: * [PR 43790: Fix global key error][] [`Element`]: {{site.api}}/flutter/widgets/Element-class.html [`forgetChild()`]: {{site.api}}/flutter/widgets/Element/forgetChild.html [Issue 43780]: {{site.repo.flutter}}/issues/43780 [PR 43790: Fix global key error]: {{site.repo.flutter}}/pull/46183
website/src/release/breaking-changes/forgetchild-call-super.md/0
{ "file_path": "website/src/release/breaking-changes/forgetchild-call-super.md", "repo_id": "website", "token_count": 694 }
1,428
--- title: Material Chip button semantics description: Interactive Material Chips are now semantically marked as buttons. --- ## Summary Flutter now applies the semantic label of `button` to all interactive [Material Chips][] for accessibility purposes. ## Context Interactive Material Chips (namely [`ActionChip`][], [`ChoiceChip`][], [`FilterChip`][], and [`InputChip`][]) are now semantically marked as being buttons. However, the non-interactive information [`Chip`][] is not. Marking Chips as buttons helps accessibility tools, search engines, and other semantic analysis software understand the meaning of an app. For example, it allows screen readers (such as TalkBack on Android and VoiceOver on iOS) to announce a tappable Chip as a "button", which can assist users in navigating your app. Prior to this change, users of accessibility tools may have had a subpar experience, unless you implemented a workaround by manually adding the missing semantics to the Chip widgets in your app. ## Description of change The outermost [`Semantics`][] widget that wraps all Chip classes to describe their semantic properties is modified. The following changes apply to [`ActionChip`][], [`ChoiceChip`][], [`FilterChip`][], and [`InputChip`][]: * The [`button`][`SemanticsProperties.button`] property is set to `true`. * The [`enabled`][`SemanticsProperties.enabled`] property reflects whether the Chip is _currently_ tappable (by having a callback set). These property changes bring interactive Chips' semantic behavior in-line with that of other [Material Buttons][]. For the non-interactive information [`Chip`][]: * The [`button`][`SemanticsProperties.button`] property is set to `false`. * The [`enabled`][`SemanticsProperties.enabled`] property is set to `null`. ## Migration guide **You might not need to perform any migration.** This change only affects you if you worked around the issue of Material Chips missing `button` semantics by wrapping the widget given to the `label` field of a `Chip` with a `Semantics` widget marked as `button: true`. **In this case, the inner and outer `button` semantics conflict, resulting in the tappable area of the button shrinking down to the size of the label after this change is introduced.** Fix this issue either by deleting that `Semantics` widget and replacing it with its child, or by removing the `button: true` property if other semantic properties still need to be applied to the `label` widget of the Chip. The following snippets use [`InputChip`][] as an example, but the same process applies to [`ActionChip`][], [`ChoiceChip`][], and [`FilterChip`][] as well. **Case 1: Remove the `Semantics` widget.** Code before migration: ```dart Widget myInputChip = InputChip( onPressed: () {}, label: Semantics( button: true, child: Text('My Input Chip'), ), ); ``` Code after migration: ```dart Widget myInputChip = InputChip( onPressed: () {}, label: Text('My Input Chip'), ); ``` **Case 2: Remove `button:true` from the `Semantics` widget.** Code before migration: ```dart Widget myInputChip = InputChip( onPressed: () {}, label: Semantics( button: true, hint: 'Example Hint', child: Text('My Input Chip'), ), ); ``` Code after migration: ```dart Widget myInputChip = InputChip( onPressed: () {}, label: Semantics( hint: 'Example Hint', child: Text('My Input Chip'), ), ); ``` ## Timeline Landed in version: 1.23.0-7.0.pre<br> In stable release: 2.0.0 ## References API documentation: * [`ActionChip`][] * [`Chip`][] * [`ChoiceChip`][] * [`FilterChip`][] * [`InputChip`][] * [Material Buttons][] * [Material Chips][] * [`Semantics`][] * [`SemanticsProperties.button`][] * [`SemanticsProperties.enabled`][] Relevant issue: * [Issue 58010][]: InputChip doesn't announce any action for a11y on iOS Relevant PRs: * [PR 60141][]: Tweaking Material Chip a11y semantics to match buttons * [PR 60645][]: Revert "Tweaking Material Chip a11y semantics to match buttons (#60141) * [PR 61048][]: Re-land "Tweaking Material Chip a11y semantics to match buttons (#60141) [`ActionChip`]: {{site.api}}/flutter/material/ActionChip-class.html [`Chip`]: {{site.api}}/flutter/material/Chip-class.html [`ChoiceChip`]: {{site.api}}/flutter/material/ChoiceChip-class.html [`FilterChip`]: {{site.api}}/flutter/material/FilterChip-class.html [`InputChip`]: {{site.api}}/flutter/material/InputChip-class.html [Material Buttons]: {{site.material}}/components/all-buttons [Material Chips]: {{site.material}}/components/chips [`Semantics`]: {{site.api}}/flutter/widgets/Semantics-class.html [`SemanticsProperties.button`]: {{site.api}}/flutter/semantics/SemanticsProperties/button.html [`SemanticsProperties.enabled`]: {{site.api}}/flutter/semantics/SemanticsProperties/enabled.html [Issue 58010]: {{site.repo.flutter}}/issues/58010 [PR 60141]: {{site.repo.flutter}}/pull/60141 [PR 60645]: {{site.repo.flutter}}/pull/60645 [PR 61048]: {{site.repo.flutter}}/pull/61048
website/src/release/breaking-changes/material-chip-button-semantics.md/0
{ "file_path": "website/src/release/breaking-changes/material-chip-button-semantics.md", "repo_id": "website", "token_count": 1558 }
1,429
--- title: Using HTML slots to render platform views in the web description: > iframes in Flutter web used to reload, because of the way some DOM operations were made. A change in the way Flutter web apps render platform views makes them stable (preventing iframe reloads, and other problems with video tags or forms potentially losing their state). --- ## Summary Flutter now renders all web platform views in a consistent location of the DOM, as direct children of `flt-glass-pane` (regardless of the rendering backend: `html` or `canvaskit`). Platform views are then _"slotted"_ into the correct position of the App's DOM with standard HTML features. Up until this change, Flutter web would change the styling of the rendered contents of a platform views to position/size it to the available space. **This is no longer the case.** Users can now decide how they want to utilize the space allocated to their platform view by the framework. ## Context The Flutter framework frequently tweaks its render tree to optimize the paint operations that are ultimately made per frame. In the web, these render tree changes often result in DOM operations. Flutter web used to render its platform views ([`HtmlElementView` widgets][]) directly into its corresponding position of the DOM. Using certain DOM elements as the "target" of some DOM operations causes those elements to lose their internal state. In practice, this means that `iframe` tags are going to reload, `video` players might restart, or an editable form might lose its edits. Flutter now renders platform views using [slot elements][] inside of a single, app-wide [shadow root][]. Slot elements can be added/removed/moved around the Shadow DOM without affecting the underlying slotted content (which is rendered in a constant location) This change was made to: * Stabilize the behavior of platform views in Flutter web. * Unify how platform views are rendered in the web for both rendering backends (`html` and `canvaskit`). * Provide a predictable location in the DOM that allows developers to reliably use CSS to style their platform views, and to use other standard DOM API, such as `querySelector`, and `getElementById`. ## Description of change A Flutter web app is now rendered inside a common [shadow root][] in which [slot elements][] represent platform views. The actual content of each platform view is rendered as a **sibling of said shadow root**. ### Before ```html ... <flt-glass-pane> ... <div id="platform-view">Contents</div> <!-- canvaskit --> <!-- OR --> <flt-platform-view> #shadow-root | <div id="platform-view">Contents</div> <!-- html --> </flt-platform-view> ... </flt-glass-pane> ... ``` ### After ```html ... <flt-glass-pane> #shadow-root | ... | <flt-platform-view-slot> | <slot name="platform-view-1" /> | </flt-platform-view-slot> | ... <flt-platform-view slot="platform-view-1"> <div id="platform-view">Contents</div> </flt-platform-view> ... </flt-glass-pane> ... ``` After this change, when the framework needs to move DOM nodes around, it operates over `flt-platform-view-slot`s, which only contain a `slot` element. The slot _projects_ the contents defined in `flt-platform-view` elements outside the shadow root. `flt-platform-view` elements are never the target of DOM operations from the framework, thus preventing the reload issues. From an app's perspective, this change is transparent. **However**, this is considered a _breaking change_ because some tests make assumptions about the internal DOM of a Flutter web app, and break. ## Migration guide ### Code The engine may print a warning message to the console similar to: ```bash Height of Platform View type: [$viewType] may not be set. Defaulting to `height: 100%`. Set `style.height` to any appropriate value to stop this message. ``` or: ```bash Width of Platform View type: [$viewType] may not be set. Defaulting to `width: 100%`. Set `style.width` to any appropriate value to stop this message. ``` Previously, the content returned by [`PlatformViewFactory` functions][] was resized and positioned by the framework. Instead, Flutter now sizes and positions `<flt-platform-view-slot>`, which is the parent of the slot where the content is projected. To stop the warning above, platform views need to set the `style.width` and `style.height` of their root element to any appropriate (non-null) value. For example, to make the root `html.Element` fill all the available space allocated by the framework, set its `style.width` and `style.height` properties to `'100%'`: ```dart ui.platformViewRegistry.registerViewFactory(viewType, (int viewId) { final html.Element htmlElement = html.DivElement() // ..other props ..style.width = '100%' ..style.height = '100%'; // ... return htmlElement; }); ``` If other techniques are used to lay out the platform view (like `inset: 0`) a value of `auto` for `width` and `height` is enough to stop the warning. Read more about [`CSS width`][] and [`CSS height`][]. ### Tests After this change, user's test code does **not** need to deeply inspect the contents of the shadow root of the App. All of the platform view contents will be placed as direct children of `flt-glass-pane`, wrapped in a `flt-platform-view` element. Avoid looking inside the `flt-glass-pane` shadow root, it is considered a **"private implementation detail"**, and its markup can change at any time, without notice. (See Relevant PRs below for examples of the "migrations" described above). ## Timeline Landed in version: 2.3.0-16.0.pre<br> In stable release: 2.5 ## References Design document: * [Using slot to embed web Platform Views][design doc] Relevant issues: * [Issue #80524][issue-80524] Relevant PRs: * [flutter/engine#25747][pull-25747]: Introduces the feature. * [flutter/flutter#82926][pull-82926]: Tweaks `flutter` tests. * [flutter/plugins#3964][pull-3964]: Tweaks to `plugins` code. * [flutter/packages#364][pull-364]: Tweaks to `packages` code. [`CSS height`]: https://developer.mozilla.org/en-US/docs/Web/CSS/height [`CSS width`]: https://developer.mozilla.org/en-US/docs/Web/CSS/width [`HtmlElementView` widgets]: {{site.api}}/flutter/widgets/HtmlElementView-class.html [`PlatformViewFactory` functions]: {{site.repo.engine}}/blob/58459a5e342f84c755919f2ad5029b22bcddd548/lib/web_ui/lib/src/engine/platform_views/content_manager.dart#L15-L18 [design doc]: /go/web-slot-content [issue-80524]: {{site.repo.flutter}}/issues/80524 [pull-25747]: {{site.repo.engine}}/pull/25747 [pull-364]: {{site.repo.packages}}/pull/364 [pull-3964]: {{site.github}}/flutter/plugins/pull/3964 [pull-82926]: {{site.repo.flutter}}/pull/82926 [shadow root]: https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot [slot elements]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/slot
website/src/release/breaking-changes/platform-views-using-html-slots-web.md/0
{ "file_path": "website/src/release/breaking-changes/platform-views-using-html-slots-web.md", "repo_id": "website", "token_count": 2074 }
1,430
--- title: Deprecated Splash Screen API Migration description: How to migrate from Manifest/Activity defined splash screen. --- Prior to Flutter 2.5, Flutter apps could add a splash screen by defining it within the metadata of their application manifest file (`AndroidManifest.xml`), by implementing [`provideSplashScreen`][] within their [`FlutterActivity`][], or both. This would display momentarily in between the time after the Android launch screen is shown and when Flutter has drawn the first frame. This approach is now deprecated as of Flutter 2.5. Flutter now automatically keeps the Android launch screen displayed until it draws the first frame. To migrate from defining a custom splash screen to just defining a custom launch screen for your application, follow the steps that correspond to how your application's custom splash screen was defined prior to the 2.5 release. **Custom splash screen defined in [`FlutterActivity`][]** 1. Locate your application's implementation of `provideSplashScreen()` within its `FlutterActivity` and **delete it**. This implementation should involve the construction of your application's custom splash screen as a `Drawable`. For example: ```java @Override public SplashScreen provideSplashScreen() { // ... return new DrawableSplashScreen( new SomeDrawable( ContextCompat.getDrawable(this, R.some_splash_screen))); } ``` 2. Use the steps in the section directly following to ensure that your `Drawable` splash screen (`R.some_splash_screen` in the previous example) is properly configured as your application's custom launch screen. **Custom splash screen defined in Manifest** 1. Locate your application's `AndroidManifest.xml` file. Within this file, find the `activity` element. Within this element, identify the `android:theme` attribute and the `meta-data` element that defines a splash screen as an `io.flutter.embedding.android.SplashScreenDrawable`, and update it. For example: ```xml <activity // ... android:theme="@style/SomeTheme"> // ... <meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable" android:resource="@drawable/some_splash_screen" /> </activity> ``` 2. If the `android:theme` attribute isn't specified, add the attribute and [define a launch theme][] for your application's launch screen. 3. Delete the `meta-data` element, as Flutter no longer uses that, but it can cause a crash. 4. Locate the definition of the theme specified by the `android:theme` attribute within your application's `style` resources. This theme specifies the launch theme of your application. Ensure that the `style` attribute configures the `android:windowBackground` attribute with your custom splash screen. For example: ```xml <resources> <style name="SomeTheme" // ... > <!-- Show a splash screen on the activity. Automatically removed when Flutter draws its first frame --> <item name="android:windowBackground">@drawable/some_splash_screen</item> </style> </resources> ``` [`provideSplashScreen`]: {{site.api}}/javadoc/io/flutter/embedding/android/SplashScreenProvider.html#provideSplashScreen-- [`FlutterActivity`]: {{site.api}}/javadoc/io/flutter/embedding/android/FlutterActivity.html [define a launch theme]: /platform-integration/android/splash-screen
website/src/release/breaking-changes/splash-screen-migration.md/0
{ "file_path": "website/src/release/breaking-changes/splash-screen-migration.md", "repo_id": "website", "token_count": 1080 }
1,431
--- title: The window singleton is deprecated description: > In preparation for supporting multiple views and multiple windows the window singleton has been deprecated. --- ## Summary In preparation for supporting multiple views and multiple windows, the `window` singleton has been deprecated. Code previously relying on the `window` singleton needs to look up the specific view it wants to operate on via the `View.of` API or interact with the `PlatformDispatcher` directly. ## Context Originally, Flutter assumed that an application would only consist of a single view (the `window`) into which content can be drawn. In a multi-view world, this assumption no longer makes sense and the APIs encoding this assumption have been deprecated. Instead, applications and libraries that relied on these APIs must choose a specific view they want to operate on and migrate to new multi-view compatible APIs as outlined in this migration guide. ## Description of change The APIs that have been deprecated as part of this change are: * The global `window` property exposed by `dart:ui`. * The `window` property on the `BaseBinding` class, which is usually accessed via * `GestureBinding.instance.window`, * `SchedulerBinding.instance.window`, * `ServicesBinding.instance.window`, * `PaintingBinding.instance.window`, * `SemanticsBinding.instance.window`, * `RendererBinding.instance.window`, * `WidgetsBinding.instance.window`, or * `WidgetTester.binding.window`. * The `SingletonFlutterView` class from `dart:ui`. * `TestWindow` from `flutter_test`, its constructors, and all of its properties and methods. The following options exist to migrate application and library code that relies on these deprecated APIs: If a `BuildContext` is available, consider looking up the current `FlutterView` via `View.of`. This returns the `FlutterView` into which the widgets built by the `build` method associated with the given context will be drawn. The `FlutterView` provides access to the same functionality that was previously available on the deprecated `SingletonFlutterView` class returned by the deprecated `window` properties mentioned above. However, some of the platform-specific functionality has moved to the `PlatformDispatcher`, which can be accessed from the `FlutterView` returned by `View.of` via `FlutterView.platformDispatcher`. Using `View.of` is the preferred way of migrating away from the deprecated properties mentioned above. If no `BuildContext` is available to look up a `FlutterView`, the `PlatformDispatcher` can be consulted directly to access platform-specific functionality. It also maintains a list of all available `FlutterView`s in `PlatformDispatcher.views` to access view-specific functionality. If possible, the `PlatformDispatcher` should be accessed via a binding (for example `WidgetsBinding.instance.platformDispatcher`) instead of using the static `PlatformDispatcher.instance` property. This ensures that the functionality of the `PlatformDispatcher` can be properly mocked out in tests. ### Testing For tests that accessed the `WidgetTester.binding.window` property to change window properties for testing, the following migrations are available: In tests written with `testWidgets`, two new properties have been added that together replace the functionality of `TestWindow`. * `WidgetTester.view` will provide a `TestFlutterView` that can be modified similarly to `WidgetTester.binding.window`, but with only view-specific properties such as the size of a view, its display pixel ratio, etc. * `WidgetTester.viewOf` is available for certain multi-view use cases, but should not be required for any migrations from `WidgetTester.binding.window`. * `WidgetTester.platformDispatcher` will provide access to a `TestPlatformDispatcher` that can be used to modify platform specific properties such as the platform's locale, whether certain system features are available, etc. ## Migration guide Instead of accessing the static `window` property, application and library code that has access to a `BuildContext` should use `View.of` to look up the `FlutterView` the context is associated with. Some properties have moved to the `PlatformDispatcher` accessible from the view via the `platformDispatcher` getter. Code before migration: ```dart Widget build(BuildContext context) { final double dpr = WidgetsBinding.instance.window.devicePixelRatio; final Locale locale = WidgetsBinding.instance.window.locale; return Text('The device pixel ratio is $dpr and the locale is $locale.'); } ``` Code after migration: ```dart Widget build(BuildContext context) { final double dpr = View.of(context).devicePixelRatio; final Locale locale = View.of(context).platformDispatcher.locale; return Text('The device pixel ratio is $dpr and the locale is $locale.'); } ``` If no `BuildContext` is available, the `PlatformDispatcher` exposed by the bindings can be consulted directly. Code before migration: ```dart double getTextScaleFactor() { return WidgetsBinding.instance.window.textScaleFactor; } ``` Code after migration: ```dart double getTextScaleFactor() { // View.of(context).platformDispatcher.textScaleFactor if a BuildContext is available, otherwise: return WidgetsBinding.instance.platformDispatcher.textScaleFactor; } ``` ### Testing In tests written with `testWidget`, the new `view` and `platformDispatcher` accessors should be used instead. #### Setting view-specific properties `TestFlutterView` has also made an effort to make the test API clearer and more concise by using setters with the same name as their related getter instead of setters with the `TestValue` suffix. Code before migration: ```dart testWidget('test name', (WidgetTester tester) async { tester.binding.window.devicePixelRatioTestValue = 2.0; tester.binding.window.displayFeaturesTestValue = <DisplayFeatures>[]; tester.binding.window.gestureSettingsTestValue = const GestureSettings(physicalTouchSlop: 100); tester.binding.window.paddingTestValue = FakeViewPadding.zero; tester.binding.window.physicalGeometryTestValue = const Rect.fromLTRB(0,0, 500, 800); tester.binding.window.physicalSizeTestValue = const Size(300, 400); tester.binding.window.systemGestureInsetsTestValue = FakeViewPadding.zero; tester.binding.window.viewInsetsTestValue = FakeViewPadding.zero; tester.binding.window.viewPaddingTestValue = FakeViewPadding.zero; }); ``` Code after migration ```dart testWidget('test name', (WidgetTester tester) async { tester.view.devicePixelRatio = 2.0; tester.view.displayFeatures = <DisplayFeatures>[]; tester.view.gestureSettings = const GestureSettings(physicalTouchSlop: 100); tester.view.padding = FakeViewPadding.zero; tester.view.physicalGeometry = const Rect.fromLTRB(0,0, 500, 800); tester.view.physicalSize = const Size(300, 400); tester.view.systemGestureInsets = FakeViewPadding.zero; tester.view.viewInsets = FakeViewPadding.zero; tester.view.viewPadding = FakeViewPadding.zero; }); ``` #### Resetting view-specific properties `TestFlutterView` retains the capability to reset individual properties or the entire view but, in order to be more clear and consist, the naming of these methods has changed from `clear<property>TestValue` and `clearAllTestValues` to `reset<property>` and `reset` respectively. ##### Resetting individual properties Code before migration: ```dart testWidget('test name', (WidgetTester tester) async { addTearDown(tester.binding.window.clearDevicePixelRatioTestValue); addTearDown(tester.binding.window.clearDisplayFeaturesTestValue); addTearDown(tester.binding.window.clearGestureSettingsTestValue); addTearDown(tester.binding.window.clearPaddingTestValue); addTearDown(tester.binding.window.clearPhysicalGeometryTestValue); addTearDown(tester.binding.window.clearPhysicalSizeTestValue); addTearDown(tester.binding.window.clearSystemGestureInsetsTestValue); addTearDown(tester.binding.window.clearViewInsetsTestValue); addTearDown(tester.binding.window.clearViewPaddingTestValue); }); ``` Code after migration ```dart testWidget('test name', (WidgetTester tester) async { addTearDown(tester.view.resetDevicePixelRatio); addTearDown(tester.view.resetDisplayFeatures); addTearDown(tester.view.resetGestureSettings); addTearDown(tester.view.resetPadding); addTearDown(tester.view.resetPhysicalGeometry); addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetSystemGestureInsets); addTearDown(tester.view.resetViewInsets); addTearDown(tester.view.resetViewPadding); }); ``` ##### Resetting all properties at once Code before migration: ```dart testWidget('test name', (WidgetTester tester) async { addTearDown(tester.binding.window.clearAllTestValues); }); ``` Code after migration ```dart testWidget('test name', (WidgetTester tester) async { addTearDown(tester.view.reset); }); ``` #### Setting platform-specific properties `TestPlatformDispatcher` retains the same functionality and naming scheme for test setters as did `TestWindow`, so migration of platform-specific properties mainly consists of calling the same setters on the new `WidgetTester.platformDispatcher` accessor. Code before migration: ```dart testWidgets('test name', (WidgetTester tester) async { tester.binding.window.accessibilityFeaturesTestValue = FakeAccessibilityFeatures.allOn; tester.binding.window.alwaysUse24HourFormatTestValue = false; tester.binding.window.brieflyShowPasswordTestValue = true; tester.binding.window.defaultRouteNameTestValue = '/test'; tester.binding.window.initialLifecycleStateTestValue = 'painting'; tester.binding.window.localesTestValue = <Locale>[const Locale('en-us'), const Locale('ar-jo')]; tester.binding.window.localeTestValue = const Locale('ar-jo'); tester.binding.window.nativeSpellCheckServiceDefinedTestValue = false; tester.binding.window.platformBrightnessTestValue = Brightness.dark; tester.binding.window.semanticsEnabledTestValue = true; tester.binding.window.textScaleFactorTestValue = 2.0; }); ``` Code after migration: ```dart testWidgets('test name', (WidgetTester tester) async { tester.platformDispatcher.accessibilityFeaturesTestValue = FakeAccessibilityFeatures.allOn; tester.platformDispatcher.alwaysUse24HourFormatTestValue = false; tester.platformDispatcher.brieflyShowPasswordTestValue = true; tester.platformDispatcher.defaultRouteNameTestValue = '/test'; tester.platformDispatcher.initialLifecycleStateTestValue = 'painting'; tester.platformDispatcher.localesTestValue = <Locale>[const Locale('en-us'), const Locale('ar-jo')]; tester.platformDispatcher.localeTestValue = const Locale('ar-jo'); tester.platformDispatcher.nativeSpellCheckServiceDefinedTestValue = false; tester.platformDispatcher.platformBrightnessTestValue = Brightness.dark; tester.platformDispatcher.semanticsEnabledTestValue = true; tester.platformDispatcher.textScaleFactorTestValue = 2.0; }); ``` #### Resetting platform-specific properties Similarly to setting properties, resetting platform-specific properties consists mainly of changing from the `binding.window` accessor to the `platformDispatcher` accessor. ##### Resetting individual properties Code before migration: ```dart testWidgets('test name', (WidgetTester tester) async { addTeardown(tester.binding.window.clearAccessibilityFeaturesTestValue); addTeardown(tester.binding.window.clearAlwaysUse24HourFormatTestValue); addTeardown(tester.binding.window.clearBrieflyShowPasswordTestValue); addTeardown(tester.binding.window.clearDefaultRouteNameTestValue); addTeardown(tester.binding.window.clearInitialLifecycleStateTestValue); addTeardown(tester.binding.window.clearLocalesTestValue); addTeardown(tester.binding.window.clearLocaleTestValue); addTeardown(tester.binding.window.clearNativeSpellCheckServiceDefinedTestValue); addTeardown(tester.binding.window.clearPlatformBrightnessTestValue); addTeardown(tester.binding.window.clearSemanticsEnabledTestValue); addTeardown(tester.binding.window.clearTextScaleFactorTestValue); }); ``` Code after migration: ```dart testWidgets('test name', (WidgetTester tester) async { addTeardown(tester.platformDispatcher.clearAccessibilityFeaturesTestValue); addTeardown(tester.platformDispatcher.clearAlwaysUse24HourFormatTestValue); addTeardown(tester.platformDispatcher.clearBrieflyShowPasswordTestValue); addTeardown(tester.platformDispatcher.clearDefaultRouteNameTestValue); addTeardown(tester.platformDispatcher.clearInitialLifecycleStateTestValue); addTeardown(tester.platformDispatcher.clearLocalesTestValue); addTeardown(tester.platformDispatcher.clearLocaleTestValue); addTeardown(tester.platformDispatcher.clearNativeSpellCheckServiceDefinedTestValue); addTeardown(tester.platformDispatcher.clearPlatformBrightnessTestValue); addTeardown(tester.platformDispatcher.clearSemanticsEnabledTestValue); addTeardown(tester.platformDispatcher.clearTextScaleFactorTestValue); }); ``` ##### Resetting all properties at once Code before migration: ```dart testWidgets('test name', (WidgetTester tester) async { addTeardown(tester.binding.window.clearAllTestValues); }); ``` Code after migration: ```dart testWidgets('test name', (WidgetTester tester) async { addTeardown(tester.platformDispatcher.clearAllTestValues); }); ``` ## Timeline Landed in version: 3.9.0-13.0.pre.20<br> In stable release: 3.10.0 ## References API documentation: * [`View.of`][] * [`FlutterView`][] * [`PlatformDispatcher`][] * [`TestPlatformDispatcher`][] * [`TestFlutterView`][] * [`TestWidgetsFlutterBinding.window`][] Relevant issues: * [Issue 116929][] * [Issue 117481][] * [Issue 121915][] Relevant PRs: * [Deprecate SingletonFlutterWindow and global window singleton][] * [Deprecate BindingBase.window][] * [Deprecates `TestWindow`][] [`View.of`]: {{site.api}}/flutter/widgets/View/of.html [`FlutterView`]: {{site.api}}/flutter/dart-ui/FlutterView-class.html [`PlatformDispatcher`]: {{site.api}}/flutter/dart-ui/PlatformDispatcher-class.html [`TestPlatformDispatcher`]: {{site.api}}/flutter/flutter_test/TestPlatformDispatcher-class.html [`TestFlutterView`]: {{site.api}}/flutter/flutter_test/TestFlutterView-class.html [`TestWidgetsFlutterBinding.window`]: {{site.api}}/flutter/flutter_test/TestWidgetsFlutterBinding/window.html [Issue 116929]: {{site.repo.flutter}}/issues/116929 [Issue 117481]: {{site.repo.flutter}}/issues/117481 [Issue 121915]: {{site.repo.flutter}}/issues/121915 [Deprecate SingletonFlutterWindow and global window singleton]: {{site.repo.engine}}/pull/39302 [Deprecate BindingBase.window]: {{site.repo.flutter}}/pull/120998 [Deprecates `TestWindow`]: {{site.repo.flutter}}/pull/122824
website/src/release/breaking-changes/window-singleton.md/0
{ "file_path": "website/src/release/breaking-changes/window-singleton.md", "repo_id": "website", "token_count": 4416 }
1,432
--- title: Flutter 1.12.13 release notes short-title: 1.12.13 release notes description: Release notes for Flutter 1.12.13. --- Welcome to Flutter 1.12, our biggest stable release so far! In this release, we've merged 1,905 Pull Requests from 188 contributors, including both Googlers and non-Google contributors! Please see the chart below for the number of PRs in each release. Over the past year, the number of PRs has been growing in each release (except for Flutter 1.9, which was an out-of-band release to support Catalina). In the recent [GitHub Octoverse report][], Flutter is listed as one of the top 3 active repos on GitHub! As the holiday season is upon us, we would like to express our sincerest appreciation to our amazing developer community who believe in Flutter, advocate for Flutter, and contribute to Flutter. It's been an incredible year for us all! We look forward to working with you in the years to come. As always, you can find interesting PRs listed below. And there are lots of interesting things to mention in this release, including: * Some breaking API changes * Some severe issues caught and fixed * Web support is now available in the beta channel * MacOS support is enabled in the dev channel as of 1.13 * Improved SDK to add Flutter to existing Android/iOS apps * iOS 13 visual refresh including the support for iOS Dark mode * Enhanced tooling experiences * New widgets and features * And more! ## Breaking changes In general, we want to avoid introducing breaking changes to Flutter, our plugins, or our packages. However, sometimes it is inevitable when we need to make our APIs more intuitive. We have implemented a new process that invites you to submit tests to help us detect breaking changes. For more information, see [this post from Ian Hickson][] on [flutter-announce][] and the [breaking change policy on the Flutter wiki][]. The following list includes breaking changes in this release. Please see the related announcements so that you can move forward with your code. [37024]({{site.repo.flutter}}/pull/37024) [Implement PageView using SliverLayoutBuilder, Deprecate RenderSliverFillViewport](https://groups.google.com/g/flutter-announce/c/1CUo2GCjrD4/m/VGKsyVirFQAJ) [37739]({{site.repo.flutter}}/pull/37739) [Fix AnimationStatus for repeat(reverse: true) and animateWith](https://groups.google.com/g/flutter-announce/c/yYqqt4Z5IIo/m/3wRYBwSQEwAJ) [37896]({{site.repo.flutter}}/pull/37896) [Add opacity control to MouseRegion. Add findAnnotations to Layer.](https://groups.google.com/g/flutter-announce/c/GHSNLpjzmPw/m/ozNXwdbHDwAJ) [38481]({{site.repo.flutter}}/pull/38481) [Timer picker fidelity revision](https://groups.google.com/g/flutter-announce/c/cSwtxCpWWEU/m/LtZS9g6eAgAJ) [38568]({{site.repo.flutter}}/pull/38568) [Normalize assert checking of clipBehavior](https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!searchin/flutter-announce/clipBehavior%7Csort:date/flutter-announce/VJaYV9R9usU/_mV1GV25DwAJ) [39079]({{site.repo.flutter}}/pull/39079) [fix widget built twice during warm up frame](https://groups.google.com/g/flutter-announce/c/m6ewfoO64mI/m/ziD4VmwUBQAJ) [39440]({{site.repo.flutter}}/pull/39440) [Allow gaps in the initial route](https://groups.google.com/g/flutter-announce/c/ysFSO3eScbs/m/GzPFkLuvAQAJ) [39919]({{site.repo.flutter}}/pull/39919) [CupertinoDatePicker & CupertinoTimerPicker dark mode](https://groups.google.com/g/flutter-announce/c/0DAdg-k_jDw/m/DUGLDQagAAAJ) [40166]({{site.repo.flutter}}/pull/40166) [Added proper focus handling when pushing and popping routes](https://groups.google.com/g/flutter-announce/c/BjPKnOw5jzU/m/Ev-gUJ_VAwAJ) [40179]({{site.repo.flutter}}/pull/40179) [Update PopupMenu layout](https://groups.google.com/g/flutter-announce/c/UlK3y9HWyBg/m/Dybr660DAAAJ) [40566]({{site.repo.flutter}}/pull/40566) [Remove CupertinoSystemColors in favor of CupertinoColors](https://groups.google.com/g/flutter-announce/c/pMYPTvjWCX4/m/UiocKCk0AQAJ) [40690]({{site.repo.flutter}}/pull/40690) [CupertinoPageScaffold dark mode](https://groups.google.com/g/flutter-announce/c/r_2xpmKiLj4/m/-myr4ZRPAAAJ) [41220]({{site.repo.flutter}}/pull/41220) [Add an ActivateAction to controls that use InkWell.](https://groups.google.com/g/flutter-announce/c/oLsxPDDRc6s/m/oCtHP3ejAAAJ) [41857 Change the dark theme elevation overlay to use the colorScheme.onSurface]({{site.repo.flutter}}/pull/41857) [42449]({{site.repo.flutter}}/pull/42449) [Increase TextField's minimum height from 40 to 48](https://groups.google.com/g/flutter-announce/c/RDyeXZK0fO8/m/rdkBzgw4DgAJ) [42470]({{site.repo.flutter}}/pull/42470) [No multiline password fields](https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/flutter-announce/Ken8TY_QiuY/qxJF2ugyBQAJ) [42479]({{site.repo.flutter}}/pull/42479) [Make DropdownButton's disabledHint and hint behavior consistent](https://groups.google.com/g/flutter-announce/c/yHIl-zEXm5c/m/abpgrXuHDgAJ) [45135]({{site.repo.flutter}}/pull/45135) [Add option to delay rendering the first frame](https://groups.google.com/g/flutter-announce/c/kBf4cXjD2y4/m/lg19fDnaAgAJ) ## Severe crash & performance bugs In every stable release, we make an effort to improve the quality of Flutter. In 1.12, we fixed several severe issues; this includes the following crashes and performance issues. [40009]({{site.repo.flutter}}/pull/40009) Add null check to _IndicatorPainter._tabOffsetsEqual() to prevent crash [40263]({{site.repo.flutter}}/pull/40263) Fix crash on vswhere search from flutter doctor [40786]({{site.repo.flutter}}/pull/40786) Fix crash on vswhere query on missing installations [42342]({{site.repo.flutter}}/pull/42342) Fix DropdownButton crash when hint and selectedItemBuilder are simultaneously defined [44610]({{site.repo.flutter}}/pull/44610) Error Message for createState assertion [38814]({{site.repo.flutter}}/pull/38814) Add iOS backdrop filter benchmarks [38821]({{site.repo.flutter}}/pull/38821) Cache caret parameters [38861]({{site.repo.flutter}}/pull/38861) Replace deprecated onReportTimings w/ frameTimings [39439]({{site.repo.flutter}}/pull/39439) Measure iOS CPU/GPU percentage [43676]({{site.repo.flutter}}/pull/43676) Allow multiple TimingsCallbacks [45050]({{site.repo.flutter}}/pull/45050) Add a perf test for picture raster cache ## New features Flutter 1.12 introduces several new features including the [SliverOpacity]({{site.api}}/flutter/widgets/SliverOpacity-class.html) widget, the [SliverAnimatedList]({{site.api}}/flutter/widgets/SliverAnimatedList-class.html), and the ability to configure a stretch effect for a SliverAppBar. [37416]({{site.repo.flutter}}/pull/37416) Add MediaQuery.systemGestureInsets to support Android Q [39857]({{site.repo.flutter}}/pull/39857) Update ToggleButtons constraints default and add new constraints parameter [40161]({{site.repo.flutter}}/pull/40161) Add fullscreenDialog argument in PageRouteBuilder [40461]({{site.repo.flutter}}/pull/40461) Implement DropdownButton.selectedItemBuilder [41415]({{site.repo.flutter}}/pull/41415) Expose API for resizing image caches [42250]({{site.repo.flutter}}/pull/42250) SliverAppBar - Configurable overscroll stretch with callback feature & FlexibleSpaceBar support [42485]({{site.repo.flutter}}/pull/42485) Re-landing SliverAnimatedList. [42842]({{site.repo.flutter}}/pull/42842) Add "navigator" option to "showDialog" and "showGeneralDialog" [43286]({{site.repo.flutter}}/pull/43286) FadeInImage cacheWidth and cacheHeight support [44289]({{site.repo.flutter}}/pull/44289) SliverOpacity [45127]({{site.repo.flutter}}/pull/45127) SliverIgnorePointer [45432]({{site.repo.flutter}}/pull/45432) Use RenderSliverPadding to inset SliverFillViewport ## iOS support iOS continues to be a big investment area for Flutter. With this release, we've made a visual refresh to our Cupertino library to match the iOS 13 look. We now support dark mode in the Cupertino widgets, added two new widgets called [CupertinoContextMenu]({{site.api}}/flutter/cupertino/CupertinoContextMenu-class.html) and [CupertinoSlidingSegmentedControl]({{site.api}}/flutter/cupertino/CupertinoSlidingSegmentedControl-class.html), and made improvements to segmented control widgets, [CupertinoAlertDialog]({{site.api}}/flutter/cupertino/CupertinoAlertDialog-class.html), and [CupertinoDatePicker]({{site.api}}/flutter/cupertino/CupertinoDatePicker-class.html) [36871]({{site.repo.flutter}}/pull/36871) Audit use of defaultTargetPlatform [37719]({{site.repo.flutter}}/pull/37719) CupertinoDynamicColor and friends [38712]({{site.repo.flutter}}/pull/38712) Show process error when iOS install fails [39056]({{site.repo.flutter}}/pull/39056) Fixed issues with Background Color #34741 [39215]({{site.repo.flutter}}/pull/39215) CupertinoActionSheet dark mode & fidelity [39289]({{site.repo.flutter}}/pull/39289) CupertinoActivityIndicator & CupertinoApp dark mode [39430]({{site.repo.flutter}}/pull/39430) make CupertinoDynamicColor const constructible [39463]({{site.repo.flutter}}/pull/39463) Update validation to support Xcode11 version [39585]({{site.repo.flutter}}/pull/39585) remove fallback code for ios/usb artifacts [39590]({{site.repo.flutter}}/pull/39590) Fix user gesture in CupertinoPageRoute [39765]({{site.repo.flutter}}/pull/39765) CupertinoButton & Bottom tab bar dark mode [39927]({{site.repo.flutter}}/pull/39927) Make CupertinoDynamicColor.resolve return null when given a null color [40007]({{site.repo.flutter}}/pull/40007) CupertinoAlertDialog dark mode & CupertinoActionSheet fidelity [40100]({{site.repo.flutter}}/pull/40100) Fix a problem with disposing of focus nodes in tab scaffold [40189]({{site.repo.flutter}}/pull/40189) Dark mode CupertinoNavigationBar [40447]({{site.repo.flutter}}/pull/40447) Implement mdns for flutter run [40454]({{site.repo.flutter}}/pull/40454) Dark Mode R: Refresh Control [40466]({{site.repo.flutter}}/pull/40466) ModalRoutes ignore input when a (cupertino) pop transition is underway [40864]({{site.repo.flutter}}/pull/40864) Move iOS and Android gitignore rules into folders [41326]({{site.repo.flutter}}/pull/41326) Exception when selecting in TextField [41355]({{site.repo.flutter}}/pull/41355) fix bad indentations(mainly around collection literals) [41384]({{site.repo.flutter}}/pull/41384) [flutter_tools] Report iOS mDNS lookup failures to analytics [41431]({{site.repo.flutter}}/pull/41431) Cupertino { TabScafold, TextSelection, TextField } dark mode & minor fidelity update [41473]({{site.repo.flutter}}/pull/41473) Missing trailing commas [41482]({{site.repo.flutter}}/pull/41482) [flutter_tool] Add analytics events for ios-mdns fallback success/failure [41644]({{site.repo.flutter}}/pull/41644) indent formal parameters correctly [41799]({{site.repo.flutter}}/pull/41799) Improved ios 13 scrollbar fidelity [41828]({{site.repo.flutter}}/pull/41828) Set DEFINES_MODULE=YES in plugin templates [41892]({{site.repo.flutter}}/pull/41892) Fix CupertinoActivityIndicator radius [42025]({{site.repo.flutter}}/pull/42025) Localization refresh [42032]({{site.repo.flutter}}/pull/42032) Update CupertinoActivityIndicator colors and gradient [42533]({{site.repo.flutter}}/pull/42533) Disable arrow key focus navigation for text fields [42550]({{site.repo.flutter}}/pull/42550) Add enableSuggestions flag to TextField and TextFormField [42563]({{site.repo.flutter}}/pull/42563) Adding thumb color customization functionality to CupertinoSlider [42602]({{site.repo.flutter}}/pull/42602) Properly throw FlutterError when route builder returns null on CupertinoPageRoute [42775]({{site.repo.flutter}}/pull/42775) CupertinoSlidingSegmentedControl [42790]({{site.repo.flutter}}/pull/42790) This disables the up/down arrow focus navigation in text fields in a different way. [42924]({{site.repo.flutter}}/pull/42924) CupertinoDialogAction is missing super call [42964]({{site.repo.flutter}}/pull/42964) Use PRODUCT_BUNDLE_IDENTIFIER from buildSettings to find correct bundle id on iOS when using flavors [42967]({{site.repo.flutter}}/pull/42967) Pad CupertinoAlertDialog with MediaQuery viewInsets [43918]({{site.repo.flutter}}/pull/43918) CupertinoContextMenu (iOS 13) [43932]({{site.repo.flutter}}/pull/43932) Update CupertinoSlidingSegmentedControl control/feedback mechanism [44149]({{site.repo.flutter}}/pull/44149) Apply minimumDate & maximumDate constraints in CupertinoDatePicker date mode [44391]({{site.repo.flutter}}/pull/44391) Segmented control quick double tap fix [44551]({{site.repo.flutter}}/pull/44551) Remove new unused elements [44743]({{site.repo.flutter}}/pull/44743) Sort Localization generation output [44870]({{site.repo.flutter}}/pull/44870) Add -runFirstLaunch hint text [45124]({{site.repo.flutter}}/pull/45124) Analyze dartpad [11350]({{site.repo.engine}}/pull/11350) Firebase test for Platform Views on iOS [11390]({{site.repo.engine}}/pull/11390) preventDefault on touchend to show iOS keyboard [11413]({{site.repo.engine}}/pull/11413) Ios simulator unittests seem to not consider the full compilation unit [11530]({{site.repo.engine}}/pull/11530) Optionally strip bitcode when creating ios framework [11652]({{site.repo.engine}}/pull/11652) iOS platform view mutation XCUITests [11802]({{site.repo.engine}}/pull/11802) Adjust iOS frame start times to match the platform info [11807]({{site.repo.engine}}/pull/11807) Fix deleting Thai vowel bug on iOS [11817]({{site.repo.engine}}/pull/11817) Smooth out iOS irregular input events delivery [11886]({{site.repo.engine}}/pull/11886) remove extra redundant channels setup in iOS embedding engine [12078]({{site.repo.engine}}/pull/12078) Manage iOS contexts separately [12084]({{site.repo.engine}}/pull/12084) Guard availability of user notification related methods to iOS 10.0 [12192]({{site.repo.engine}}/pull/12192) Updating text field location in IOS as a pre-work for spellcheck [12295]({{site.repo.engine}}/pull/12295) Issue 13238: on iOS, force an orientation change when the current orientation is not allowed [12404]({{site.repo.engine}}/pull/12404) Support accessibility labels on iOS switches. [12990]({{site.repo.engine}}/pull/12990) Fix for a11y crash on iOS [13029]({{site.repo.engine}}/pull/13029) Minimal test harness for iOS [13051]({{site.repo.engine}}/pull/13051) Don't bump iOS deployment target for Metal builds. [13093]({{site.repo.engine}}/pull/13093) iOS Platform View: Fixed overrelease of the observer. [13170]({{site.repo.engine}}/pull/13170) Issue 13238: on iOS, force an orientation change when the current orientation is not allowed [13449]({{site.repo.engine}}/pull/13449) Fix iOS crash when multiple platform views are in the scene [13469]({{site.repo.engine}}/pull/13469) Fix stale platform view gr context on iOS [13651]({{site.repo.engine}}/pull/13651) Fixed the scroll direction for iOS horizontal accessibility scroll events. [13852]({{site.repo.engine}}/pull/13852) Do not default to downstream affinity on iOS insertText [13857]({{site.repo.engine}}/pull/13857) Guard against orphaned semantic objects from referencing dead accessibility bridge on iOS [1370]({{site.github}}/flutter/plugins/pull/1370) [camera] Pause/resume video recording for Android & iOS [1999]({{site.github}}/flutter/plugins/pull/1999) [Connectivity] add a method to request location on iOS (for iOS 13) [2052]({{site.github}}/flutter/plugins/pull/2052) [instrumentation_adapter] Add stub iOS implementation and example app [2068]({{site.github}}/flutter/plugins/pull/2068) [google_maps_flutter] Fix iOS MyLocationButton on iOS [2083]({{site.github}}/flutter/plugins/pull/2083) [image_picker] Fix a crash when picking video on iOS 13 and above. [2131]({{site.github}}/flutter/plugins/pull/2131) [share]fix iOS crash when setting the subject to null [2139]({{site.github}}/flutter/plugins/pull/2139) [google_maps_flutter] Add NonNull macro to reduce warnings in iOS [2191]({{site.github}}/flutter/plugins/pull/2191) [image_picker] Fix iOS build and analyzer warnings [2192]({{site.github}}/flutter/plugins/pull/2192) [in_app_purchase] Fix iOS build warning [2275]({{site.github}}/flutter/plugins/pull/2275) Update cirrus to create IOS simulator on 13.2 an xCode 11 [2281]({{site.github}}/flutter/plugins/pull/2281) [connectivity] Fix reachability stream for iOS ## Android In this release, we've merged a list of changes to support Android 10, including a new activity zoom transition. [37526]({{site.repo.flutter}}/pull/37526) catch errors during gradle update [39126]({{site.repo.flutter}}/pull/39126) Fid app bundle in Gradle 3.5 [39145]({{site.repo.flutter}}/pull/39145) Add missing files in the Gradle wrapper directory [39312]({{site.repo.flutter}}/pull/39312) let flutter build aar use a local engine [39457]({{site.repo.flutter}}/pull/39457) Log flags in build apk and appbundle [40640]({{site.repo.flutter}}/pull/40640) Exclude non Android plugins from Gradle build [41698]({{site.repo.flutter}}/pull/41698) Download android x64 release artifacts [41933]({{site.repo.flutter}}/pull/41933) upload x64 android host release [41935]({{site.repo.flutter}}/pull/41935) [Android 10] Activity zoom transition [41946]({{site.repo.flutter}}/pull/41946) Do not validate the Android SDK when building an appbundle [42378]({{site.repo.flutter}}/pull/42378) remove println from flutter.gradle [42401]({{site.repo.flutter}}/pull/42401) Add support for Android x86_64 ABI to Flutter [42508]({{site.repo.flutter}}/pull/42508) Add Android x64 profile artifacts [42966]({{site.repo.flutter}}/pull/42966) expand scope of rethrown gradle errors [43245]({{site.repo.flutter}}/pull/43245) Add smallestScreenSize to android:configChanges in the Android manifest template [43282]({{site.repo.flutter}}/pull/43282) implement build aot with assemble for Android target platforms [43876]({{site.repo.flutter}}/pull/43876) Refactor flutter.gradle to use assemble directly [44534]({{site.repo.flutter}}/pull/44534) Improve performance of build APK (~50%) by running gen_snapshot concurrently [45139]({{site.repo.flutter}}/pull/45139) Update Android CPU device detection [11345]({{site.repo.engine}}/pull/11345) [Android] Write MINIMAL_SDK required to use PlatformViews to exception message [11441]({{site.repo.engine}}/pull/11441) Android 10+ View.setSystemGestureExclusionRects [11451]({{site.repo.engine}}/pull/11451) Android 10+ View.getSystemGestureExclusionRects [12085]({{site.repo.engine}}/pull/12085) Enable platform view keyboard input on Android Q [13059]({{site.repo.engine}}/pull/13059) Android targets create final zip artifacts [13099]({{site.repo.engine}}/pull/13099) NO_SUGGESTIONS keyboard flag in Android [13262]({{site.repo.engine}}/pull/13262) Added Semantic header support on Android. [2003]({{site.github}}/flutter/plugins/pull/2003) [video_player] Added formatHint to to override video format on Android [2029]({{site.github}}/flutter/plugins/pull/2029) fix android crash when pausing or resuming video on APIs lower than 24. [2049]({{site.github}}/flutter/plugins/pull/2049) [path_provider] Android: Support multiple external storage options [2208]({{site.github}}/flutter/plugins/pull/2208) delete all example/android/app/gradle.properties files [2216]({{site.github}}/flutter/plugins/pull/2216) [battery]Use android.arch.lifecycle instead of androidx.lifecycle:lifecycle in [2239]({{site.github}}/flutter/plugins/pull/2239) [camera] Android: Improve image streaming by creating a request suita… ## Add to App feature We've made a significant upgrade to Add-to-App, the feature that allows you to integrate a Flutter module into your Android or iOS app. Can't wait to try it? Check out the [Add-to-App documentation](/add-to-app). [41666]({{site.repo.flutter}}/pull/41666) Generate projects using the new Android embedding [44369]({{site.repo.flutter}}/pull/44369) Flip enable-android-embedding-v2 flag [40810]({{site.repo.flutter}}/pull/40810) Re-enable AAR plugins when an AndroidX failure occurred [41820]({{site.repo.flutter}}/pull/41820) Added SystemNavigator.pop "animated" argument. [12752]({{site.repo.engine}}/pull/12752) Enabled people to chose if SystemNavigator.pop is animated on iOS. [12069]({{site.repo.engine}}/pull/12069) Fold the calls for FlutterMain into the FlutterEngine constructor [39945]({{site.repo.flutter}}/pull/39945) added new lifecycle state [11913]({{site.repo.engine}}/pull/11913) Added new lifecycle enum [45115]({{site.repo.flutter}}/pull/45115) fix ios_add2app_life_cycle license [45133]({{site.repo.flutter}}/pull/45133) reland add lifecycle enum and fix the scheduleforcedframe [45430]({{site.repo.flutter}}/pull/45430) Drops detached message until we can handle it properly [9525]({{site.repo.engine}}/pull/9525) Android Embedding Refactor PR36: Add splash screen support. [9506]({{site.repo.engine}}/pull/9506) Synchronize main thread and gpu thread for first render frame [39600]({{site.repo.flutter}}/pull/39600) Let Material BackButton have a custom onPressed handler [9952]({{site.repo.engine}}/pull/9952) ios: Fixed the callback for the first frame so that it isn't predicated on having a splash screen. [10145]({{site.repo.engine}}/pull/10145) Added integration test that tests that the first frame callback is called [42708]({{site.repo.flutter}}/pull/42708) Test the Android embedding v2 [43221]({{site.repo.flutter}}/pull/43221) Migrate examples to the Android embedding v2 [9895]({{site.repo.engine}}/pull/9895) Android Embedding PR37: Separated FlutterActivity and FlutterFragment via FlutterActivityAndFragmentDelegate [11890]({{site.repo.engine}}/pull/11890) Add some AppLifecycleTests [12128]({{site.repo.engine}}/pull/12128) Make iOS FlutterViewController stop sending inactive/pause on app lifecycle events when not visible [12232]({{site.repo.engine}}/pull/12232) FlutterViewController notify will dealloc [13280]({{site.repo.engine}}/pull/13280) Android embedding API updates for plugin ecosystem [13349]({{site.repo.engine}}/pull/13349) Deprecated DartExecutor as BinaryMessenger and added a getBinaryMessenger() method. (#43202) [13432]({{site.repo.engine}}/pull/13432) Release shim bindings when detaching [2232]({{site.github}}/flutter/plugins/pull/2232) [multiple] V2 embedding plugins use compileOnly [1323]({{site.github}}/FirebaseExtended/flutterfire/pull/1323) [firebase_core][firebase_analytics] Fix bug with transitive lifecycle dependencies [13445]({{site.repo.engine}}/pull/13445) Fizzle onConfigurationChanged if no FlutterView [44499]({{site.repo.flutter}}/pull/44499) Show a warning when a module uses a v1 only plugin [35100]({{site.repo.flutter}}/pull/35100) Add handling of 'TextInput.clearClient' message from platform to framework (#35054). [13474]({{site.repo.engine}}/pull/13474) Request a reattach when creating the text input plugin on Android [43959]({{site.repo.flutter}}/pull/43959) Respond to TextInputClient.reattach messages. [509]({{site.github}}/flutter/cocoon/pull/509) Force the phone's screen on before running a test. [11792]({{site.repo.engine}}/pull/11792) Started logging warnings if we drop platform messages. [12167]({{site.repo.engine}}/pull/12167) Channel buffers [40165]({{site.repo.flutter}}/pull/40165) Channel buffers [12402]({{site.repo.engine}}/pull/12402) Resize channel buffers [6879]({{site.repo.engine}}/pull/6879) Allow FlutterViewController to be released when not initialized with an engine [9329]({{site.repo.engine}}/pull/9329) Fixed memory leak by way of accidental retain on implicit self [9347]({{site.repo.engine}}/pull/9347) Surrogate binary messenger [9419]({{site.repo.engine}}/pull/9419) Has a binary messenger [8387]({{site.repo.engine}}/pull/8387) Make the resource context primary on iOS [11798]({{site.repo.engine}}/pull/11798) Manage resource and onscreen contexts using separate IOSGLContext objects [12277]({{site.repo.engine}}/pull/12277) Manage resource and onscreen contexts using separate IOSGLContext objects [13396]({{site.repo.engine}}/pull/13396) Made it so we clean up gl resources when view controllers get deleted. [39157]({{site.repo.flutter}}/pull/39157) Use new Maven artifacts from Gradle [39503]({{site.repo.flutter}}/pull/39503) Remove bitcode=NO from add-to-app flows [36793]({{site.repo.flutter}}/pull/36793) Vend Flutter module App.framework as a local CocoaPod pod to be installed by a host app [37966]({{site.repo.flutter}}/pull/37966) Remove ephemeral directories during flutter clean [40302]({{site.repo.flutter}}/pull/40302) Set DEFINES_MODULE for FlutterPluginRegistrant to generate modulemap [37731]({{site.repo.flutter}}/pull/37731) Add metadata to indicate if the host app contains a Flutter module [36805]({{site.repo.flutter}}/pull/36805) Allow flavors and custom build types in host app [26630]({{site.repo.flutter}}/pull/26630) Move flutter_assets to App.framework [31463]({{site.repo.flutter}}/pull/31463) Disable all Dart fingerprinters [35217]({{site.repo.flutter}}/pull/35217) Add flutter build aar [40927]({{site.repo.flutter}}/pull/40927) Make module pod headers public [44065]({{site.repo.flutter}}/pull/44065) Build ios framework [37206]({{site.repo.flutter}}/pull/37206) Test that modules built as AAR contain the right assets and artifacts [44127]({{site.repo.flutter}}/pull/44127) build aar prints how to consume the artifacts [23782]({{site.repo.flutter}}/pull/23782) Add flutter_shared assets to module artifact [22707]({{site.repo.flutter}}/pull/22707) Gradle plugin support for adding flutter as subproject to another Android app [9893]({{site.repo.engine}}/pull/9893) Removed logic from FlutterAppDelegate into FlutterPluginAppLifeCycleDelegate [9922]({{site.repo.engine}}/pull/9922) Split out lifecycle protocol [44026]({{site.repo.flutter}}/pull/44026) Exit tool if a plugin only supports the embedding v2 but the app doesn't [44214]({{site.repo.flutter}}/pull/44214) Fix v1 embedding support heuristic for plugins [43994]({{site.repo.flutter}}/pull/43994) flutter build aar should also build plugins as AARs [13455]({{site.repo.engine}}/pull/13455) Automatically register plugins in FlutterEngine. (#43855) [44011]({{site.repo.flutter}}/pull/44011) Move the plugin registrant to io.flutter.plugins and add the @Keep an… [44166]({{site.repo.flutter}}/pull/44166) Add v1 plugin register function into v2 plugin template [13394]({{site.repo.engine}}/pull/13394) Remove multiplexed Flutter Android Lifecycle. (#43663) [45557]({{site.repo.flutter}}/pull/45557) Add a note to generated plugins files [45379]({{site.repo.flutter}}/pull/45379) Add .flutter-plugins-dependencies to the project, which contains the app's plugin dependency graph [3850]({{site.repo.flutter}}-intellij/pull/3850) Support co-editing Flutter and Android in a single project [4097]({{site.repo.flutter}}-intellij/pull/4097) Support for debugging add-to-app modules in Android Studio [4129]({{site.repo.flutter}}-intellij/pull/4129) Smooth out the rough spots in add-to-app support [4062]({{site.repo.flutter}}-intellij/pull/4062) Re-enable attach button for add-to-app projects [4004]({{site.repo.flutter}}-intellij/pull/4004) Co-edit module created in Android Studio [33297]({{site.repo.flutter}}/pull/33297) Instrument add to app flows [33458]({{site.repo.flutter}}/pull/33458) Add to app measurement [34189]({{site.repo.flutter}}/pull/34189) Instrument usage of include_flutter.groovy and xcode_backend.sh [13289]({{site.repo.engine}}/pull/13289) Made restarting the Engine remember the last entrypoint that was used. [12370]({{site.repo.engine}}/pull/12370) Added a default entrypoint variable to match android syntax. [10823]({{site.repo.engine}}/pull/10823) Expose isolateId for engine [13264]({{site.repo.engine}}/pull/13264) Made restarting the Engine remember the last entrypoint that was used. [13789]({{site.repo.engine}}/pull/13789) add recent packages to javadoc list [10481]({{site.repo.engine}}/pull/10481) Android embedding refactor pr40 add static engine cache [29946]({{site.repo.flutter}}/pull/29946) Let CupertinoPageScaffold have tap status bar to scroll to top [12587]({{site.repo.engine}}/pull/12587) Split out the logic to handle status bar touches into its own function [44638]({{site.repo.flutter}}/pull/44638) Add module to create template help text [9351]({{site.repo.engine}}/pull/9351) Android Embedding Refactor PR32: Clean up logs in new embedding. [6447]({{site.repo.engine}}/pull/6447) iOS Embedding Refactor [41794]({{site.repo.flutter}}/pull/41794) Updated the docstring for SystemNavigator.pop. [9304]({{site.repo.engine}}/pull/9304) Decorate UIApplicationDelegate wrappers with matching UIKit deprecation [266]({{site.github}}/FirebaseExtended/flutterfire/pull/266) [firebase_performance] support v2 android embedding [274]({{site.github}}/FirebaseExtended/flutterfire/pull/274) [firebase_core] v2 embedding API [275]({{site.github}}/FirebaseExtended/flutterfire/pull/275) [firebase_ml_vision] v2 embedding API [282]({{site.github}}/FirebaseExtended/flutterfire/pull/282) [firebase_remote_config] Support v2 android embedder. [287]({{site.github}}/FirebaseExtended/flutterfire/pull/287) [firebase_database] Support v2 android embedder. [1266]({{site.github}}/FirebaseExtended/flutterfire/pull/1266) [firebase_analytics] Support Android v2 embedding [1295]({{site.github}}/FirebaseExtended/flutterfire/pull/1295) [firebase_storage] Support Android v2 embedding [1369]({{site.github}}/FirebaseExtended/flutterfire/pull/1369) Upgrade in-app-messaging to plugin api v2 [1370]({{site.github}}/FirebaseExtended/flutterfire/pull/1370) Upgrade crashlytics to v2 plugin API [1372]({{site.github}}/FirebaseExtended/flutterfire/pull/1372) [firebase_dynamic_links] support v2 embedding [2142]({{site.github}}/flutter/plugins/pull/2142) [Connectivity] migrate to the new android embedding [2152]({{site.github}}/flutter/plugins/pull/2152) [battery] Support the v2 Android embedder [2155]({{site.github}}/flutter/plugins/pull/2155) [in_app_purchase] migrate to the v2 android embedding [2156]({{site.github}}/flutter/plugins/pull/2156) [Share] Support v2 android embedder. [2157]({{site.github}}/flutter/plugins/pull/2157) [url_launcher] Migrate to the new embedding [2160]({{site.github}}/flutter/plugins/pull/2160) [package_info] Support the v2 Android embedder (with e2e tests) [2162]({{site.github}}/flutter/plugins/pull/2162) [shared_preferences] Support v2 android embedder. [2163]({{site.github}}/flutter/plugins/pull/2163) [device_info] Support v2 android embedder. [2164]({{site.github}}/flutter/plugins/pull/2164) [sensor] Support v2 android embedder. [2165]({{site.github}}/flutter/plugins/pull/2165) [camera] Migrate to the new embedding [2167]({{site.github}}/flutter/plugins/pull/2167) [quick_actions] Support v2 android embedder. [2169]({{site.github}}/flutter/plugins/pull/2169) [flutter_webview] Migrate to the new embedding [2193]({{site.github}}/flutter/plugins/pull/2193) [android_alarm_manager] migrate to the V2 Android embedding [2195]({{site.github}}/flutter/plugins/pull/2195) [android_intent] Cleanup the V2 migration [2196]({{site.github}}/flutter/plugins/pull/2196) [webview_flutter] (Trivial) Add V2 warnings [2200]({{site.github}}/flutter/plugins/pull/2200) [flutter_webview] Revert v2 embedder support [2204]({{site.github}}/flutter/plugins/pull/2204) [url_launcher] Re-land v2 embedding support [2209]({{site.github}}/flutter/plugins/pull/2209) [webview_flutter] Re-land support v2 embedding support [2226]({{site.github}}/flutter/plugins/pull/2226) [video_player] Add v2 embedding support [2241]({{site.github}}/flutter/plugins/pull/2241) [Shared_preferences]suppress warnings [2284]({{site.github}}/flutter/plugins/pull/2284) [path_provider] Add v2 embedding support for [2327]({{site.github}}/flutter/plugins/pull/2327) [android_alarm_manager] Update minimum Flutter version to 1.12.0 [43461]({{site.repo.flutter}}/pull/43461) Fixed usage of optional types in swift integration test. [13423]({{site.repo.engine}}/pull/13423) Automatically destroy FlutterEngine when created by FlutterActivity or FlutterFragment. [42958]({{site.repo.flutter}}/pull/42958) Turn off bitcode for integration tests and add-to-app templates [13428]({{site.repo.engine}}/pull/13428) Set the install name at link time for darwin dylibs [41333]({{site.repo.flutter}}/pull/41333) Merge Flutter assets in add to app [39747]({{site.repo.flutter}}/pull/39747) Fix type mismatch in Gradle [39986]({{site.repo.flutter}}/pull/39986) Enable Proguard by default on release mode [40181]({{site.repo.flutter}}/pull/40181) Update Kotlin and Gradle version [40282]({{site.repo.flutter}}/pull/40282) Flip the default for proguard [40440]({{site.repo.flutter}}/pull/40440) Rename useProguard method, so Gradle doesn't get confused [40453]({{site.repo.flutter}}/pull/40453) Enable R8 [40610]({{site.repo.flutter}}/pull/40610) Enable the resource shrinker [40900]({{site.repo.flutter}}/pull/40900) Stop using deprecated features from Gradle [40925]({{site.repo.flutter}}/pull/40925) Use AndroidX in new projects by default [41142]({{site.repo.flutter}}/pull/41142) Add embedding as API dependency instead of compile only dependency [41251]({{site.repo.flutter}}/pull/41251) Migrate examples and tests to AndroidX [41254]({{site.repo.flutter}}/pull/41254) Test that flutter assets are contained in the APK [41885]({{site.repo.flutter}}/pull/41885) Include embedding transitive dependencies in plugins [41942]({{site.repo.flutter}}/pull/41942) Use mergeResourcesProvider instead of deprecated mergeResources [42022]({{site.repo.flutter}}/pull/42022) Fix smoke test [42306]({{site.repo.flutter}}/pull/42306) Ensure that flutter assets are copied in the AAR [42352]({{site.repo.flutter}}/pull/42352) Add android.permission.WAKE_LOCK permission to abstract_method_smoke_test [42360]({{site.repo.flutter}}/pull/42360) Add smoke test for the new Android embedding [42548]({{site.repo.flutter}}/pull/42548) Print message and log event when app isn't using AndroidX [42684]({{site.repo.flutter}}/pull/42684) Remove isNewAndroidEmbeddingEnabled flag when reading an existing pro… [42709]({{site.repo.flutter}}/pull/42709) Test Gradle on Windows [42981]({{site.repo.flutter}}/pull/42981) Remove GeneratedPluginRegistrant.java [43187]({{site.repo.flutter}}/pull/43187) Ensure android.enableR8 is appended to a new line [43479]({{site.repo.flutter}}/pull/43479) Refactor gradle.dart [43669]({{site.repo.flutter}}/pull/43669) Don't read AndroidManifest.xml if it doesn't exit [43674]({{site.repo.flutter}}/pull/43674) Add missing import [43675]({{site.repo.flutter}}/pull/43675) Fix device lab tests [43927]({{site.repo.flutter}}/pull/43927) Fix stdout test [43941]({{site.repo.flutter}}/pull/43941) Tweaks after the gradle.dart refactor [44301]({{site.repo.flutter}}/pull/44301) Don't print how to consume AARs when building plugins as AARs [44243]({{site.repo.flutter}}/pull/44243) Build local maven repo when using local engine [44302]({{site.repo.flutter}}/pull/44302) Don't add x86 nor x64 when building a local engine in debug mode [44637]({{site.repo.flutter}}/pull/44637) Attach looks at future observatory URIs [44783]({{site.repo.flutter}}/pull/44783) Forward ProcessException to error handlers [44797]({{site.repo.flutter}}/pull/44797) Build AAR for all build variants by default [45439]({{site.repo.flutter}}/pull/45439) Fallback to protocol discovery if mdns returns null [45579]({{site.repo.flutter}}/pull/45579) Add integration test for transitive plugin dependencies [45743]({{site.repo.flutter}}/pull/45743) Android log reader reads any recent logs [45937]({{site.repo.flutter}}/pull/45937) Handle case where lastLogcatTimestamp is null [46040]({{site.repo.flutter}}/pull/46040) Enable Android embedding v2 on the beta, dev and stable channel [46101]({{site.repo.flutter}}/pull/46101) Remove flutterBuildPluginAsAarFeature flag [14136]({{site.repo.engine}}/pull/14136) Expanded our scenario_app docs. [14094]({{site.repo.engine}}/pull/14094) Started specifying the OS version for running the tests. [13421]({{site.repo.engine}}/pull/13421) FlutterAppDelegate: Added back in empty lifecycle methods [13073]({{site.repo.engine}}/pull/13073) Removed retain cycle from notification center. [13006]({{site.repo.engine}}/pull/13006) Refactor: FlutterDartProject [44782]({{site.repo.flutter}}/pull/44782) Updated flutter/examples to further conform to new embedding: removed references to FlutterApplication, deleted all MainActivity's that were not necessary, removed all direct invocations of GeneratedPluginRegistrant. (#22529) [45740]({{site.repo.flutter}}/pull/45740) Do not delete output directory during flutter build ios-framework [45560]({{site.repo.flutter}}/pull/45560) Always compile with isysroot on iOS to point to SDK root [45436]({{site.repo.flutter}}/pull/45436) Always compile with -isysroot flag on iOS to point to SDK root [45189]({{site.repo.flutter}}/pull/45189) Remove chmod to make Flutter framework headers unwritable [45136]({{site.repo.flutter}}/pull/45136) Remove FLUTTER_DEVICELAB_XCODE_PROVISIONING_CONFIG code paths [44633]({{site.repo.flutter}}/pull/44633) Turn on bitcode for integration tests and add-to-app templates [44625]({{site.repo.flutter}}/pull/44625) Release startup lock during long-lived build ios framework [44324]({{site.repo.flutter}}/pull/44324) Add swift_versions to plugin template podspec, include default CocoaPod version [43915]({{site.repo.flutter}}/pull/43915) Observe logging from VM service on iOS 13 [43553]({{site.repo.flutter}}/pull/43553) Pass environment variables through to xcodebuild [42872]({{site.repo.flutter}}/pull/42872) Remove use_modular_headers from Podfiles using libraries [42808]({{site.repo.flutter}}/pull/42808) Run flutter pub get before pod install in platform_view_ios__start_up test [42254]({{site.repo.flutter}}/pull/42254) Update minimum version to Xcode 10.2 [42204]({{site.repo.flutter}}/pull/42204) Add use_modular_headers! to default Podfile [42029]({{site.repo.flutter}}/pull/42029) Always embed iOS Flutter.framework build mode version from Xcode configuration [41882]({{site.repo.flutter}}/pull/41882) Increase template Swift version from 4 to 5 [41491]({{site.repo.flutter}}/pull/41491) Skip pod initialization if version >= 1.8.0. [40792]({{site.repo.flutter}}/pull/40792) Move build info checks from generating files to the xcode build [40611]({{site.repo.flutter}}/pull/40611) Warn when build number and version can't be parsed on iOS [40401]({{site.repo.flutter}}/pull/40401) Make FlutterPluginRegistrant a static framework so add-to-app can use static framework plugins [40174]({{site.repo.flutter}}/pull/40174) Keep Flutter.framework binaries writable so they can be code signed [40117]({{site.repo.flutter}}/pull/40117) Show outdated CocoaPods version in hint text [39539]({{site.repo.flutter}}/pull/39539) Keep Flutter.framework binaries writable so they can be code signed [39509]({{site.repo.flutter}}/pull/39509) Skip failing add2app test to unblock roll [38992]({{site.repo.flutter}}/pull/38992) Clean Xcode workspace during flutter clean [38905]({{site.repo.flutter}}/pull/38905) Remove iphonesimulator from SUPPORTED_PLATFORMS for Profile and Release modes [11357]({{site.repo.engine}}/pull/11357) Rename first frame method and notify FlutterActivity when full drawn (#38714 #36796). [11844]({{site.repo.engine}}/pull/11844) Updated API usage in scenario app by deleting unnecessary method. [11902]({{site.repo.engine}}/pull/11902) Remove un-needed FragmentActivity import statements to facilitate proguard. [12305]({{site.repo.engine}}/pull/12305) Introduce flutterfragmentactivity [12328]({{site.repo.engine}}/pull/12328) Added javadoc comments to FlutterActivity and FlutterFragmentActivity. [12359]({{site.repo.engine}}/pull/12359) Forwards Flutter View to platform views and detaches when needed. [12362]({{site.repo.engine}}/pull/12362) Fixes race condition that was reported internally. [12806]({{site.repo.engine}}/pull/12806) Move initialization into FlutterEngine [12987]({{site.repo.engine}}/pull/12987) Added FlutterActivity and FlutterFragment hook to cleanUpFlutterEngine() as symmetry for configureFlutterEngine(). (#41943) [13214]({{site.repo.engine}}/pull/13214) Forwards Activity result to FlutterFragment in FlutterFragmentActivity. [13215]({{site.repo.engine}}/pull/13215) Adds Dark Mode support to new Android embedding (this was accidentally missed previously). [13402]({{site.repo.engine}}/pull/13402) Converted ActivityAware and ServiceAware Lifecycles to opaque objects (#43670) [13660]({{site.repo.engine}}/pull/13660) Fix splash screen lookup. (#44131) [13698]({{site.repo.engine}}/pull/13698) Fix plugin registrant reflection path. (#44161) [13738]({{site.repo.engine}}/pull/13738) Removed scary experimental warnings for new embedding. (#44314) [13739]({{site.repo.engine}}/pull/13739) Point old plugin registry accessors to new embedding plugin accessors. (#44225) [13743]({{site.repo.engine}}/pull/13743) Expose asset lookup from plugin binding. (#42019) [13855]({{site.repo.engine}}/pull/13855) Add support for --dart-flags in FlutterShellArgs. (#44855) [13932]({{site.repo.engine}}/pull/13932) Removed GET_ACTIVITIES flag from all manifest meta-data lookups. (#38891) [2087]({{site.github}}/flutter/plugins/pull/2087) [android_alarm_manager] Update and migrate iOS example project [2088]({{site.github}}/flutter/plugins/pull/2088) [android_intent] Update and migrate iOS example project [2089]({{site.github}}/flutter/plugins/pull/2089) [battery] Update and migrate iOS example project [2090]({{site.github}}/flutter/plugins/pull/2090) [camera] Update and migrate iOS example project [2091]({{site.github}}/flutter/plugins/pull/2091) [connectivity] Update and migrate iOS example project [2092]({{site.github}}/flutter/plugins/pull/2092) [device_info] Update and migrate iOS example project [2093]({{site.github}}/flutter/plugins/pull/2093) [google_maps_flutter] Update and migrate iOS example project [2094]({{site.github}}/flutter/plugins/pull/2094) [google_sign_in] Update and migrate iOS example project [2095]({{site.github}}/flutter/plugins/pull/2095) [image_picker] Update and migrate iOS example project [2096]({{site.github}}/flutter/plugins/pull/2096) [in_app_purchase] Update and migrate iOS example project [2097]({{site.github}}/flutter/plugins/pull/2097) [local_auth] Update and migrate iOS example project [2098]({{site.github}}/flutter/plugins/pull/2098) [package_info] Update and migrate iOS example project [2099]({{site.github}}/flutter/plugins/pull/2099) [path_provider] Update and migrate iOS example project [2100]({{site.github}}/flutter/plugins/pull/2100) [quick_actions] Update and migrate iOS example project [2101]({{site.github}}/flutter/plugins/pull/2101) [sensors] Update and migrate iOS example project [2102]({{site.github}}/flutter/plugins/pull/2102) [share] Update and migrate iOS example project [2103]({{site.github}}/flutter/plugins/pull/2103) [shared_preferences] Update and migrate iOS example project [2109]({{site.github}}/flutter/plugins/pull/2109) [url_launcher] Update and migrate iOS example project [2110]({{site.github}}/flutter/plugins/pull/2110) [video_player] Update and migrate iOS example project [2115]({{site.github}}/flutter/plugins/pull/2115) [camera] Define clang modules in for iOS [2125]({{site.github}}/flutter/plugins/pull/2125) [in_app_purchase] Define clang module for iOS [2128]({{site.github}}/flutter/plugins/pull/2128) [image_picker] Define clang module for iOS [2135]({{site.github}}/flutter/plugins/pull/2135) [android_alarm_manager] Define clang module for iOS [2137]({{site.github}}/flutter/plugins/pull/2137) [connectivity] Define clang module for iOS [2138]({{site.github}}/flutter/plugins/pull/2138) [device_info] Define clang module for iOS [2144]({{site.github}}/flutter/plugins/pull/2144) [android_intent] Define clang module for iOS [2145]({{site.github}}/flutter/plugins/pull/2145) [instrumentation_adapter] Define clang module for iOS [2146]({{site.github}}/flutter/plugins/pull/2146) [local_auth] Define clang module for iOS [2147]({{site.github}}/flutter/plugins/pull/2147) [path_provider] Define clang module for iOS [2148]({{site.github}}/flutter/plugins/pull/2148) [package_info] Define clang module for iOS [2149]({{site.github}}/flutter/plugins/pull/2149) [quick_actions] Define clang module for iOS [2175]({{site.github}}/flutter/plugins/pull/2175) [sensors] Define clang module for iOS [2176]({{site.github}}/flutter/plugins/pull/2176) [shared_preferences] Define clang module for iOS [2177]({{site.github}}/flutter/plugins/pull/2177) [url_launcher] Define clang module for iOS [2179]({{site.github}}/flutter/plugins/pull/2179) [battery] Define clang module for iOS [2180]({{site.github}}/flutter/plugins/pull/2180) [share] Define clang module for iOS [2182]({{site.github}}/flutter/plugins/pull/2182) [google_maps_flutter] Define clang module for iOS, fix analyzer warnings [2183]({{site.github}}/flutter/plugins/pull/2183) [video_player] Define clang module for iOS [2184]({{site.github}}/flutter/plugins/pull/2184) [google_sign_in] Define clang module for iOS [2185]({{site.github}}/flutter/plugins/pull/2185) [webview_flutter] Define clang module for iOS [2186]({{site.github}}/flutter/plugins/pull/2186) Run clang analyzer on iOS and macOS code in CI test when packages change [40302]({{site.repo.flutter}}/pull/40302) Set DEFINES_MODULE for FlutterPluginRegistrant to generate modulemap [2206]({{site.github}}/flutter/plugins/pull/2206) [flutter_plugin_android_lifecycle] Update README with new plugin name [2207]({{site.github}}/flutter/plugins/pull/2207) [flutter_plugin_android_lifecycle] bump e2e depenency to 0.2.1 [2223]({{site.github}}/flutter/plugins/pull/2223) [flutter_plugin_android_lifecycle] register the e2e plugin in the example app [2243]({{site.github}}/flutter/plugins/pull/2243) [flutter_plugin_android_lifecycle] Adapt the FlutterLifecycleAdapter to the new embedding API [44043]({{site.repo.flutter}}/pull/44043) Add Android embedding version analytics [2120]({{site.github}}/flutter/plugins/pull/2120) [image_picker] fix crash when aar from 'flutter build aar' [2168]({{site.github}}/flutter/plugins/pull/2168) Add plugin for Android lifecycle in embedding [2174]({{site.github}}/flutter/plugins/pull/2174) [url_launcher] Enable androidx and jetifier in android gradle properties [11239]({{site.repo.engine}}/pull/11239) Remove dart entrypoint Intent parameter from FlutterActivity. (#38713) [12469]({{site.repo.engine}}/pull/12469) Started asserting the FlutterEngine is running before communicating over channels. [13403]({{site.repo.engine}}/pull/13403) Use DartExecutor.getBinaryMessenger in FlutterNativeView instead of deprecated send methods ## Material Material continues to a focus for the Flutter team. In this release, we refreshed all Material widgets with dark mode support. Also, we added support for extending the height of the Scaffold's body behind the app bar, which was contributed by a community member! [36998]({{site.repo.flutter}}/pull/36998) Added properties in DropdownButtonFormField to match DropdownButton [37962]({{site.repo.flutter}}/pull/37962) Show search app bar theme [38583]({{site.repo.flutter}}/pull/38583) Added InheritedTheme [38650]({{site.repo.flutter}}/pull/38650) Allow independent theming of Persistent and Modal bottom sheets [38709]({{site.repo.flutter}}/pull/38709) [Material] Add contentPadding property to SwitchListTile [38726]({{site.repo.flutter}}/pull/38726) Make disabled buttons/chips/text fields not be focusable. [38813]({{site.repo.flutter}}/pull/38813) Add ToggleButtons.textStyle property [38831]({{site.repo.flutter}}/pull/38831) [Material] Add clip property to bottom sheet and theme [38898]({{site.repo.flutter}}/pull/38898) ToggleButtons test improvement [39144]({{site.repo.flutter}}/pull/39144) Add the textAlignVertical param to TextFormField [39156]({{site.repo.flutter}}/pull/39156) Added Scaffold.extendBodyBehindAppBar [39299]({{site.repo.flutter}}/pull/39299) Add showAboutDialog sample [39333]({{site.repo.flutter}}/pull/39333) Allow independent theming of Persistent and Modal bottom sheets Background Color [39433]({{site.repo.flutter}}/pull/39433) Add helperMaxLines to InputDecoration and InputDecorationTheme [39572]({{site.repo.flutter}}/pull/39572) Prevent exception when creating a Divider borderSide [39583]({{site.repo.flutter}}/pull/39583) Fix single action banner to ensure button alignment [39627]({{site.repo.flutter}}/pull/39627) Default colorScheme data in ButtonThemeData (fix for #38655) [39632]({{site.repo.flutter}}/pull/39632) Updates to debugFillProperties to test all properties in slider.dart and slider_test.dart [39903]({{site.repo.flutter}}/pull/39903) Fixed passing autofocus to MaterialButton, and when rebuilding Focus widget. [39924]({{site.repo.flutter}}/pull/39924) Adds DartPad option to the DartDoc snippet generator. [40390]({{site.repo.flutter}}/pull/40390) a11y improvements for textfield [40608]({{site.repo.flutter}}/pull/40608) Add the option to configure a chip check mark color [40641]({{site.repo.flutter}}/pull/40641) Add onLongPress to Buttons [40665]({{site.repo.flutter}}/pull/40665) Fix CupertinoTextField and TextField ToolbarOptions not changing [40713]({{site.repo.flutter}}/pull/40713) Material textselection context menu cannot disable select all [40994]({{site.repo.flutter}}/pull/40994) Fix the ThemeData.copyWith toggleButtonsTheme argument type [41120]({{site.repo.flutter}}/pull/41120) Dropdown Menu layout respects menu items intrinsic sizes [41150]({{site.repo.flutter}}/pull/41150) Rebuild modal routes when the value of userGestureInProgress changes [41172]({{site.repo.flutter}}/pull/41172) fix some bad indentations [41320]({{site.repo.flutter}}/pull/41320) [Material] Remove text ripple from TextFields [41338]({{site.repo.flutter}}/pull/41338) Fix ReorderableListView's use of child keys (#41334) [41463]({{site.repo.flutter}}/pull/41463) [Chip] Make sure InkResponse is in the foreground on delete for chips with background color [41625]({{site.repo.flutter}}/pull/41625) Update DefaultTabController to allow for zero tabs [41629]({{site.repo.flutter}}/pull/41629) [Material] Fix Tooltip to respect ambient Directionality [41632]({{site.repo.flutter}}/pull/41632) fix confusing 'popupTheme' variable name in a MaterialBannerTheme method [41640]({{site.repo.flutter}}/pull/41640) some formatting changes [41650]({{site.repo.flutter}}/pull/41650) DropdownButton.style API doc example for differing button and menu item text styles [41864]({{site.repo.flutter}}/pull/41864) Update BottomAppBar to use elevation overlays when in a dark theme [41972]({{site.repo.flutter}}/pull/41972) Add enableFeedback param to MaterialButton, RawMaterialButton and IconButton [42033]({{site.repo.flutter}}/pull/42033) Reprise: Dropdown Menu layout respects menu items intrinsic sizes [42189]({{site.repo.flutter}}/pull/42189) Fix regression with ModalBottomSheets not responding to changes in theme [42366]({{site.repo.flutter}}/pull/42366) TextStyle.fontFamily should override fontFamily parameter in ThemeData [42404]({{site.repo.flutter}}/pull/42404) Add isDismissible configuration for showModalBottomSheet [42482]({{site.repo.flutter}}/pull/42482) Only dismiss dropdowns if the orientation changes, not the size. [42554]({{site.repo.flutter}}/pull/42554) Fix route focusing and autofocus when reparenting focus nodes. [42613]({{site.repo.flutter}}/pull/42613) Fix Tooltip implementation of PopupMenuButton [42683]({{site.repo.flutter}}/pull/42683) Optimize focus operations by caching descendants and ancestors. [42779]({{site.repo.flutter}}/pull/42779) Fix chip ripple bug — No longer two ripples [42811]({{site.repo.flutter}}/pull/42811) Add a Focus node to the DropdownButton, and adds an activation action for it. [42936]({{site.repo.flutter}}/pull/42936) Support AppBars with jumbo titles [43213]({{site.repo.flutter}}/pull/43213) Add focus nodes, hover, and shortcuts to switches, checkboxes, and radio buttons. [43422]({{site.repo.flutter}}/pull/43422) trivial fixed AboutListTile having an empty icon placeholder when no icon set. [43511]({{site.repo.flutter}}/pull/43511) Improve DropdownButton assert message [43526]({{site.repo.flutter}}/pull/43526) Change PopupMenuButton.icon type to Widget [43722]({{site.repo.flutter}}/pull/43722) Make selected item get focus when dropdown is opened [43843]({{site.repo.flutter}}/pull/43843) Remove print and fix code formatting [43848]({{site.repo.flutter}}/pull/43848) Don't allow Disabled InkWells to be focusable [43859]({{site.repo.flutter}}/pull/43859) Add convenience accessor for primaryFocus [43946]({{site.repo.flutter}}/pull/43946) Adding subtitle to ExpansionTile [43981]({{site.repo.flutter}}/pull/43981) Fix typo in app_bar.dart [44029]({{site.repo.flutter}}/pull/44029) Use alphabetic baselines for layout of InputDecorator [44068]({{site.repo.flutter}}/pull/44068) Fix typo in tabs.dart [44076]({{site.repo.flutter}}/pull/44076) Typo on comments [44160]({{site.repo.flutter}}/pull/44160) Wire selectedItemBuilder through DropdownButtonFormField [44296]({{site.repo.flutter}}/pull/44296) ModalBarrier and Drawer barrier prevents mouse events [44736]({{site.repo.flutter}}/pull/44736) Check in new diffs to material localizations [44787]({{site.repo.flutter}}/pull/44787) Fix snippets to include element ID in the output sample. [44867]({{site.repo.flutter}}/pull/44867) FocusableActionDetector widget [45081]({{site.repo.flutter}}/pull/45081) Remove duplicated expect from text field test [45362]({{site.repo.flutter}}/pull/45362) Add widget of the week video embeddings ## Text & Accessibility In Text and Accessibility, we have several enhancements in ButtonBar and AlertDialog to prevent text overflow. [40468]({{site.repo.flutter}}/pull/40468) Propagate textfield character limits to semantics [41730]({{site.repo.flutter}}/pull/41730) Allow customization of label styles for semantics debugger [42344]({{site.repo.flutter}}/pull/42344) Add onVisible callback to snackbar. [42368]({{site.repo.flutter}}/pull/42368) Update android semantics test to match existing engine behavior. [43193]({{site.repo.flutter}}/pull/43193) ButtonBar aligns in column when it overflows horizontally [43226]({{site.repo.flutter}}/pull/43226) Implement AlertDialog title/content overflow scroll [38573]({{site.repo.flutter}}/pull/38573) Clamp scrollOffset to prevent textfield bouncing [41108]({{site.repo.flutter}}/pull/41108) Fixing a text editing bug happening when text field changes. [44605]({{site.repo.flutter}}/pull/44605) Changing RenderEditable.textAlign doesn't break hot reload anymore ## Animation & Scroll For animation, we released the [TweenAnimationBuilder]({{site.api}}/flutter/widgets/TweenAnimationBuilder-class.html) for building custom implicit animations. For more information, check out this [TweenAnimationBuilder video](https://www.youtube.com/watch?reload=9&v=6KiPEqzJIKQ) on Youtube. [38317]({{site.repo.flutter}}/pull/38317) TweenAnimationBuilder for building custom animations without managing an AnimationController [38979]({{site.repo.flutter}}/pull/38979) Adding onEnd callback to implicit animated widgets [43756]({{site.repo.flutter}}/pull/43756) Mark routes as opaque when added without animation [39142]({{site.repo.flutter}}/pull/39142) fix sliverfixedextent with sliverchildbuilderdelegate does not correc… [44965]({{site.repo.flutter}}/pull/44965) Scroll scrollable to keep focused control visible. ## Web We increased our support for web, moving it from the dev channel to the beta channel. For more details, please check [web support blog post](https://medium.com/flutter/web-support-for-flutter-goes-beta-35b64a1217c0). [37819]({{site.repo.flutter}}/pull/37819) Add HtmlElementView (the Flutter Web platform view) [38723]({{site.repo.flutter}}/pull/38723) Handle compilation failures from web application [38823]({{site.repo.flutter}}/pull/38823) Print service url when connecting to web applications [39006]({{site.repo.flutter}}/pull/39006) Add web workflow to default validators [39066]({{site.repo.flutter}}/pull/39066) Kill resident runner on browser disconnect. [39073]({{site.repo.flutter}}/pull/39073) Add profile mode to flutter web applications [39189]({{site.repo.flutter}}/pull/39189) fix source map loading and service protocol for flutter web [39344]({{site.repo.flutter}}/pull/39344) Upstream changes necessary for text editing in flutter web [39364]({{site.repo.flutter}}/pull/39364) Correct libraries path and remove dart:io and dart:isolate for dart platform [39414]({{site.repo.flutter}}/pull/39414) Make sure profile is forwarded through build web command [39462]({{site.repo.flutter}}/pull/39462) Remove run in shell and add unit test for chrome launching [39543]({{site.repo.flutter}}/pull/39543) create .dart_tool if it is missing [39628]({{site.repo.flutter}}/pull/39628) Automatically generated registrants for web plugins [39748]({{site.repo.flutter}}/pull/39748) print launching on device message [39751]({{site.repo.flutter}}/pull/39751) Minor cleanup and prevent multiple exit [39752]({{site.repo.flutter}}/pull/39752) Add delay to recompile request for web [39756]({{site.repo.flutter}}/pull/39756) remove web flag from create [39774]({{site.repo.flutter}}/pull/39774) workaround for mangled web sdk source map packages [39910]({{site.repo.flutter}}/pull/39910) If there are no web plugins, don't generate a plugin registrant [39950]({{site.repo.flutter}}/pull/39950) Register reload sources call and make 'r' restart for web [39951]({{site.repo.flutter}}/pull/39951) Add "web" server device to allow running flutter for web on arbitrary browsers [39983]({{site.repo.flutter}}/pull/39983) Update the supported library set for Flutter for web [39999]({{site.repo.flutter}}/pull/39999) Disable the performance overlay for web [40175]({{site.repo.flutter}}/pull/40175) Ensure we send hot restart events for flutter web [40191]({{site.repo.flutter}}/pull/40191) add host and port to run configuration for web devices [40301]({{site.repo.flutter}}/pull/40301) Allow skipping webOnlyInitializePlatform in Flutter for Web [40370]({{site.repo.flutter}}/pull/40370) rename port to web-port and hostname to web-hostname [40465]({{site.repo.flutter}}/pull/40465) Pass --web-hostname and --web-port to release mode debugging options [40627]({{site.repo.flutter}}/pull/40627) Allow skipping chrome launch with --no-web-browser-launch [40757]({{site.repo.flutter}}/pull/40757) Fix visibility of web server device when Chrome is not available [41222]({{site.repo.flutter}}/pull/41222) Copy archived js part files out of dart_tool directory [41347]({{site.repo.flutter}}/pull/41347) Fix timing issues in initialization of web resident runner [41386]({{site.repo.flutter}}/pull/41386) Serve every html file under web [41397]({{site.repo.flutter}}/pull/41397) Keymap for Web [41441]({{site.repo.flutter}}/pull/41441) Exit resident web runner on compilation failure [41545]({{site.repo.flutter}}/pull/41545) Add analytics tracking for compile and refresh times for Flutter Web [41618]({{site.repo.flutter}}/pull/41618) Rename Server/web to Headless Server/headless-server [41695]({{site.repo.flutter}}/pull/41695) Add more information to cannot find Chrome message [41815]({{site.repo.flutter}}/pull/41815) [web] Make it clear that lowercase "r" can also perform hot restart [41906]({{site.repo.flutter}}/pull/41906) Ensure plugin registrants are generated in build_web [41996]({{site.repo.flutter}}/pull/41996) [web] Always send the route name even if it's null [42144]({{site.repo.flutter}}/pull/42144) Don't eagerly call runMain when --start-paused is provided to web application [42260]({{site.repo.flutter}}/pull/42260) Small cleanup of web code [42289]({{site.repo.flutter}}/pull/42289) Ensure precache web works on dev branch [42531]({{site.repo.flutter}}/pull/42531) Print correct hostname when web server is launched [42676]({{site.repo.flutter}}/pull/42676) [web] Update web runner message with flutter.dev/web [42701]({{site.repo.flutter}}/pull/42701) serve correct content type from debug server [42857]({{site.repo.flutter}}/pull/42857) Fix progress indicators for release/profile builds of web. [42951]({{site.repo.flutter}}/pull/42951) implement debugTogglePlatform for the web [42970]({{site.repo.flutter}}/pull/42970) Rename headless server to web server [43214]({{site.repo.flutter}}/pull/43214) For --profile builds on web, still use -O4 but unminified names. [43573]({{site.repo.flutter}}/pull/43573) Catch MissingPortFile from web tooling. [43576]({{site.repo.flutter}}/pull/43576) Enable usage of experimental incremental compiler for web [44028]({{site.repo.flutter}}/pull/44028) Support --no-resident on the web [44263]({{site.repo.flutter}}/pull/44263) Allow web server device to use extension if started with --start-paused [44268]({{site.repo.flutter}}/pull/44268) Switch from using app.progress to app.webLaunchUrl for passing web launch urls [44421]({{site.repo.flutter}}/pull/44421) switch web test to macOS [44744]({{site.repo.flutter}}/pull/44744) Ensure web-server does not force usage of dwds [44746]({{site.repo.flutter}}/pull/44746) Remove chrome device web integration test [44830]({{site.repo.flutter}}/pull/44830) Update manual_tests to be able to run on macOS/web [45145]({{site.repo.flutter}}/pull/45145) cache sdkNameAndVersion logic for web devices [45286]({{site.repo.flutter}}/pull/45286) Fix experimental incremental web compiler for Windows [11360]({{site.repo.engine}}/pull/11360) build legacy web SDK [11421]({{site.repo.engine}}/pull/11421) sync Flutter Web engine to the latest [11732]({{site.repo.engine}}/pull/11732) last flutter web sync: cc38319841 [11796]({{site.repo.engine}}/pull/11796) Provide a hook for a plugin handler to receive messages on the web [12161]({{site.repo.engine}}/pull/12161) Ensure that the web image ImageShader implements Shader [12335]({{site.repo.engine}}/pull/12335) [Web] Implement dark mode support for web [12445]({{site.repo.engine}}/pull/12445) [web] filter test targets; cache host.dart compilation [12712]({{site.repo.engine}}/pull/12712) Support correct keymap for web [12747]({{site.repo.engine}}/pull/12747) Add web implementation for channel_buffers.dart [12753]({{site.repo.engine}}/pull/12753) [web] Don't require felt to be in PATH [12794]({{site.repo.engine}}/pull/12794) [web] Add support for path transform [12811]({{site.repo.engine}}/pull/12811) [web] Implement basic radial gradient (TileMode.clamp, no transform) [13003]({{site.repo.engine}}/pull/13003) [web] Update the url when route is replaced [13066]({{site.repo.engine}}/pull/13066) [web] Add basic color per vertex drawVertices API support [13141]({{site.repo.engine}}/pull/13141) Enable/tweak web sdk source maps [13161]({{site.repo.engine}}/pull/13161) Enable/tweak web sdk source maps, take 2 [13187]({{site.repo.engine}}/pull/13187) [web] Environment variable to disable felt snapshot [13190]({{site.repo.engine}}/pull/13190) [web] Fix canvas reuse metrics. Refactor drawVertices code. [13259]({{site.repo.engine}}/pull/13259) [web] Support -j to use goma in felt build [13268]({{site.repo.engine}}/pull/13268) [web] Support input action [13272]({{site.repo.engine}}/pull/13272) [web] [test] Adding firefox install functionality to the test platform [13296]({{site.repo.engine}}/pull/13296) [web] Cupertino dynamic color fix. [13359]({{site.repo.engine}}/pull/13359) Web: fix Color subclass handling [13462]({{site.repo.engine}}/pull/13462) [web] Get the size from visualviewport instead of window.innerHeight/innerW… [13483]({{site.repo.engine}}/pull/13483) web: fix Paragraph.getBoxesForRange for zero-length ranges [13634]({{site.repo.engine}}/pull/13634) [web] Ignore changes in *.ttf files in felt build watch mode [13699]({{site.repo.engine}}/pull/13699) [web] Don't send keyboard events from text fields to flutter [13722]({{site.repo.engine}}/pull/13722) [web] Proper support for text field's obscureText [13741]({{site.repo.engine}}/pull/13741) [web] Refactor text editing to handle any order of platform messages gracefully [13748]({{site.repo.engine}}/pull/13748) [web] Support gif/webp animations, Speed up image drawing in BitmapCanvas. [13769]({{site.repo.engine}}/pull/13769) [web] Implement TextStyle.shadows [13779]({{site.repo.engine}}/pull/13779) [web] Fix path to svg for drrect [13802]({{site.repo.engine}}/pull/13802) [web] Fix selectable text rendering [13809]({{site.repo.engine}}/pull/13809) [web] Fix blendmode for images [13860]({{site.repo.engine}}/pull/13860) [web] Change canvas sibling transforms to 3d with z=0 to get around canvas rendering bug. [13901]({{site.repo.engine}}/pull/13901) [web] Fix single line bitmap canvas text shadow [13909]({{site.repo.engine}}/pull/13909) [web] Implement PathMetrics.length [13922]({{site.repo.engine}}/pull/13922) [web] Flutter for web autocorrect support [13929]({{site.repo.engine}}/pull/13929) [web] Allow users to enable canvas text measurement [13940]({{site.repo.engine}}/pull/13940) [web] Fix Edge detection for correct dom_renderer reset [13960]({{site.repo.engine}}/pull/13960) [web] Fix default line-height issue for Firefox [13981]({{site.repo.engine}}/pull/13981) [web] use Element.nodes instead of Element.children in text layout [2119]({{site.github}}/flutter/plugins/pull/2119) Add web url launcher ## Desktop We are also moving macOS support from tech preview to alpha, enabling it in the dev channel. For more details, see the [Flutter wiki]({{site.repo.flutter}}/wiki/Desktop-shells). [37901]({{site.repo.flutter}}/pull/37901) [macos] Check for special keys before creating a logical key [38748]({{site.repo.flutter}}/pull/38748) Create correctly structured framework for macOS [38858]({{site.repo.flutter}}/pull/38858) Use GLFW-name artifacts on Windows and Linux [38909]({{site.repo.flutter}}/pull/38909) Add support for macOS release/profile mode (3 of 3) [39017]({{site.repo.flutter}}/pull/39017) Add "OneSequenceRecognizer.resolvePointer". Fix DragGestureRecognizer crash on multiple pointers [39264]({{site.repo.flutter}}/pull/39264) Add profile support on macOS [39432]({{site.repo.flutter}}/pull/39432) Do not hide .git in zip for Windows [39702]({{site.repo.flutter}}/pull/39702) Fix macOS App.framework version symlink [39836]({{site.repo.flutter}}/pull/39836) Switch to the Win32 Windows embedding [40011]({{site.repo.flutter}}/pull/40011) [windows] Searches for pre-release and 'all' Visual Studio installations [40186]({{site.repo.flutter}}/pull/40186) Add shortcuts and actions for default focus traversal [40194]({{site.repo.flutter}}/pull/40194) Add an ephemeral directory to Windows projects [40197]({{site.repo.flutter}}/pull/40197) [windows] Refactor to optimize vswhere queries [40294]({{site.repo.flutter}}/pull/40294) fix copy command and remove resolve sync for macOS assemble [40375]({{site.repo.flutter}}/pull/40375) Harden macOS build use of Xcode project getInfo [40393]({{site.repo.flutter}}/pull/40393) Convert build mode to lowercase in tool_backend [40587]({{site.repo.flutter}}/pull/40587) Add an ephemeral directory for Linux [40730]({{site.repo.flutter}}/pull/40730) Invalidate macOS pods on plugin changes [40851]({{site.repo.flutter}}/pull/40851) Support create for macOS (app and plugin) [41015]({{site.repo.flutter}}/pull/41015) Add the beginnings of plugin support for Windows and Linux [41332]({{site.repo.flutter}}/pull/41332) Prevent PointerEnter[or Exit]Event from erasing event.down value [41551]({{site.repo.flutter}}/pull/41551) Pass Linux build mode on command line [41612]({{site.repo.flutter}}/pull/41612) AOT support for Linux Desktop I: switch Linux builds to assemble [41747]({{site.repo.flutter}}/pull/41747) Add Profile entry to macOS Podfile [42031]({{site.repo.flutter}}/pull/42031) Rewrite MouseTracker's tracking and notifying algorithm [42235]({{site.repo.flutter}}/pull/42235) Reading deviceId for RawKeyEventDataAndroid event [42487]({{site.repo.flutter}}/pull/42487) refactor depfile usage and update linux rule [42861]({{site.repo.flutter}}/pull/42861) Add repeatCount to RawKeyEventDataAndroid [42962]({{site.repo.flutter}}/pull/42962) Remove linux-x64 unpack logic [43238]({{site.repo.flutter}}/pull/43238) Fixing focus traversal when the node options are empty [43362]({{site.repo.flutter}}/pull/43362) Allow rebuilding of docker image, re-enable deploy gallery macos [43758]({{site.repo.flutter}}/pull/43758) Split desktop config fallback variable by platform [44130]({{site.repo.flutter}}/pull/44130) Add command key bindings to macOS text editing and fix selection. [44410]({{site.repo.flutter}}/pull/44410) Add macOS fn key support. [44576]({{site.repo.flutter}}/pull/44576) [ci] Use the latest Cirrus Image for macOS [44620]({{site.repo.flutter}}/pull/44620) Bump memory requirements for tool_tests-general-linux [44844]({{site.repo.flutter}}/pull/44844) Properly interpret modifiers on GLFW key events [45264]({{site.repo.flutter}}/pull/45264) Add macOS hot reload test [45392]({{site.repo.flutter}}/pull/45392) [ci] more resources to Windows tasks [8507]({{site.repo.engine}}/pull/8507) Add texture support for macOS shell. [11324]({{site.repo.engine}}/pull/11324) Clean up Windows and Linux build output [11327]({{site.repo.engine}}/pull/11327) [Windows] Update API for alternative Windows shell platform implementation [11380]({{site.repo.engine}}/pull/11380) Use App.framework in macOS FlutterDartProject [11386]({{site.repo.engine}}/pull/11386) Allow non-resizable windows in GLFW embedding [11475]({{site.repo.engine}}/pull/11475) buildfix: support build windows release/profile mode(#32746) [11828]({{site.repo.engine}}/pull/11828) [Windows] Address #36422 by adding a context for async resource uploading [12230]({{site.repo.engine}}/pull/12230) Add an initial macOS version of FlutterAppDelegate [12234]({{site.repo.engine}}/pull/12234) [glfw/windows] Stops keeping track of input models [12267]({{site.repo.engine}}/pull/12267) [macos] Stops keeping track of text input models [12276]({{site.repo.engine}}/pull/12276) Add system font change listener for windows [12423]({{site.repo.engine}}/pull/12423) add windows embedding test [12809]({{site.repo.engine}}/pull/12809) Use the x64 host toolchain for x86 target gen_snapshot only on Linux [12814]({{site.repo.engine}}/pull/12814) Enable all engine test on windows [13300]({{site.repo.engine}}/pull/13300) Switch the MacOS Desktop embedder to using a thread configuration where the platform and render task runners are the same. [13702]({{site.repo.engine}}/pull/13702) Fix editing selection and deletion on macOS ## Framework We've fixed many bugs in this release to improve the quality and stability of our framework. [38643]({{site.repo.flutter}}/pull/38643) PlatformViewLink handles focus [38699]({{site.repo.flutter}}/pull/38699) fix widgetspan does not work with ellipsis in text widget [38789]({{site.repo.flutter}}/pull/38789) Fix DragTarget not being rebuilt when a rejected Draggable enters #38786 [38930]({{site.repo.flutter}}/pull/38930) Implement system fonts system channel listener [38936]({{site.repo.flutter}}/pull/38936) Fix KeySet (and LogicalKeySet) hashCode calculation [39059]({{site.repo.flutter}}/pull/39059) Explain const values in MediaQuery test file [39085]({{site.repo.flutter}}/pull/39085) Make inspector details subtree depth configurable. [39089]({{site.repo.flutter}}/pull/39089) Correct InheritedTheme.captureAll() for multiple theme ancestors of the same type [39195]({{site.repo.flutter}}/pull/39195) respect reversed scroll views [39252]({{site.repo.flutter}}/pull/39252) Adds relayout option to CustomMultiChildLayout. [39282]({{site.repo.flutter}}/pull/39282) Expose text metrics in TextPainter. [39354]({{site.repo.flutter}}/pull/39354) Add IterableFlagsProperty and use it on proxy box classes [39428]({{site.repo.flutter}}/pull/39428) Replace doc example text [39446]({{site.repo.flutter}}/pull/39446) Add viewType to PlatformViewLink [39844]({{site.repo.flutter}}/pull/39844) Fix curve for popping heroes [40099]({{site.repo.flutter}}/pull/40099) Fix double.infinity serialization [40105]({{site.repo.flutter}}/pull/40105) Ensure frame is scheduled when root widget is attached [40119]({{site.repo.flutter}}/pull/40119) fix skips to include all channels [40280]({{site.repo.flutter}}/pull/40280) PlatformView: recreate surface if the controller changes [40306]({{site.repo.flutter}}/pull/40306) Restore offstage and ticker mode after hero pop and the from hero is null [40609]({{site.repo.flutter}}/pull/40609) Specify ifTrue and ifFalse for strut FlagProperty [40635]({{site.repo.flutter}}/pull/40635) Return WidgetSpans from getSpanForPosition [40638]({{site.repo.flutter}}/pull/40638) Allow sending platform messages from plugins to the framework and implement EventChannel [40709]({{site.repo.flutter}}/pull/40709) Fixed Selectable text align is broken [40718]({{site.repo.flutter}}/pull/40718) Handle CR+LF end of line sequences in the license parser [40775]({{site.repo.flutter}}/pull/40775) Use EdgeInsetsGeometry instead of EdgeInsets [40917]({{site.repo.flutter}}/pull/40917) AnimatedBuilder API Doc improvements [41145]({{site.repo.flutter}}/pull/41145) Explicitly set CocoaPods version [41245]({{site.repo.flutter}}/pull/41245) Change the way ActionDispatcher is found. [41329]({{site.repo.flutter}}/pull/41329) Refactor: Base tap gesture recognizer [41417]({{site.repo.flutter}}/pull/41417) Address previous comments, fix Intent.doNothing. [41763]({{site.repo.flutter}}/pull/41763) No longer rebuild Routes when MediaQuery updates [41791]({{site.repo.flutter}}/pull/41791) Refactor: Make MouseTracker test concise with some utility functions [41803]({{site.repo.flutter}}/pull/41803) Fixed media query issues and added test to prevent it from coming back [41879]({{site.repo.flutter}}/pull/41879) Make MouseTracker.sendMouseNotifications private [42076]({{site.repo.flutter}}/pull/42076) create gesture recognizers on attach and dispose on detach to avoid leaks [42253]({{site.repo.flutter}}/pull/42253) Change modal barrier to dismissing on tap up [42484]({{site.repo.flutter}}/pull/42484) Gradient transform [42526]({{site.repo.flutter}}/pull/42526) Improve routers performance [42558]({{site.repo.flutter}}/pull/42558) Use placeholder dimensions that reflect the final text layout [42688]({{site.repo.flutter}}/pull/42688) Source Code Comment Typo Fixes [42777]({{site.repo.flutter}}/pull/42777) Fix memory leak in TransitionRoute [42879]({{site.repo.flutter}}/pull/42879) Re-implement hardware keyboard text selection. [42953]({{site.repo.flutter}}/pull/42953) Soften layer breakage [43006]({{site.repo.flutter}}/pull/43006) Set default borderRadius to zero in ClipRRect (as documented) [43246]({{site.repo.flutter}}/pull/43246) Tap.dart: Fixes the spacing to the right side of reason [43296]({{site.repo.flutter}}/pull/43296) Skip failing test to green build [43467]({{site.repo.flutter}}/pull/43467) Fixed bug where we could accidently call a callback twice. [43677]({{site.repo.flutter}}/pull/43677) add libzip cache artifact [43684]({{site.repo.flutter}}/pull/43684) [flutter_runner] Use sky_engine from the topaz tree [43685]({{site.repo.flutter}}/pull/43685) Remove Poller class from flutter_tools [43739]({{site.repo.flutter}}/pull/43739) enable avoid_web_libraries_in_flutter [43865]({{site.repo.flutter}}/pull/43865) Reorder show and setEditingState calls to the IMM [44150]({{site.repo.flutter}}/pull/44150) Manually roll engine to unred the tree [44217]({{site.repo.flutter}}/pull/44217) Moving pointer event sanitizing to engine. [44233]({{site.repo.flutter}}/pull/44233) Remove yield from inherited model [44408]({{site.repo.flutter}}/pull/44408) Remove no longer needed clean up code [44422]({{site.repo.flutter}}/pull/44422) Remove TextRange, export it from dart:ui [44490]({{site.repo.flutter}}/pull/44490) Fix "node._relayoutBoundary == _relayoutBoundary" crash [44611]({{site.repo.flutter}}/pull/44611) Convert to TextPosition for getWordBoundary [44617]({{site.repo.flutter}}/pull/44617) Make disposing a ScrollPosition with pixels=null legal [44622]({{site.repo.flutter}}/pull/44622) Track and use fallback TextAffinity for null affinity platform TextSelections. [44967]({{site.repo.flutter}}/pull/44967) Try a mildly prettier FlutterError and make it less drastic in release mode [45083]({{site.repo.flutter}}/pull/45083) Fix draggable scrollable sheet scroll notification [45240]({{site.repo.flutter}}/pull/45240) implicit-casts:false in flutter_web_plugins [45249]({{site.repo.flutter}}/pull/45249) implicit-casts:false in flutter_goldens and flutter_goldens_client ## Engine In this update, the core engine continues to see many improvements, including a fix that solves the long-requested scrolling performance issue on iPhoneX/Xs. [9386]({{site.repo.engine}}/pull/9386) [glfw] Send the glfw key data to the framework. [9498]({{site.repo.engine}}/pull/9498) Notify framework to clear input connection when app is backgrounded (#35054). [9806]({{site.repo.engine}}/pull/9806) Reuse texture cache in ios_external_texture_gl. [9864]({{site.repo.engine}}/pull/9864) Add capability to add AppDelegate as UNUserNotificationCenterDelegate [9888]({{site.repo.engine}}/pull/9888) Provide dart vm initalize isolate callback so that children isolates belong to parent's isolate group. [10154]({{site.repo.engine}}/pull/10154) Started taking advantage of Skia's new copyTableData to avoid superfluous copies. [10182]({{site.repo.engine}}/pull/10182) Made flutter startup faster by allowing initialization to be parallelized [10326]({{site.repo.engine}}/pull/10326) copypixelbuffer causes crash [10670]({{site.repo.engine}}/pull/10670) Expose LineMetrics in dart:ui [10945]({{site.repo.engine}}/pull/10945) De-dup FILE output for each license [11041]({{site.repo.engine}}/pull/11041) Add a BroadcastStream to FrameTiming [11049]({{site.repo.engine}}/pull/11049) Release _ongoingTouches when FlutterViewController dealloc [11062]({{site.repo.engine}}/pull/11062) Provide a placeholder queue ID for the custom embedder task runner. [11063]({{site.repo.engine}}/pull/11063) Update ExternalViewEmbedder class comment. [11070]({{site.repo.engine}}/pull/11070) Platform View implemenation for Metal [11210]({{site.repo.engine}}/pull/11210) Add Chrome to Dockerfile [11222]({{site.repo.engine}}/pull/11222) Dont present session twice [11224]({{site.repo.engine}}/pull/11224) Update metal layer drawable size on relayout. [11226]({{site.repo.engine}}/pull/11226) Make firebase testlab always pass [11228]({{site.repo.engine}}/pull/11228) Re-enable firebase test and don't use google login [11230]({{site.repo.engine}}/pull/11230) Update tflite_native and language_model revisions to match the Dart SDK [11256]({{site.repo.engine}}/pull/11256) Upgrade compiler to Clang 10. [11265]({{site.repo.engine}}/pull/11265) make it possible to disable debug symbols stripping [11270]({{site.repo.engine}}/pull/11270) Reset NSNetService delegate to nil,when stop service. [11283]({{site.repo.engine}}/pull/11283) Fix objects equal to null not being detected as null [11300]({{site.repo.engine}}/pull/11300) Do not Prepare raster_cache if view_embedder is present [11305]({{site.repo.engine}}/pull/11305) Fix a segfault in EmbedderTest.CanSpecifyCustomTaskRunner [11306]({{site.repo.engine}}/pull/11306) Set FlutterMacOS podspec min version to 10.11 [11309]({{site.repo.engine}}/pull/11309) Fix change_install_name.py to be GN-friendly [11310]({{site.repo.engine}}/pull/11310) When using a custom compositor, ensure the root canvas is flushed. [11315]({{site.repo.engine}}/pull/11315) Do not add null task observers [11330]({{site.repo.engine}}/pull/11330) Remove engine hash from the output artifact [11355]({{site.repo.engine}}/pull/11355) update sim script [11356]({{site.repo.engine}}/pull/11356) Remove engine hash from pom filename [11361]({{site.repo.engine}}/pull/11361) Include Java stack trace in method channel invocations [11367]({{site.repo.engine}}/pull/11367) Make message loop task entry containers thread safe [11368]({{site.repo.engine}}/pull/11368) Switch to an incremental runloop for GLFW [11374]({{site.repo.engine}}/pull/11374) Update scenarios readme [11382]({{site.repo.engine}}/pull/11382) Trivial: remove empty line in the pom file [11384]({{site.repo.engine}}/pull/11384) Account for root surface transformation on the surfaces managed by the external view embedder. [11388]({{site.repo.engine}}/pull/11388) Allow overriding the GLFW pixel ratio [11392]({{site.repo.engine}}/pull/11392) Wire up software rendering in the test compositor. [11394]({{site.repo.engine}}/pull/11394) Avoid root surface acquisition during custom composition with software renderer. [11395]({{site.repo.engine}}/pull/11395) Remove deprecated ThreadTest::GetThreadTaskRunner and use the newer CreateNewThread API. [11416]({{site.repo.engine}}/pull/11416) Shrink cirrus docker image: reduce RUN count, apt-get clean [11419]({{site.repo.engine}}/pull/11419) Support non-60 refresh rate on PerformanceOverlay [11420]({{site.repo.engine}}/pull/11420) Fix touchpad scrolling on Chromebook [11423]({{site.repo.engine}}/pull/11423) Add tracing of the number of frames in flight in the pipeline. [11427]({{site.repo.engine}}/pull/11427) Skip empty platform view overlays. [11436]({{site.repo.engine}}/pull/11436) update method for skia [11456]({{site.repo.engine}}/pull/11456) Update the ui.LineMetrics.height metric to be more useful to external users [11473]({{site.repo.engine}}/pull/11473) Add missing newline at EOF [11489]({{site.repo.engine}}/pull/11489) Ensure trailing newline before EOF in C++ sources [11520]({{site.repo.engine}}/pull/11520) Bitcode only for release [11524]({{site.repo.engine}}/pull/11524) Reuse texture cache in ios_external_texture_gl [11528]({{site.repo.engine}}/pull/11528) Strip bitcode from gen_snapshot [11537]({{site.repo.engine}}/pull/11537) Add check to enable metal for import [11550]({{site.repo.engine}}/pull/11550) Make Skia cache size channel respond with a value [11554]({{site.repo.engine}}/pull/11554) make engine, ui, and sdk rewriter inputs of dill construction [11576]({{site.repo.engine}}/pull/11576) Minor tweaks to the Doxygen theme. [11622]({{site.repo.engine}}/pull/11622) Include from font_asset_provider [11635]({{site.repo.engine}}/pull/11635) [flutter_runner] Port Expose ViewBound Wireframe Functionality [11636]({{site.repo.engine}}/pull/11636) [fidl][flutter_runner] Port Migrate to new fit::optional compatible APIs [11638]({{site.repo.engine}}/pull/11638) Update CanvasSpy::onDrawEdgeAAQuad for Skia API change [11649]({{site.repo.engine}}/pull/11649) [flutter] Port: Run handle wait completers on the microtask queue [11654]({{site.repo.engine}}/pull/11654) Append newlines to EOF of all translation units. [11655]({{site.repo.engine}}/pull/11655) Don't crash while loading improperly formatted fonts on Safari [11669]({{site.repo.engine}}/pull/11669) Add style guide and formatting information [11717]({{site.repo.engine}}/pull/11717) Return a JSON value for the Skia channel [11722]({{site.repo.engine}}/pull/11722) Quote the font family name whenever setting the font-family property. [11736]({{site.repo.engine}}/pull/11736) Add wasm to sky_engine [11776]({{site.repo.engine}}/pull/11776) [flutter_runner] Port over all the changes to the dart_runner cmx files [11783]({{site.repo.engine}}/pull/11783) completely strip bitcode [11795]({{site.repo.engine}}/pull/11795) Add a good reference source for font metrics. [11804]({{site.repo.engine}}/pull/11804) Incorporate View.setSystemGestureExclusionRects code review feedback from #11441 [11808]({{site.repo.engine}}/pull/11808) Annotate nullability on FlutterEngine to make swift writing more ergonomic [11835]({{site.repo.engine}}/pull/11835) [CFE/VM] Fix merge/typo for bump to kernel version 29 [11839]({{site.repo.engine}}/pull/11839) Remove ENABLE_BITCODE from Scenarios test app [11842]({{site.repo.engine}}/pull/11842) Fix RTL justification with newline by passing in full justify tracking var [11847]({{site.repo.engine}}/pull/11847) Add a sample unit test target to flutter runner [11849]({{site.repo.engine}}/pull/11849) Support building standalone far packages with autogen manifests [11875]({{site.repo.engine}}/pull/11875) [flutter_runner] Add common libs to the test far [11877]({{site.repo.engine}}/pull/11877) Finish plumbing message responses on method channels [11880]({{site.repo.engine}}/pull/11880) Handle new navigation platform messages [11893]({{site.repo.engine}}/pull/11893) Add @Keep annotation [11899]({{site.repo.engine}}/pull/11899) Improve input method and Unicode character display(#30661) [12011]({{site.repo.engine}}/pull/12011) Cherry-picks for 1.9.1 [12016]({{site.repo.engine}}/pull/12016) [flutter_runner] Kernel platform files can now be built in topaz [12023]({{site.repo.engine}}/pull/12023) Fix multi span text ruler cache lookup failure. [12026]({{site.repo.engine}}/pull/12026) [flutter_runner] Plumb Flutter component arguments to the Dart entrypoint [12034]({{site.repo.engine}}/pull/12034) [flutter_runner] Refactor our build rules to make them more inline with topaz [12048]({{site.repo.engine}}/pull/12048) [flutter_runner] Generate symbols for the Dart VM profiler [12054]({{site.repo.engine}}/pull/12054) [flutter_runner] Port the accessibility bridge from Topaz [12076]({{site.repo.engine}}/pull/12076) Add a method to flutter_window_controller to destroy the current window. [12080]({{site.repo.engine}}/pull/12080) Don't quote generic font families [12081]({{site.repo.engine}}/pull/12081) Add GradientRadial paintStyle implementation [12087]({{site.repo.engine}}/pull/12087) Don't launch the observatory by default on each embedder unit-test invocation. [12204]({{site.repo.engine}}/pull/12204) Don't disable toString in release mode for dart:ui classes [12205]({{site.repo.engine}}/pull/12205) Don't load Roboto by default [12218]({{site.repo.engine}}/pull/12218) Namespace patched SDK names to not conflict with Topaz [12222]({{site.repo.engine}}/pull/12222) Do not generate kernel platform files on topaz tree [12226]({{site.repo.engine}}/pull/12226) [web_ui] add missing dispose handler for MethodCalls to flutter/platform_view [12227]({{site.repo.engine}}/pull/12227) [web_ui] PersistedPlatformView attribute update handling to enable resizing [12228]({{site.repo.engine}}/pull/12228) pin and auto-install chrome version [12229]({{site.repo.engine}}/pull/12229) Improve check to render (or not) a DRRect when inner falls outside of outer on RecordingCanvas [12249]({{site.repo.engine}}/pull/12249) Editable text fix [12253]({{site.repo.engine}}/pull/12253) Implement Base32Decode [12256]({{site.repo.engine}}/pull/12256) Do not assume Platform.script is a Dart source file during training. [12257]({{site.repo.engine}}/pull/12257) Re-enable ThreadChecker and fix associated failures [12258]({{site.repo.engine}}/pull/12258) Refactor and polish the 'felt' tool [12269]({{site.repo.engine}}/pull/12269) a11y: expose max character count for text fields [12273]({{site.repo.engine}}/pull/12273) Clean up after AppLifecycleTests [12274]({{site.repo.engine}}/pull/12274) Store screenshot test output as Cirrus artifacts; do fuzzy comparison of non-matching screenshot pixels [12275]({{site.repo.engine}}/pull/12275) Shuffle test order and repeat test runs once. [12281]({{site.repo.engine}}/pull/12281) optionally skip builds [12282]({{site.repo.engine}}/pull/12282) [flutter_runner] Change the path to artifacts [12287]({{site.repo.engine}}/pull/12287) Adds PluginRegistry to the C++ client wrapper API [12288]({{site.repo.engine}}/pull/12288) Include firefox in check to quote font families [12289]({{site.repo.engine}}/pull/12289) Fix flutter runner paths [12303]({{site.repo.engine}}/pull/12303) Add a build command to felt [12306]({{site.repo.engine}}/pull/12306) Fix the declaration of setSystemGestureExclusionRects to match the PlatformMessageHandler interface [12307]({{site.repo.engine}}/pull/12307) Cleanup in web_ui [12308]({{site.repo.engine}}/pull/12308) [flutter] Remove old A11y API's. [12318]({{site.repo.engine}}/pull/12318) Update canvaskit backend [12319]({{site.repo.engine}}/pull/12319) Add "type" to getDisplayRefreshRate protocol [12320]({{site.repo.engine}}/pull/12320) Fix continuous event polling in the GLFW event loop [12323]({{site.repo.engine}}/pull/12323) README for the felt tool [12330]({{site.repo.engine}}/pull/12330) Ensure DRRects without corners also draw. [12336]({{site.repo.engine}}/pull/12336) Check for index bounds in RTL handling for trailing whitespace runs. [12340]({{site.repo.engine}}/pull/12340) [flutter_runner] Do not use pre-builts just yet [12342]({{site.repo.engine}}/pull/12342) Update test to verify that secondary isolate gets shutdown before root isolate exits. [12343]({{site.repo.engine}}/pull/12343) [flutter_runner] Remove usages of shared snapshots from CC sources [12345]({{site.repo.engine}}/pull/12345) [flutter_runner] Port over the tuning advice for vulkan surface provider [12346]({{site.repo.engine}}/pull/12346) [flutter_runner] Move from runner context to component context [12347]({{site.repo.engine}}/pull/12347) [flutter_runner][async] Migrate dart/flutter to new async-loop APIs [12348]({{site.repo.engine}}/pull/12348) [flutter_runner] Port the new compilation trace from topaz [12349]({{site.repo.engine}}/pull/12349) [flutter_runner] Explicitly set |trace_skia| to false [12350]({{site.repo.engine}}/pull/12350) [flutter_runner] Port vulkan surface changes [12355]({{site.repo.engine}}/pull/12355) skip flaky test [12363]({{site.repo.engine}}/pull/12363) Track "mouse leave" event [12375]({{site.repo.engine}}/pull/12375) Sync dart_runner [12395]({{site.repo.engine}}/pull/12395) Update --dart-vm-flags whitelist to include --write-service-info and --sample-buffer-duration [12403]({{site.repo.engine}}/pull/12403) Don't send pointer events when the framework isn't ready yet [12410]({{site.repo.engine}}/pull/12410) Send TYPE_VIEW_FOCUSED for views with input focus. [12412]({{site.repo.engine}}/pull/12412) SkSL precompile [12426]({{site.repo.engine}}/pull/12426) Store fallback font names as a vector instead of a set. [12431]({{site.repo.engine}}/pull/12431) Interpret negative radii as 0 in recording_canvas.dart [12432]({{site.repo.engine}}/pull/12432) Work around Samsung keyboard issue [12434]({{site.repo.engine}}/pull/12434) delete golden files; switch to flutter/goldens [12435]({{site.repo.engine}}/pull/12435) add dart:html, dart:js, and dart:js_util to the copy of the Dart SDK used for analysis [12443]({{site.repo.engine}}/pull/12443) Force exit felt tool on sigint, sigterm [12446]({{site.repo.engine}}/pull/12446) Add support for JIT release mode [12447]({{site.repo.engine}}/pull/12447) Reflect selection changes in Firefox for text editing [12448]({{site.repo.engine}}/pull/12448) Make kDoNotResizeDimension public so framework can use it directly [12450]({{site.repo.engine}}/pull/12450) Adds support for 5 mouse buttons [12453]({{site.repo.engine}}/pull/12453) Adding Link SemanticsFlag [12454]({{site.repo.engine}}/pull/12454) Add .mskp file to binary format [12470]({{site.repo.engine}}/pull/12470) [web_ui] Check if a pointer is already down for the specific device [12479]({{site.repo.engine}}/pull/12479) Refactoring text_editing.dart [12563]({{site.repo.engine}}/pull/12563) Remove use of the blobs snapshot format from unittests [12565]({{site.repo.engine}}/pull/12565) Remove references to topaz [12573]({{site.repo.engine}}/pull/12573) [flutter_runner] Refactor thread_application pair to ActiveApplication [12618]({{site.repo.engine}}/pull/12618) Add isFocusable to SemanticsFlag [12681]({{site.repo.engine}}/pull/12681) Create a package-able incremental compiler [12695]({{site.repo.engine}}/pull/12695) Add onUnregistered callback in 'Texture' and 'FlutterTexture' [12698]({{site.repo.engine}}/pull/12698) [web_ui] Fixing invalid state bug for text editing [12699]({{site.repo.engine}}/pull/12699) Adding 'pub get' to the 'compile_xxxx.sh' in the Scenario app [12700]({{site.repo.engine}}/pull/12700) Add missing flag for embedder. [12701]({{site.repo.engine}}/pull/12701) Cleanup: Made a macro to assert ARC is enabled. [12706]({{site.repo.engine}}/pull/12706) Check for a null input method subtype [12708]({{site.repo.engine}}/pull/12708) Cleanup: Turned on NS_ASSUME_NONNULL_BEGIN for FlutterViewController. [12710]({{site.repo.engine}}/pull/12710) Set transparent background in textarea elements [12725]({{site.repo.engine}}/pull/12725) Expanded channel buffer resize to method channels. [12728]({{site.repo.engine}}/pull/12728) Remove unused import in the scenario app [12730]({{site.repo.engine}}/pull/12730) Stop setting the accessibility text if a node has SCOPES_ROUTE set. [12733]({{site.repo.engine}}/pull/12733) [flutter_runner] Make rd and rx uniform [12746]({{site.repo.engine}}/pull/12746) Send AccessibilityEvent.TYPE_VIEW_FOCUSED when input focus is set. [12754]({{site.repo.engine}}/pull/12754) Fix Metal builds by accounting for the updated SubmitFrame signature. [12775]({{site.repo.engine}}/pull/12775) Added some thread asserts to the code and made ios_surface_ safe since [12777]({{site.repo.engine}}/pull/12777) Fix Metal builds. [12780]({{site.repo.engine}}/pull/12780) Restart all modern Samsung keyboard IMM [12783]({{site.repo.engine}}/pull/12783) Add a unit-test to verify that root surface transformation affects platform view coordinates. [12785]({{site.repo.engine}}/pull/12785) Fix bug in package script and add dev_compiler to list [12793]({{site.repo.engine}}/pull/12793) Fixing selection issues in Firefox [12797]({{site.repo.engine}}/pull/12797) add option for bulk-updating screenshots; update screenshots (Work in progress [12798]({{site.repo.engine}}/pull/12798) [flutter_runner] Update the cmx files to include TZ support [12799]({{site.repo.engine}}/pull/12799) Disable EmbedderTest::CanLaunchAndShutdownMultipleTimes. [12800]({{site.repo.engine}}/pull/12800) Prettify all CMX files [12801]({{site.repo.engine}}/pull/12801) do not wrap font family name [12802]({{site.repo.engine}}/pull/12802) Build gen_snapshot with a 64-bit host toolchain even if the target platform is 32-bit [12808]({{site.repo.engine}}/pull/12808) Added an embedder example [12813]({{site.repo.engine}}/pull/12813) Unblock SIGPROF on flutter_tester start [12816]({{site.repo.engine}}/pull/12816) Enable sanitizer build variants. [12821]({{site.repo.engine}}/pull/12821) Update buildroot to pull in ubsan updates. [12931]({{site.repo.engine}}/pull/12931) remove references to package:_chrome [12958]({{site.repo.engine}}/pull/12958) Adding deviceId to KeyEventChannel enconding method [12960]({{site.repo.engine}}/pull/12960) Fix typo on channel buffer debug output. [12974]({{site.repo.engine}}/pull/12974) Support empty strings and vectors in standard codec [12980]({{site.repo.engine}}/pull/12980) Made _printDebug only happen on debug builds of the engine for now. [12982]({{site.repo.engine}}/pull/12982) Color matrix doc [12986]({{site.repo.engine}}/pull/12986) Prevent default when Tab is clicked [12988]({{site.repo.engine}}/pull/12988) Use the standard gen_snapshot target unless the platform requires host_targeting_host [12989]({{site.repo.engine}}/pull/12989) Unpublicize kDoNotResizeDimension [12991]({{site.repo.engine}}/pull/12991) Compile sanitizer suppressions list and file bugs as necessary. [12999]({{site.repo.engine}}/pull/12999) Started setting our debug background task id to invalid [13001]({{site.repo.engine}}/pull/13001) Missing link flag [13004]({{site.repo.engine}}/pull/13004) Allow embedders to disable causal async stacks in the Dart VM [13005]({{site.repo.engine}}/pull/13005) Auto-formatter fixes for [BUILD.gn](http://build.gn/) files [13008]({{site.repo.engine}}/pull/13008) Integration with more of Skia's SkShaper/SkParagraph APIs [13009]({{site.repo.engine}}/pull/13009) Fixing Link Semantics Typo [13015]({{site.repo.engine}}/pull/13015) Fire PlatformViewController FlutterView callbacks [13042]({{site.repo.engine}}/pull/13042) Add "felt clean" command [13043]({{site.repo.engine}}/pull/13043) Add a task runner for the Win32 embedding [13044]({{site.repo.engine}}/pull/13044) Support keyboard types on mobile browsers [13047]({{site.repo.engine}}/pull/13047) Allow embedders to specify arbitrary data to the isolate on launch. [13049]({{site.repo.engine}}/pull/13049) Ignore thread leaks from Dart VM in tsan instrumented builds. [13053]({{site.repo.engine}}/pull/13053) Set the Cirrus badge to only display status of the master branch. [13056]({{site.repo.engine}}/pull/13056) Put Metal renderer selection behind runtime flag and plist opt-in. [13071]({{site.repo.engine}}/pull/13071) [dart_aot_runner] Add support for generating dart_aot snapshots [13074]({{site.repo.engine}}/pull/13074) [dart_aot_runner] Add rules to generate dart_aot binaries [13082]({{site.repo.engine}}/pull/13082) java imports/style [13085]({{site.repo.engine}}/pull/13085) Print more output when gen_package fails [13086]({{site.repo.engine}}/pull/13086) Gen package output corrected [13088]({{site.repo.engine}}/pull/13088) felt: use rest args for specifying test targets [13089]({{site.repo.engine}}/pull/13089) cleanup gen_package.py [13090]({{site.repo.engine}}/pull/13090) Snapshot the felt tool for faster start-up [13091]({{site.repo.engine}}/pull/13091) Remove persistent cache unittest timeout [13094]({{site.repo.engine}}/pull/13094) Integrate more SkParagraph builder patches [13096]({{site.repo.engine}}/pull/13096) [dart_aot_runner] Use the host_toolchain to build kernels [13097]({{site.repo.engine}}/pull/13097) Update felt README [13101]({{site.repo.engine}}/pull/13101) [dart_aot_runner] Generate vmservice aotsnapshots [13103]({{site.repo.engine}}/pull/13103) [dart_aot_runner] Complete the port of dart_aot_runner [13121]({{site.repo.engine}}/pull/13121) Change IO thread shader cache strategy [13122]({{site.repo.engine}}/pull/13122) refactoring chrome_installer [13123]({{site.repo.engine}}/pull/13123) Upgrades the ICU version to 64.2 [13124]({{site.repo.engine}}/pull/13124) Allow embedders to specify a render task runner description. [13125]({{site.repo.engine}}/pull/13125) add the dart:__interceptors library to the dart sdk [13126]({{site.repo.engine}}/pull/13126) [frontend_server] Include bytecode generation in the training run. [13143]({{site.repo.engine}}/pull/13143) Add flutter_tester binary to the CIPD package [13144]({{site.repo.engine}}/pull/13144) Document //flutter/runtime/dart_vm [13151]({{site.repo.engine}}/pull/13151) Remove incomplete static thread safety annotations. [13153]({{site.repo.engine}}/pull/13153) Make the Dart isolate constructor private. [13154]({{site.repo.engine}}/pull/13154) Fix an output file path for the frontend server package_incremental script [13157]({{site.repo.engine}}/pull/13157) Fix type error in SkVertices [13159]({{site.repo.engine}}/pull/13159) Move surface-based SceneBuilder implementation under surface/ [13162]({{site.repo.engine}}/pull/13162) Document //flutter/runtime/dart_isolate.h [13175]({{site.repo.engine}}/pull/13175) Remove redundant call to updateEditingState in sendKeyEvent [13176]({{site.repo.engine}}/pull/13176) Add repeatCount to FlutterKeyEvent [13177]({{site.repo.engine}}/pull/13177) Update compiler to Clang 10. [13182]({{site.repo.engine}}/pull/13182) If we get a 'down' event, add that device to the active devices. [13185]({{site.repo.engine}}/pull/13185) Adding firefox_installer.dart [13192]({{site.repo.engine}}/pull/13192) Use window.devicePixelRatio in the CanvasKit backend [13193]({{site.repo.engine}}/pull/13193) Custom compositor layers must take into account the device pixel ratio. [13196]({{site.repo.engine}}/pull/13196) Document //flutter/runtime/dart_snapshot.h [13207]({{site.repo.engine}}/pull/13207) Wrap the text in text editing to fix selections. [13209]({{site.repo.engine}}/pull/13209) Preserve stdout colors of subprocesses run by felt [13212]({{site.repo.engine}}/pull/13212) Add trace events around custom compositor callbacks. [13218]({{site.repo.engine}}/pull/13218) Specify a human readable reason for an error from the embedder API. [13232]({{site.repo.engine}}/pull/13232) Avoid dereferencing IO manager weak pointers on the UI thread [13237]({{site.repo.engine}}/pull/13237) Do not attempt to drain the SkiaUnrefQueue in the destructor [13238]({{site.repo.engine}}/pull/13238) Allow embedders to update preferrred locales. [13239]({{site.repo.engine}}/pull/13239) Hold a reference to the Skia unref queue in UIDartState [13240]({{site.repo.engine}}/pull/13240) Update CanvasKit to 0.7.0 and flesh out painting [13241]({{site.repo.engine}}/pull/13241) Ignore *.obj files when gathering licenses [13242]({{site.repo.engine}}/pull/13242) Update harfbuzz to 2.6.2, Roll buildroot to a518e [13255]({{site.repo.engine}}/pull/13255) Fix NPE in accessibility bridge [13261]({{site.repo.engine}}/pull/13261) Updated license script to ignore testdata directories [13265]({{site.repo.engine}}/pull/13265) Ensure we call into Engine from the UI taskrunner in Shell::EngineHasLivePorts() [13269]({{site.repo.engine}}/pull/13269) Send flag modified events to the framework [13270]({{site.repo.engine}}/pull/13270) Add recipe changelog [13274]({{site.repo.engine}}/pull/13274) Fix decode feature detection in HtmlCodec [13275]({{site.repo.engine}}/pull/13275) Flesh out the CanvasKit backend some more [13292]({{site.repo.engine}}/pull/13292) Disable flaky test ShellTest_ReportTimingsIsCalled. [13295]({{site.repo.engine}}/pull/13295) Avoid accessing the Cocoa view on the GPU or IO task runners. [13311]({{site.repo.engine}}/pull/13311) [recipe] Upload opt flutter_tester [13314]({{site.repo.engine}}/pull/13314) Guarding EAGLContext used by Flutter [13319]({{site.repo.engine}}/pull/13319) Add FlutterEngineRunsAOTCompiledDartCode to the embedder API. [13321]({{site.repo.engine}}/pull/13321) Pass LinearTextFlag to SkFont - iOS13 letter spacing [13337]({{site.repo.engine}}/pull/13337) Bump dart/language_model to 9fJQZ0TrnAGQKrEtuL3-AXbUfPzYxqpN_OBHr9P4hE4C [13342]({{site.repo.engine}}/pull/13342) Intercept SystemSound.play platform message before it's sent. [13345]({{site.repo.engine}}/pull/13345) Expose platform view ID on embedder semantics node [13360]({{site.repo.engine}}/pull/13360) Turn on RasterCache based on view hierarchy [13361]({{site.repo.engine}}/pull/13361) Expand on CanvasKit backend more [13364]({{site.repo.engine}}/pull/13364) [flutter_runner] Remove the checks for libdart profiler symbols [13367]({{site.repo.engine}}/pull/13367) Delay metal drawable acquisition till frame submission. [13391]({{site.repo.engine}}/pull/13391) Implement basic Picture.toImage via BitmapCanvas [13395]({{site.repo.engine}}/pull/13395) fix fml_unittes is not run during presubmit [13397]({{site.repo.engine}}/pull/13397) [flutter_runner] Don't build far files twice [13401]({{site.repo.engine}}/pull/13401) Reformat [BUILD.gn](http://build.gn/) files to comply with the format checker presubmit script [13405]({{site.repo.engine}}/pull/13405) Make sure root surface transformations survive resetting the matrix directly in Flow. [13406]({{site.repo.engine}}/pull/13406) Fix the dry run mode of the GN format checker script [13407]({{site.repo.engine}}/pull/13407) Kick luci [13419]({{site.repo.engine}}/pull/13419) [dart_runner] Common libs need to exist for aot runner [13424]({{site.repo.engine}}/pull/13424) Add isRunningInRobolectricTest back [13440]({{site.repo.engine}}/pull/13440) Switch to Cirrus Dockerfile as CI [13444]({{site.repo.engine}}/pull/13444) Remove usage of yaml module from CIPD script [13448]({{site.repo.engine}}/pull/13448) Duplicate the directory fd in fml::VisitFiles [13451]({{site.repo.engine}}/pull/13451) Fix mDNS for iOS13 [13460]({{site.repo.engine}}/pull/13460) [dart] Makes the intl services available [13461]({{site.repo.engine}}/pull/13461) CIPD needs the directory to be relative [13464]({{site.repo.engine}}/pull/13464) [recipe] Upload sky_engine to CIPD [13468]({{site.repo.engine}}/pull/13468) Pass the automaticallyRegisterPlugins flag to the FlutterEngine constructor in FlutterActivityTest [13478]({{site.repo.engine}}/pull/13478) use check_output instead of check_call [13479]({{site.repo.engine}}/pull/13479) Print the output [13630]({{site.repo.engine}}/pull/13630) Fix bug where Enter doesn't add new line in multi-line fields [13642]({{site.repo.engine}}/pull/13642) Issues/39832 reland [13643]({{site.repo.engine}}/pull/13643) Ensure that the CAMetalLayer FBO attachments can be read from. [13649]({{site.repo.engine}}/pull/13649) Add 'Cough' test font and support multiple test fonts. [13695]({{site.repo.engine}}/pull/13695) Fix Class.forName unchecked call warning [13697]({{site.repo.engine}}/pull/13697) Moves pointer event sanitizing to engine. [13708]({{site.repo.engine}}/pull/13708) Ensure that the device pixel ratio is taken into account with window metrics in physical pixels. [13710]({{site.repo.engine}}/pull/13710) Fix picture raster cache throttling [13711]({{site.repo.engine}}/pull/13711) Imagefilter wrapper object [13719]({{site.repo.engine}}/pull/13719) Fix NPE in splash screen lookup [13727]({{site.repo.engine}}/pull/13727) Add line boundary information to LineMetrics. [13728]({{site.repo.engine}}/pull/13728) Prefer SchedulerBinding.addTimingsCallback [13731]({{site.repo.engine}}/pull/13731) Expose the platform view mutator stack to custom compositors. [13735]({{site.repo.engine}}/pull/13735) Cleanup obsolete --strong option of front-end server [13736]({{site.repo.engine}}/pull/13736) libtxt: pass an RTL bool flag instead of a bidiFlags enum to measureText [13742]({{site.repo.engine}}/pull/13742) Only specify --no-link-platform when not specifying --aot, roll dart-lang sdk [13744]({{site.repo.engine}}/pull/13744) Create a new picture recorder even when the embedder supplied render target is recycled. [13747]({{site.repo.engine}}/pull/13747) Move TextRange from the framework to dart:ui. [13760]({{site.repo.engine}}/pull/13760) Implement Path.computeMetrics in the CanvasKit backend [13762]({{site.repo.engine}}/pull/13762) Turn on RasterCache based on view hierarchy [13765]({{site.repo.engine}}/pull/13765) Change wordBoundary to take dynamic temporarily [13768]({{site.repo.engine}}/pull/13768) Add ImageFilter and BackdropFilter to CanvasKit backend [13772]({{site.repo.engine}}/pull/13772) Move Path and PathMetrics from canvas.dart into their own files. No delta [13780]({{site.repo.engine}}/pull/13780) Allow passing hot reload debugging flags through [13781]({{site.repo.engine}}/pull/13781) Create a WeakPtrFactory for use on the UI thread in VsyncWaiter [13782]({{site.repo.engine}}/pull/13782) Document the coordinate space of points in FlutterPointerEvent. [13784]({{site.repo.engine}}/pull/13784) Add Helvetica and sans-serif as fallback font families [13785]({{site.repo.engine}}/pull/13785) Fix RendererContextSwitch result check in Rasterizer::MakeRasterSnapshot [13786]({{site.repo.engine}}/pull/13786) Take devicePixelRatio into account when drawing shadows [13795]({{site.repo.engine}}/pull/13795) Adds missing comma in EngineParagraphStyle.toString() [13796]({{site.repo.engine}}/pull/13796) implement radial gradient in canvaskit backend [13799]({{site.repo.engine}}/pull/13799) Update version of dart/language_model distributed with flutter engine to latest [13803]({{site.repo.engine}}/pull/13803) [build] Make --engine-version flag optional [13805]({{site.repo.engine}}/pull/13805) Remove extra shadows from ParagraphStyle [13812]({{site.repo.engine}}/pull/13812) RendererContextSwitch guard flutter's gl context rework. [13829]({{site.repo.engine}}/pull/13829) [dart_runner] Initialize logging and tracing [13832]({{site.repo.engine}}/pull/13832) Remove unused import [13848]({{site.repo.engine}}/pull/13848) Use Skia's matchStyleCSS3 to find bundled asset typefaces matching a font style [13850]({{site.repo.engine}}/pull/13850) Fix test to account for pixel ratio transformations being framework responsibility. [13851]({{site.repo.engine}}/pull/13851) Implement the rest of ui.Path methods for CanvasKit [13869]({{site.repo.engine}}/pull/13869) Changing test runner and platform to be browser independent [13881]({{site.repo.engine}}/pull/13881) Change edge conditions of getLineBoundary [13902]({{site.repo.engine}}/pull/13902) Adding opacity -> alpha method to Color class [13903]({{site.repo.engine}}/pull/13903) Implement basic text rendering support in CanvasKit backend [13904]({{site.repo.engine}}/pull/13904) Fix withIn matcher distance function lookup [13907]({{site.repo.engine}}/pull/13907) allow ignoring toString, hashCode, and == in api_conform_test [13908]({{site.repo.engine}}/pull/13908) Made a way to turn off the OpenGL operations on the IO thread for backgrounded apps [13918]({{site.repo.engine}}/pull/13918) Add virtual destructor to GPUSurfaceSoftwareDelegate. [13926]({{site.repo.engine}}/pull/13926) Add dev_compiler and frontend_server to package uploading rule [13934]({{site.repo.engine}}/pull/13934) Ensure we use the base CompositorContext's AcquireFrame method when screenshotting [13943]({{site.repo.engine}}/pull/13943) Made the thread checker print out the thread names on Apple platforms. [13945]({{site.repo.engine}}/pull/13945) Update SwiftShader to 5d1e854. [13962]({{site.repo.engine}}/pull/13962) Added auto-reviewer config file [13975]({{site.repo.engine}}/pull/13975) Refactor to passing functions by const ref [14082]({{site.repo.engine}}/pull/14082) add pointer data santizing in flutter web engine ## Plugins We have made significant improvements in our plugins. We upgraded a set of plugins to support web development. Also, to support Add to App scenarios, we have a new set of APIs available for existing Android plugins to be upgraded to. If you are currently maintaining an Android plugin. We encourage you to check the [Migrating your plugin to the new APIs][] documentation, and upgrade your plugins accordingly. [Migrating your plugin to the new APIs]: /release/breaking-changes/plugin-api-migration [1984]({{site.github}}/flutter/plugins/pull/1984) Remove Flutterfire plugins (moved to FirebaseExtended) [2004]({{site.github}}/flutter/plugins/pull/2004) [cirrus] Use flutter create for all_plugins test [2009]({{site.github}}/flutter/plugins/pull/2009) Fix unit test for sensors [2036]({{site.github}}/flutter/plugins/pull/2036) video player version fix [2055]({{site.github}}/flutter/plugins/pull/2055) Point opensource site at new location [2084]({{site.github}}/flutter/plugins/pull/2084) [update] local_auth - intl version [2112]({{site.github}}/flutter/plugins/pull/2112) Run flutter_plugin_tools format [2141]({{site.github}}/flutter/plugins/pull/2141) BugFix: formatHint was meant for network streams. [2154]({{site.github}}/flutter/plugins/pull/2154) Use stable Flutter image as base [2161]({{site.github}}/flutter/plugins/pull/2161) Rename instrumentation_adapter plugin to e2e plugin [2205]({{site.github}}/flutter/plugins/pull/2205) s/flutter_android_lifecycle/flutter_plugin_android_lifecycle/ [2230]({{site.github}}/flutter/plugins/pull/2230) Forbid ... implements UrlLauncherPlatform [2231]({{site.github}}/flutter/plugins/pull/2231) [cleanup] Remove AndroidX warning [2236]({{site.github}}/flutter/plugins/pull/2236) Use package import to import files inside lib/ directory. [2250]({{site.github}}/flutter/plugins/pull/2250) Run the publish with the pub version from flutter stable [2260]({{site.github}}/flutter/plugins/pull/2260) Make setMockInitialValues handle non-prefixed keys [2267]({{site.github}}/flutter/plugins/pull/2267) Bump google_maps_flutter pubspec version to match CHANGELOG [2271]({{site.github}}/flutter/plugins/pull/2271) [infra] Ignore analyzer issues in CI [2280]({{site.github}}/flutter/plugins/pull/2280) Add google_sign_in_web plugin. #### Plugin: Android Alarm Manager We added the ability to get id in the callback in the Android Alarm Manager plugin. [1985]({{site.github}}/flutter/plugins/pull/1985) [android_alarm_manager] Added ability to get id in the callback #### Plugin: Android Intent We made several improvements in the Android Intent plugin including adding the ability to pass intent flags (contributed by a community member!), and upgrading it to the [new plugin API][]. [new plugin API]: /release/breaking-changes/plugin-api-migration [2000]({{site.github}}/flutter/plugins/pull/2000) [android_intent] add flags option [2045]({{site.github}}/flutter/plugins/pull/2045) [android_intent] Add action_application_details_settings [2143]({{site.github}}/flutter/plugins/pull/2143) [android_intent] Migrate to the new embedding [2188]({{site.github}}/flutter/plugins/pull/2188) [android_intent] Bump the Flutter SDK min version [2202]({{site.github}}/flutter/plugins/pull/2202) [android_intent] componentName must be provided before resolveActivity is called [2221]({{site.github}}/flutter/plugins/pull/2221) [android_intent]remove AndroidX constraint [2268]({{site.github}}/flutter/plugins/pull/2268) [android_intent] Add missing DartDocs #### Plugin: Battery General bug fix in the Battery plugin. [2189]({{site.github}}/flutter/plugins/pull/2189) [battery] relax the example app minimal required Flutter version #### Plugin: Camera We upgraded the Camera plugin to the [new plugin API][], and made some bug fixes. [2057]({{site.github}}/flutter/plugins/pull/2057) [Camera] Fixes NullPointerException [2123]({{site.github}}/flutter/plugins/pull/2123) [camera] Fix event type check [2219]({{site.github}}/flutter/plugins/pull/2219) [camera]remove androidx constraint #### Plugin: Connectivity General bug fixes in the Connectivity plugin. [2212]({{site.github}}/flutter/plugins/pull/2212) [connectivity]remove AndroidX constraint [2262]({{site.github}}/flutter/plugins/pull/2262) [connectivity] add more documentations, delete example/README #### Plugin: e2e General bug fixes in the e2e plugin. [2022]({{site.github}}/flutter/plugins/pull/2022) [instrumentation_adapter] Update README instructions [2023]({{site.github}}/flutter/plugins/pull/2023) [instrumentation_adapter] update boilerplate to use @Rule instead of FlutterTest [2024]({{site.github}}/flutter/plugins/pull/2024) [instrumentation_adapter] update CODEOWNERS [2051]({{site.github}}/flutter/plugins/pull/2051) [instrumentation_adapter] update for release [2075]({{site.github}}/flutter/plugins/pull/2075) [instrumentation_adapter] Migrate example to AndroidX [2178]({{site.github}}/flutter/plugins/pull/2178) [e2e] update README [2190]({{site.github}}/flutter/plugins/pull/2190) [e2e] Update to support new embedder [2233]({{site.github}}/flutter/plugins/pull/2233) [e2e] update README #### Plugin: Google Maps Flutter We have made several improvements in the Google Maps plugin including adding support for displaying the traffic layer. [1702]({{site.github}}/flutter/plugins/pull/1702) [google_maps_flutter]Marker drag event [1767]({{site.github}}/flutter/plugins/pull/1767) [google_maps_flutter] Adds support for displaying the traffic layer [1784]({{site.github}}/flutter/plugins/pull/1784) [google_maps_flutter] Allow (de-)serialization of CameraPosition [1933]({{site.github}}/flutter/plugins/pull/1933) [google_maps_flutter] Avoid unnecessary redraws [2053]({{site.github}}/flutter/plugins/pull/2053) [google_maps_flutter] Fix analyzer failures relating to prefer_const_constructors [2065]({{site.github}}/flutter/plugins/pull/2065) [google_maps_flutter] Prefer const constructors. [2076]({{site.github}}/flutter/plugins/pull/2076) [google_maps_flutter] Clone cached elements in GoogleMap [2108]({{site.github}}/flutter/plugins/pull/2108) [google_maps_flutter] Add Projection methods to google_maps [2113]({{site.github}}/flutter/plugins/pull/2113) [google_maps_flutter] Avoid AbstractMethod crash [2242]({{site.github}}/flutter/plugins/pull/2242) [google_maps_flutter] Cast error.code to unsigned long to avoid using NSInteger as %ld format warnings. #### Plugin: Google Sign In We made some bug fixes in Google Sign in plugin. Meanwhile, we converted it to a federated plugin to help it scale more efficiently to multiple platforms. For more information, refer to [Federated plugins][]. [Federated plugins]: /packages-and-plugins/developing-packages#federated-plugins [2059]({{site.github}}/flutter/plugins/pull/2059) [google_sign_in] Fix chained async methods in error handling zones [2127]({{site.github}}/flutter/plugins/pull/2127) [google_sign_in] Fix deprecated API usage issue by upgrading CocoaPod to 5.0 [2244]({{site.github}}/flutter/plugins/pull/2244) [google_sign_in] Move plugin to its subdir to allow for federated implementations [2252]({{site.github}}/flutter/plugins/pull/2252) [google_sign_in] Handle new style URLs in GoogleUserCircleAvatar [2266]({{site.github}}/flutter/plugins/pull/2266) [google_sign_in] Port plugin to use the federated Platform Interface #### Plugin: Image Picker General bug fixes in the Image Picker plugin. [2070]({{site.github}}/flutter/plugins/pull/2070) [image_picker] swap width and height when source image orientation is left or right [2293]({{site.github}}/flutter/plugins/pull/2293) [image_picker]fix a crash when a non-image file is picked. #### Plugin: In App Purchase General bug fixes in the In App Purchase plugin. [2014]({{site.github}}/flutter/plugins/pull/2014) [In_App_Purchase] Avoids possible NullPointerException with background registrations. [2016]({{site.github}}/flutter/plugins/pull/2016) [In_App_Purchase] Improve testability [2027]({{site.github}}/flutter/plugins/pull/2027) [in_app_purchase] Remove skipped driver test [2215]({{site.github}}/flutter/plugins/pull/2215) [in_app_purchase] remove AndroidX constraint #### Plugin: Local Auth General bug fixes in the Local Auth plugin. [2047]({{site.github}}/flutter/plugins/pull/2047) [local_auth] Avoid user confirmation on face unlock [2111]({{site.github}}/flutter/plugins/pull/2111) [local_auth] Api to stop authentication #### Plugin: Package Info General bug fixes in the Package Info plugin. [2218]({{site.github}}/flutter/plugins/pull/2218) [package_info]remove AndroidX constraint #### Plugin: Path Provider In the Path Provider plugin, we added getApplicationLibraryDirectory, which is contributed by a community member! [1953]({{site.github}}/flutter/plugins/pull/1953) [path_provider] add getApplicationLibraryDirectory [1993]({{site.github}}/flutter/plugins/pull/1993) [pathprovider] Fix fall through bug [2288]({{site.github}}/flutter/plugins/pull/2288) [path_provider] Add missing DartDocs #### Plugin: Share Documentation update in the Share plugin. [2297]({{site.github}}/flutter/plugins/pull/2297) [share] README update #### Plugin: Shared Preferences General bug fixes in the Shared Preferences plugin. [2241]({{site.github}}/flutter/plugins/pull/2241) [Shared_preferences]suppress warnings [2296]({{site.github}}/flutter/plugins/pull/2296) [shared_preferences] Add missing DartDoc #### Plugin: Url launcher We upgraded the Url launcher plugin to the [new plugin API][], and fixed some bugs. Meanwhile, we have converted the Url launcher into a federated plugin to help it scale more efficiently to multiple platforms. For more information, refer to [Federated plugins][]. [2038]({{site.github}}/flutter/plugins/pull/2038) [url_launcher] Removed reference to rootViewController during initialization [2136]({{site.github}}/flutter/plugins/pull/2136) [url_launcher_web] Fix [README.md](http://readme.md/) pubspec example [2217]({{site.github}}/plugins/pull/2217) [url_launcher] Add url_launcher_platform_interface package [2220]({{site.github}}/flutter/plugins/pull/2220) [url_launcher]remove AndroidX constraint [2228]({{site.github}}/flutter/plugins/pull/2228) [url_launcher] Use url_launcher_platform_interface to handle calls [2237]({{site.github}}/flutter/plugins/pull/2237) [url_launcher] Migrate url_launcher_web to the platform interface [2274]({{site.github}}/flutter/plugins/pull/2274) [url_launcher] DartDoc and test improvements #### Plugin: Video Player We upgraded the Video Player plugin to the [new plugin API][], and made some bug fixes. Meanwhile, we have converted it into a federated plugin to help it scale more efficiently to multiple platforms. For more information, refer to [Federated plugins][]. [1813]({{site.github}}/flutter/plugins/pull/1813) [video-player] add support for content uris as urls [1998]({{site.github}}/flutter/plugins/pull/1998) [video_player] Fix deprecated member use [2124]({{site.github}}/flutter/plugins/pull/2124) [video_player] Move [player dispose] to onUnregistered [2158]({{site.github}}/flutter/plugins/pull/2158) [video_player] Basic test for VideoPlayerController initialization [2273]({{site.github}}/flutter/plugins/pull/2273) [video_player] Add platform interface [2286]({{site.github}}/flutter/plugins/pull/2286) [video_player] Improve DartDocs and test coverage #### Plugin: Webview Flutter We upgraded the Webview Flutter plugin to the [new plugin API][], and made some bug fixes. [1996]({{site.github}}/flutter/plugins/pull/1996) [webview_flutter] Allow underscores anywhere for Javascript Channel name [2257]({{site.github}}/flutter/plugins/pull/2257) [webview_flutter] Add async NavigationDelegates ## Tooling Flutter tooling is another big investment in this release. We launched a new version of [DartPad](http://dartpad.dev) that allows you to play with Flutter directly in your browser without installing anything, released a new feature "Hot UI" (in preview) that allows you to interact with widgets directly in the IDE, enhanced Dart DevTools with a new visual layout view, enabled simultaneous multi-device debugging in Visual Studio Code, and added support for "golden" image testing. In addition to the PRs listed below, please also check out the following releases for the IntelliJ and Android Studio Flutter plugin, the VS Code Flutter plugin and Dart DevTools: ### VS Code * 10/1/2019: [dartcode.org/releases/v3-5/](https://dartcode.org/releases/v3-5/) * 11/1/2019: [dartcode.org/releases/v3-6/](https://dartcode.org/releases/v3-6/) * 12/5/2019: [dartcode.org/releases/v3-7/](https://dartcode.org/releases/v3-7/) ### Flutter IntelliJ and Android Studio plugin * 10/1/2019: Flutter IntelliJ Plugin [M40 Release](https://groups.google.com/d/msg/flutter-dev/s2AxzJ2TbkU/RC3S508rBwAJ) * 11/1/2019: Flutter IntelliJ Plugin [M41 Release](https://groups.google.com/d/msg/flutter-dev/4TSSi_niovs/piNoRPr6EgAJ) * 12/5/2019: Flutter IntelliJ Plugin [M42 Release](https://groups.google.com/forum/#!topic/flutter-announce/EmOelPrGwGo) ### DevTools * 10/2/2019: New Dart DevTools [Release 0.1.8](https://groups.google.com/d/msg/flutter-dev/J6zDXzZOsts/vOWn7mcWCgAJ) * 10/17/2019: New Dart DevTools [Release 0.1.9](https://groups.google.com/d/msg/flutter-dev/WuzEEENGsXU/zb0IDhkhDgAJ) * 11/8/2019: New Dart DevTools [Release 0.1.11](https://groups.google.com/d/msg/flutter-dev/VdAni_rhpS4/UP3mBH-2AAAJ) * 12/6/2019: New Dart DevTools [Release 0.1.12](https://groups.google.com/forum/#!topic/flutter-dev/EGLBgQAOoC8) ### Tooling PRs [37508]({{site.repo.flutter}}/pull/37508) build bundle with assemble [37642]({{site.repo.flutter}}/pull/37642) Unit test for build.dart::GenSnapshot [37832]({{site.repo.flutter}}/pull/37832) add --exit and --match-host-platform defaults to devicelab runner [37845]({{site.repo.flutter}}/pull/37845) echo error messages to stderr [38560]({{site.repo.flutter}}/pull/38560) refactor cocoapods validator to detect broken install [38576]({{site.repo.flutter}}/pull/38576) flutter_tools/version: git log.showSignature=false [38632]({{site.repo.flutter}}/pull/38632) Flutter Plugin Tool supports multi-platform plugin config [38654]({{site.repo.flutter}}/pull/38654) [flutter_tool] Remove some async file io [38869]({{site.repo.flutter}}/pull/38869) Store file hashes per build configuration. [38894]({{site.repo.flutter}}/pull/38894) [flutter_tool] Move http request close under try-catch [38907]({{site.repo.flutter}}/pull/38907) Throw error when hot reload enters bad state [38920]({{site.repo.flutter}}/pull/38920) [flutter_tool] Handle crashes from doctor validators [38925]({{site.repo.flutter}}/pull/38925) [flutter_tool] Only send one crash report per run [38932]({{site.repo.flutter}}/pull/38932) Add build warning for non-debug desktop builds [39000]({{site.repo.flutter}}/pull/39000) Dont throw StateError when calling assemble [39005]({{site.repo.flutter}}/pull/39005) [flutter_tool] Teach crash reporter about HttpException [39013]({{site.repo.flutter}}/pull/39013) Update package versions to latest [39052]({{site.repo.flutter}}/pull/39052) Make forward calls run interactively [39136]({{site.repo.flutter}}/pull/39136) [flutter_tool] Some additional input validation for 'version' [39140]({{site.repo.flutter}}/pull/39140) Move commands into their own shard [39147]({{site.repo.flutter}}/pull/39147) Downgrade the AndroidX warning [39274]({{site.repo.flutter}}/pull/39274) Use output dir instead of specific paths in assemble rules [39280]({{site.repo.flutter}}/pull/39280) [flutter_tool] Use a timeout for xcode showBuildSettings [39358]({{site.repo.flutter}}/pull/39358) surface errors from build runner [39445]({{site.repo.flutter}}/pull/39445) [flutter_tool] Add onError callback to asyncGuard. Use it in Doctor [39524]({{site.repo.flutter}}/pull/39524) Register flutterVersion service in flutter_tools. [39530]({{site.repo.flutter}}/pull/39530) keep symbols for profile [39541]({{site.repo.flutter}}/pull/39541) Handle single unsupported device [39555]({{site.repo.flutter}}/pull/39555) Use feature flags to control build command visibility [39558]({{site.repo.flutter}}/pull/39558) Filter error message from skip build script checks [39579]({{site.repo.flutter}}/pull/39579) [flutter_tools] Add a timeout to another showBuildSettings command [39654]({{site.repo.flutter}}/pull/39654) Use persisted build information to automatically clean old outputs [39699]({{site.repo.flutter}}/pull/39699) Detecting when installing over MingW's Git Bash, fixing paths [39781]({{site.repo.flutter}}/pull/39781) Add lib/generated_plugin_registrant.dart to gitignore [39782]({{site.repo.flutter}}/pull/39782) Allow specifying a project for Xcode getInfo [39899]({{site.repo.flutter}}/pull/39899) [flutter_tool] process.dart cleanup [39997]({{site.repo.flutter}}/pull/39997) Remove visibleForTesting annotation; this constructor is used outside… [40029]({{site.repo.flutter}}/pull/40029) [BUG] Process all children of intent-filter instead of just the first one to identify default activity [40131]({{site.repo.flutter}}/pull/40131) ensure we use pub from flutter SDK [40159]({{site.repo.flutter}}/pull/40159) [flutter_tool] Kill a timing-out process before trying to drain its streams [40171]({{site.repo.flutter}}/pull/40171) Place hot reload artifacts in a temp directory [40195]({{site.repo.flutter}}/pull/40195) Make Swift plugin template swift-format compliant [40210]({{site.repo.flutter}}/pull/40210) make sure we launch with dwds [40259]({{site.repo.flutter}}/pull/40259) remove io and isolate from libraries [40366]({{site.repo.flutter}}/pull/40366) Place existing dill into hot reload temp directory to boost initialization time [40368]({{site.repo.flutter}}/pull/40368) ensure dart2js does not compile unsupported packages [40397]({{site.repo.flutter}}/pull/40397) Adds list required components when VS is not installed [40410]({{site.repo.flutter}}/pull/40410) Remove fluter tool usage of protobuf [40435]({{site.repo.flutter}}/pull/40435) [flutter_tool] Remove the synchronous -showBuildSettings [40472]({{site.repo.flutter}}/pull/40472) Dont kill other processes when starting desktop application [40783]({{site.repo.flutter}}/pull/40783) ensure debug builds are only accessible through run [40795]({{site.repo.flutter}}/pull/40795) Update toolchain description to request the latest version [40968]({{site.repo.flutter}}/pull/40968) add missing trailing commas in flutter_tools [40988]({{site.repo.flutter}}/pull/40988) [flutter_tool] Report rss high watermark in command analytics events [41224]({{site.repo.flutter}}/pull/41224) fix flutter error report correct local widget [41304]({{site.repo.flutter}}/pull/41304) [flutter_tools] Allows adding multiple signal handlers [41401]({{site.repo.flutter}}/pull/41401) Flutter build bundle without --precompiled should always perform a debug build. [41406]({{site.repo.flutter}}/pull/41406) Retry devfs uploads in case they fail. [41424]({{site.repo.flutter}}/pull/41424) Don't update last compiled time when compilation is rejected [41447]({{site.repo.flutter}}/pull/41447) Switch to assemble API for dart2js [41493]({{site.repo.flutter}}/pull/41493) [flutter_tool] Report to analytics when the tool is killed by a signal [41514]({{site.repo.flutter}}/pull/41514) Ensure we find dart.exe on local engines [41519]({{site.repo.flutter}}/pull/41519) Make desktop stopApp only apply to processes Flutter started [41583]({{site.repo.flutter}}/pull/41583) Add debugging option to write vmservice address to file after starting [41610]({{site.repo.flutter}}/pull/41610) track unused inputs in build_runner [41621]({{site.repo.flutter}}/pull/41621) change logging in mDNS discovery to verbose-mode only [41652]({{site.repo.flutter}}/pull/41652) [flutter_tools] Add more info to pub get failure event [41687]({{site.repo.flutter}}/pull/41687) Use processManager.run() instead of manually capturing streams in test_utils getPackages() [41697]({{site.repo.flutter}}/pull/41697) Handle missing .packages file in the flutter tool for prebuilt artifacts [41735]({{site.repo.flutter}}/pull/41735) handle empty entry in asset list and add more explicit validation [41751]({{site.repo.flutter}}/pull/41751) Add support for downloading x86 JIT release artifact [41788]({{site.repo.flutter}}/pull/41788) Reduce log verbosity by removing individual used files [41832]({{site.repo.flutter}}/pull/41832) Plumb --enable-asserts through to frontend_server invocation in debug… [41862]({{site.repo.flutter}}/pull/41862) Make output directory a build input [41989]({{site.repo.flutter}}/pull/41989) Flutter doctor should require java 1.8+ [42008]({{site.repo.flutter}}/pull/42008) Restructure ProjectFileInvalidator.findInvalidated a bit [42016]({{site.repo.flutter}}/pull/42016) [flutter_tool] Re-work analytics events to use labels and values [42026]({{site.repo.flutter}}/pull/42026) Stop leaking iproxy processes [42028]({{site.repo.flutter}}/pull/42028) Make ProjectFileInvalidator.findInvalidated able to use the async FileStat.stat [42187]({{site.repo.flutter}}/pull/42187) Be more verbose when pub fails [42209]({{site.repo.flutter}}/pull/42209) Add error logging to flutter generate [42243]({{site.repo.flutter}}/pull/42243) Improve trailing whitespace message [42252]({{site.repo.flutter}}/pull/42252) catch argument error from Make [42353]({{site.repo.flutter}}/pull/42353) Add --cache-sksl flag to drive and run [42354]({{site.repo.flutter}}/pull/42354) Pass -Ddart.developer.causal_async_stacks=true to frontend_server invocations. [42364]({{site.repo.flutter}}/pull/42364) Wrap dwds in async guard, only catch known error types [42373]({{site.repo.flutter}}/pull/42373) Switch build commands to use process utils [42376]({{site.repo.flutter}}/pull/42376) Add option to precache unsigned mac binaries. [42471]({{site.repo.flutter}}/pull/42471) Pass build mode-specific bytecode generation options to frontend_server. [42476]({{site.repo.flutter}}/pull/42476) Refactor BuildMode into class, add jit_release configuration [42491]({{site.repo.flutter}}/pull/42491) Extra defensive programming for pub modification time assert [42538]({{site.repo.flutter}}/pull/42538) [flutter_tool] Improve yaml font map validation [42597]({{site.repo.flutter}}/pull/42597) Deflake wildcard asset test [42655]({{site.repo.flutter}}/pull/42655) resident_web_runner doesn't close debug connection [42656]({{site.repo.flutter}}/pull/42656) Catch appInstanceId error [42668]({{site.repo.flutter}}/pull/42668) dispose devices on cleanupAtFinish() for run_cold.dart [42698]({{site.repo.flutter}}/pull/42698) Ensure we stop the status when browser connection is complete [42791]({{site.repo.flutter}}/pull/42791) fix type error in manifest asset bundle [42813]({{site.repo.flutter}}/pull/42813) Fix NPE in Chrome Device [42972]({{site.repo.flutter}}/pull/42972) Do not produce an error when encountering a new type in a service response. [42977]({{site.repo.flutter}}/pull/42977) switch dart2js build to depfile, remove Source.function [43016]({{site.repo.flutter}}/pull/43016) ensure we can disable --track-widget-creation in debug mode [43022]({{site.repo.flutter}}/pull/43022) Enable dump-skp-on-shader-compilation in drive [43042]({{site.repo.flutter}}/pull/43042) add samsungexynos7570 to list of known physical devices [43080]({{site.repo.flutter}}/pull/43080) Indent Kotlin code with 4 spaces [43180]({{site.repo.flutter}}/pull/43180) Adding missing break in plugin validation check [43217]({{site.repo.flutter}}/pull/43217) [flutter_tool] Update analytics policy, send event on disable [43219]({{site.repo.flutter}}/pull/43219) Add devfs for incremental compiler JavaScript bundle [43225]({{site.repo.flutter}}/pull/43225) Catch io.StdinException from failure to set stdin echo/line mode [43281]({{site.repo.flutter}}/pull/43281) Add compiler configuration to support dartdevc target [43292]({{site.repo.flutter}}/pull/43292) initial bootstrap script for incremental compiler support [43381]({{site.repo.flutter}}/pull/43381) [flutter_tool] Use engine flutter_runner prebuilts [43390]({{site.repo.flutter}}/pull/43390) catch ChromeDebugException from dwds [43401]({{site.repo.flutter}}/pull/43401) Handle permission error during flutter clean [43402]({{site.repo.flutter}}/pull/43402) Handle format error from vswhere [43403]({{site.repo.flutter}}/pull/43403) Handle version and option skew errors [43436]({{site.repo.flutter}}/pull/43436) Handle onError callback with optional argument [43448]({{site.repo.flutter}}/pull/43448) Don't html-escape in the plugin registrant templates. [43471]({{site.repo.flutter}}/pull/43471) flip track widget creation on by default [43544]({{site.repo.flutter}}/pull/43544) Catch AppConnectionException [43546]({{site.repo.flutter}}/pull/43546) Alias upgrade-packages => update-packages [43577]({{site.repo.flutter}}/pull/43577) set trace to true for desktop builds [43586]({{site.repo.flutter}}/pull/43586) Ensure Chrome is closed on tab close [43598]({{site.repo.flutter}}/pull/43598) Catch failed daemon startup error [43599]({{site.repo.flutter}}/pull/43599) catch failure to parse FLUTTER_STORAGE_BASE_URL [43602]({{site.repo.flutter}}/pull/43602) Don't indefinitely persist file hashes, handle more error conditions [43667]({{site.repo.flutter}}/pull/43667) Added a null check for ranges in the sourceReport map. [43725]({{site.repo.flutter}}/pull/43725) Add reloadMethod RPC [43753]({{site.repo.flutter}}/pull/43753) pass --no-gen-bytecode to aot kernel compiler invocations [43764]({{site.repo.flutter}}/pull/43764) Update create.dart [43767]({{site.repo.flutter}}/pull/43767) check if libimobiledevice executables exist [43800]({{site.repo.flutter}}/pull/43800) de-flake logger test [43862]({{site.repo.flutter}}/pull/43862) Ensure target platform is passed is always passed [43870]({{site.repo.flutter}}/pull/43870) check for instanceof instead of runtimeType [43907]({{site.repo.flutter}}/pull/43907) Serve correct mime type on release dev server [43908]({{site.repo.flutter}}/pull/43908) remove no-gen-bytecode flag [43945]({{site.repo.flutter}}/pull/43945) Remove Source.behavior, fix bug in depfile invalidation [44017]({{site.repo.flutter}}/pull/44017) Asset server fix for sourcemaps [44027]({{site.repo.flutter}}/pull/44027) Allow specifying device-vmservice-port and host-vmservice-port [44032]({{site.repo.flutter}}/pull/44032) Copy chrome preferences to seeded data dir [44052]({{site.repo.flutter}}/pull/44052) Remove flutter_tool services code [44083]({{site.repo.flutter}}/pull/44083) Add --dart-define option [44119]({{site.repo.flutter}}/pull/44119) [flutter_tool] --flutter_runner will download the debug symbols [44146]({{site.repo.flutter}}/pull/44146) Remove flutter.yaml migration code [44200]({{site.repo.flutter}}/pull/44200) Make ProjectFileInvalidator injectable [44221]({{site.repo.flutter}}/pull/44221) Use platform appropriate filepaths [44227]({{site.repo.flutter}}/pull/44227) [flutter_tool] Screenshot command must require device only for _kDeviceType [44278]({{site.repo.flutter}}/pull/44278) Do not pass obsolete --strong option to front-end server [44279]({{site.repo.flutter}}/pull/44279) link platform should be true for profile [44360]({{site.repo.flutter}}/pull/44360) [flutter_tool] Stream artifact downloads to files [44447]({{site.repo.flutter}}/pull/44447) implicit-casts:false on flutter_tools/lib [44481]({{site.repo.flutter}}/pull/44481) Provide specific field to accept depfiles in target class [44488]({{site.repo.flutter}}/pull/44488) Refactorings to testbed.run and testbed.test [44574]({{site.repo.flutter}}/pull/44574) Print a message when modifying settings that you may need to reload IDE/editor [44608]({{site.repo.flutter}}/pull/44608) Reduce some direct package:archive usage [44753]({{site.repo.flutter}}/pull/44753) Always link desktop platforms [44868]({{site.repo.flutter}}/pull/44868) Catch and display version check errors during doctor [44933]({{site.repo.flutter}}/pull/44933) [flutter_tool] Don't crash when failing to delete downloaded artifacts [44966]({{site.repo.flutter}}/pull/44966) Don't log stack traces to console on build failures [45011]({{site.repo.flutter}}/pull/45011) catch IOSDeviceNotFoundError in IOSDevice.startApp() [45153]({{site.repo.flutter}}/pull/45153) implicit-casts:false on flutter_tools [45236]({{site.repo.flutter}}/pull/45236) Improve time to development by initializing frontend_server concurrently with platform build [45239]({{site.repo.flutter}}/pull/45239) implicit-casts:false in fuchsia_remote_debug_protocol [45303]({{site.repo.flutter}}/pull/45303) Allow unknown fields in pubspec plugin section [45317]({{site.repo.flutter}}/pull/45317) de-null dartDefines in daemon mode [45319]({{site.repo.flutter}}/pull/45319) catch parse error from corrupt config [45364]({{site.repo.flutter}}/pull/45364) Allow a no-op default_package key for a plugin platform [45407]({{site.repo.flutter}}/pull/45407) Don't crash if the tool cannot delete asset directory [46011]({{site.repo.flutter}}/pull/46011) [flutter_tool] Do not continue with a no-op 'upgrade' ## Full PR List See the [full list](/release/release-notes/changelogs/changelog-1.12.13) of merged PRs for the 1.12 release. [breaking change policy on the Flutter wiki]: {{site.repo.flutter}}/wiki/Tree-hygiene#handling-breaking-changes [flutter-announce]: https://groups.google.com/g/flutter-announce [GitHub Octoverse report]: https://octoverse.github.com/ [this post from Ian Hickson]: https://groups.google.com/g/flutter-announce/c/Z09a317E21o
website/src/release/release-notes/release-notes-1.12.13.md/0
{ "file_path": "website/src/release/release-notes/release-notes-1.12.13.md", "repo_id": "website", "token_count": 48456 }
1,433
--- title: Inside Flutter description: Learn about Flutter's inner workings from one of the founding engineers. --- This document describes the inner workings of the Flutter toolkit that make Flutter's API possible. Because Flutter widgets are built using aggressive composition, user interfaces built with Flutter have a large number of widgets. To support this workload, Flutter uses sublinear algorithms for layout and building widgets as well as data structures that make tree surgery efficient and that have a number of constant-factor optimizations. With some additional details, this design also makes it easy for developers to create infinite scrolling lists using callbacks that build exactly those widgets that are visible to the user. ## Aggressive composability One of the most distinctive aspects of Flutter is its _aggressive composability_. Widgets are built by composing other widgets, which are themselves built out of progressively more basic widgets. For example, `Padding` is a widget rather than a property of other widgets. As a result, user interfaces built with Flutter consist of many, many widgets. The widget building recursion bottoms out in `RenderObjectWidgets`, which are widgets that create nodes in the underlying _render_ tree. The render tree is a data structure that stores the geometry of the user interface, which is computed during _layout_ and used during _painting_ and _hit testing_. Most Flutter developers do not author render objects directly but instead manipulate the render tree using widgets. In order to support aggressive composability at the widget layer, Flutter uses a number of efficient algorithms and optimizations at both the widget and render tree layers, which are described in the following subsections. ### Sublinear layout With a large number of widgets and render objects, the key to good performance is efficient algorithms. Of paramount importance is the performance of _layout_, which is the algorithm that determines the geometry (for example, the size and position) of the render objects. Some other toolkits use layout algorithms that are O(N²) or worse (for example, fixed-point iteration in some constraint domain). Flutter aims for linear performance for initial layout, and _sublinear layout performance_ in the common case of subsequently updating an existing layout. Typically, the amount of time spent in layout should scale more slowly than the number of render objects. Flutter performs one layout per frame, and the layout algorithm works in a single pass. _Constraints_ are passed down the tree by parent objects calling the layout method on each of their children. The children recursively perform their own layout and then return _geometry_ up the tree by returning from their layout method. Importantly, once a render object has returned from its layout method, that render object will not be visited again<sup><a href="#a1">1</a></sup> until the layout for the next frame. This approach combines what might otherwise be separate measure and layout passes into a single pass and, as a result, each render object is visited _at most twice_<sup><a href="#a2">2</a></sup> during layout: once on the way down the tree, and once on the way up the tree. Flutter has several specializations of this general protocol. The most common specialization is `RenderBox`, which operates in two-dimensional, cartesian coordinates. In box layout, the constraints are a min and max width and a min and max height. During layout, the child determines its geometry by choosing a size within these bounds. After the child returns from layout, the parent decides the child's position in the parent's coordinate system<sup><a href="#a3">3</a></sup>. Note that the child's layout cannot depend on its position, as the position is not determined until after the child returns from the layout. As a result, the parent is free to reposition the child without needing to recompute its layout. More generally, during layout, the _only_ information that flows from parent to child are the constraints and the _only_ information that flows from child to parent is the geometry. These invariants can reduce the amount of work required during layout: * If the child has not marked its own layout as dirty, the child can return immediately from layout, cutting off the walk, as long as the parent gives the child the same constraints as the child received during the previous layout. * Whenever a parent calls a child's layout method, the parent indicates whether it uses the size information returned from the child. If, as often happens, the parent does not use the size information, then the parent need not recompute its layout if the child selects a new size because the parent is guaranteed that the new size will conform to the existing constraints. * _Tight_ constraints are those that can be satisfied by exactly one valid geometry. For example, if the min and max widths are equal to each other and the min and max heights are equal to each other, the only size that satisfies those constraints is one with that width and height. If the parent provides tight constraints, then the parent need not recompute its layout whenever the child recomputes its layout, even if the parent uses the child's size in its layout, because the child cannot change size without new constraints from its parent. * A render object can declare that it uses the constraints provided by the parent only to determine its geometry. Such a declaration informs the framework that the parent of that render object does not need to recompute its layout when the child recomputes its layout _even if the constraints are not tight_ and _even if the parent's layout depends on the child's size_, because the child cannot change size without new constraints from its parent. As a result of these optimizations, when the render object tree contains dirty nodes, only those nodes and a limited part of the subtree around them are visited during layout. ### Sublinear widget building Similar to the layout algorithm, Flutter's widget building algorithm is sublinear. After being built, the widgets are held by the _element tree_, which retains the logical structure of the user interface. The element tree is necessary because the widgets themselves are _immutable_, which means (among other things), they cannot remember their parent or child relationships with other widgets. The element tree also holds the _state_ objects associated with stateful widgets. In response to user input (or other stimuli), an element can become dirty, for example if the developer calls `setState()` on the associated state object. The framework keeps a list of dirty elements and jumps directly to them during the _build_ phase, skipping over clean elements. During the build phase, information flows _unidirectionally_ down the element tree, which means each element is visited at most once during the build phase. Once cleaned, an element cannot become dirty again because, by induction, all its ancestor elements are also clean<sup><a href="#a4">4</a></sup>. Because widgets are _immutable_, if an element has not marked itself as dirty, the element can return immediately from build, cutting off the walk, if the parent rebuilds the element with an identical widget. Moreover, the element need only compare the object identity of the two widget references in order to establish that the new widget is the same as the old widget. Developers exploit this optimization to implement the _reprojection_ pattern, in which a widget includes a prebuilt child widget stored as a member variable in its build. During build, Flutter also avoids walking the parent chain using `InheritedWidgets`. If widgets commonly walked their parent chain, for example to determine the current theme color, the build phase would become O(N²) in the depth of the tree, which can be quite large due to aggressive composition. To avoid these parent walks, the framework pushes information down the element tree by maintaining a hash table of `InheritedWidget`s at each element. Typically, many elements will reference the same hash table, which changes only at elements that introduce a new `InheritedWidget`. ### Linear reconciliation Contrary to popular belief, Flutter does not employ a tree-diffing algorithm. Instead, the framework decides whether to reuse elements by examining the child list for each element independently using an O(N) algorithm. The child list reconciliation algorithm optimizes for the following cases: * The old child list is empty. * The two lists are identical. * There is an insertion or removal of one or more widgets in exactly one place in the list. * If each list contains a widget with the same key<sup><a href="#a5">5</a></sup>, the two widgets are matched. The general approach is to match up the beginning and end of both child lists by comparing the runtime type and key of each widget, potentially finding a non-empty range in the middle of each list that contains all the unmatched children. The framework then places the children in the range in the old child list into a hash table based on their keys. Next, the framework walks the range in the new child list and queries the hash table by key for matches. Unmatched children are discarded and rebuilt from scratch whereas matched children are rebuilt with their new widgets. ### Tree surgery Reusing elements is important for performance because elements own two critical pieces of data: the state for stateful widgets and the underlying render objects. When the framework is able to reuse an element, the state for that logical part of the user interface is preserved and the layout information computed previously can be reused, often avoiding entire subtree walks. In fact, reusing elements is so valuable that Flutter supports _non-local_ tree mutations that preserve state and layout information. Developers can perform a non-local tree mutation by associating a `GlobalKey` with one of their widgets. Each global key is unique throughout the entire application and is registered with a thread-specific hash table. During the build phase, the developer can move a widget with a global key to an arbitrary location in the element tree. Rather than building a fresh element at that location, the framework will check the hash table and reparent the existing element from its previous location to its new location, preserving the entire subtree. The render objects in the reparented subtree are able to preserve their layout information because the layout constraints are the only information that flows from parent to child in the render tree. The new parent is marked dirty for layout because its child list has changed, but if the new parent passes the child the same layout constraints the child received from its old parent, the child can return immediately from layout, cutting off the walk. Global keys and non-local tree mutations are used extensively by developers to achieve effects such as hero transitions and navigation. ### Constant-factor optimizations In addition to these algorithmic optimizations, achieving aggressive composability also relies on several important constant-factor optimizations. These optimizations are most important at the leaves of the major algorithms discussed above. * **Child-model agnostic.** Unlike most toolkits, which use child lists, Flutter's render tree does not commit to a specific child model. For example, the `RenderBox` class has an abstract `visitChildren()` method rather than a concrete `firstChild` and `nextSibling` interface. Many subclasses support only a single child, held directly as a member variable, rather than a list of children. For example, `RenderPadding` supports only a single child and, as a result, has a simpler layout method that takes less time to execute. * **Visual render tree, logical widget tree.** In Flutter, the render tree operates in a device-independent, visual coordinate system, which means smaller values in the x coordinate are always towards the left, even if the current reading direction is right-to-left. The widget tree typically operates in logical coordinates, meaning with _start_ and _end_ values whose visual interpretation depends on the reading direction. The transformation from logical to visual coordinates is done in the handoff between the widget tree and the render tree. This approach is more efficient because layout and painting calculations in the render tree happen more often than the widget-to-render tree handoff and can avoid repeated coordinate conversions. * **Text handled by a specialized render object.** The vast majority of render objects are ignorant of the complexities of text. Instead, text is handled by a specialized render object, `RenderParagraph`, which is a leaf in the render tree. Rather than subclassing a text-aware render object, developers incorporate text into their user interface using composition. This pattern means `RenderParagraph` can avoid recomputing its text layout as long as its parent supplies the same layout constraints, which is common, even during tree surgery. * **Observable objects.** Flutter uses both the model-observation and the reactive paradigms. Obviously, the reactive paradigm is dominant, but Flutter uses observable model objects for some leaf data structures. For example, `Animation`s notify an observer list when their value changes. Flutter hands off these observable objects from the widget tree to the render tree, which observes them directly and invalidates only the appropriate stage of the pipeline when they change. For example, a change to an `Animation<Color>` might trigger only the paint phase rather than both the build and paint phases. Taken together and summed over the large trees created by aggressive composition, these optimizations have a substantial effect on performance. ### Separation of the Element and RenderObject trees The `RenderObject` and `Element` (Widget) trees in Flutter are isomorphic (strictly speaking, the `RenderObject` tree is a subset of the `Element` tree). An obvious simplification would be to combine these trees into one tree. However, in practice there are a number of benefits to having these trees be separate: * **Performance.** When the layout changes, only the relevant parts of the layout tree need to be walked. Due to composition, the element tree frequently has many additional nodes that would have to be skipped. * **Clarity.** The clearer separation of concerns allows the widget protocol and the render object protocol to each be specialized to their specific needs, simplifying the API surface and thus lowering the risk of bugs and the testing burden. * **Type safety.** The render object tree can be more type safe since it can guarantee at runtime that children will be of the appropriate type (each coordinate system, e.g. has its own type of render object). Composition widgets can be agnostic about the coordinate system used during layout (for example, the same widget exposing a part of the app model could be used in both a box layout and a sliver layout), and thus in the element tree, verifying the type of render objects would require a tree walk. ## Infinite scrolling Infinite scrolling lists are notoriously difficult for toolkits. Flutter supports infinite scrolling lists with a simple interface based on the _builder_ pattern, in which a `ListView` uses a callback to build widgets on demand as they become visible to the user during scrolling. Supporting this feature requires _viewport-aware layout_ and _building widgets on demand_. ### Viewport-aware layout Like most things in Flutter, scrollable widgets are built using composition. The outside of a scrollable widget is a `Viewport`, which is a box that is "bigger on the inside," meaning its children can extend beyond the bounds of the viewport and can be scrolled into view. However, rather than having `RenderBox` children, a viewport has `RenderSliver` children, known as _slivers_, which have a viewport-aware layout protocol. The sliver layout protocol matches the structure of the box layout protocol in that parents pass constraints down to their children and receive geometry in return. However, the constraint and geometry data differs between the two protocols. In the sliver protocol, children are given information about the viewport, including the amount of visible space remaining. The geometry data they return enables a variety of scroll-linked effects, including collapsible headers and parallax. Different slivers fill the space available in the viewport in different ways. For example, a sliver that produces a linear list of children lays out each child in order until the sliver either runs out of children or runs out of space. Similarly, a sliver that produces a two-dimensional grid of children fills only the portion of its grid that is visible. Because they are aware of how much space is visible, slivers can produce a finite number of children even if they have the potential to produce an unbounded number of children. Slivers can be composed to create bespoke scrollable layouts and effects. For example, a single viewport can have a collapsible header followed by a linear list and then a grid. All three slivers will cooperate through the sliver layout protocol to produce only those children that are actually visible through the viewport, regardless of whether those children belong to the header, the list, or the grid<sup><a href="#a6">6</a></sup>. ### Building widgets on demand If Flutter had a strict _build-then-layout-then-paint_ pipeline, the foregoing would be insufficient to implement an infinite scrolling list because the information about how much space is visible through the viewport is available only during the layout phase. Without additional machinery, the layout phase is too late to build the widgets necessary to fill the space. Flutter solves this problem by interleaving the build and layout phases of the pipeline. At any point in the layout phase, the framework can start building new widgets on demand _as long as those widgets are descendants of the render object currently performing layout_. Interleaving build and layout is possible only because of the strict controls on information propagation in the build and layout algorithms. Specifically, during the build phase, information can propagate only down the tree. When a render object is performing layout, the layout walk has not visited the subtree below that render object, which means writes generated by building in that subtree cannot invalidate any information that has entered the layout calculation thus far. Similarly, once layout has returned from a render object, that render object will never be visited again during this layout, which means any writes generated by subsequent layout calculations cannot invalidate the information used to build the render object's subtree. Additionally, linear reconciliation and tree surgery are essential for efficiently updating elements during scrolling and for modifying the render tree when elements are scrolled into and out of view at the edge of the viewport. ## API Ergonomics Being fast only matters if the framework can actually be used effectively. To guide Flutter's API design towards greater usability, Flutter has been repeatedly tested in extensive UX studies with developers. These studies sometimes confirmed pre-existing design decisions, sometimes helped guide the prioritization of features, and sometimes changed the direction of the API design. For instance, Flutter's APIs are heavily documented; UX studies confirmed the value of such documentation, but also highlighted the need specifically for sample code and illustrative diagrams. This section discusses some of the decisions made in Flutter's API design in aid of usability. ### Specializing APIs to match the developer's mindset The base class for nodes in Flutter's `Widget`, `Element`, and `RenderObject` trees does not define a child model. This allows each node to be specialized for the child model that is applicable to that node. Most `Widget` objects have a single child `Widget`, and therefore only expose a single `child` parameter. Some widgets support an arbitrary number of children, and expose a `children` parameter that takes a list. Some widgets don't have any children at all and reserve no memory, and have no parameters for them. Similarly, `RenderObjects` expose APIs specific to their child model. `RenderImage` is a leaf node, and has no concept of children. `RenderPadding` takes a single child, so it has storage for a single pointer to a single child. `RenderFlex` takes an arbitrary number of children and manages it as a linked list. In some rare cases, more complicated child models are used. The `RenderTable` render object's constructor takes an array of arrays of children, the class exposes getters and setters that control the number of rows and columns, and there are specific methods to replace individual children by x,y coordinate, to add a row, to provide a new array of arrays of children, and to replace the entire child list with a single array and a column count. In the implementation, the object does not use a linked list like most render objects but instead uses an indexable array. The `Chip` widgets and `InputDecoration` objects have fields that match the slots that exist on the relevant controls. Where a one-size-fits-all child model would force semantics to be layered on top of a list of children, for example, defining the first child to be the prefix value and the second to be the suffix, the dedicated child model allows for dedicated named properties to be used instead. This flexibility allows each node in these trees to be manipulated in the way most idiomatic for its role. It's rare to want to insert a cell in a table, causing all the other cells to wrap around; similarly, it's rare to want to remove a child from a flex row by index instead of by reference. The `RenderParagraph` object is the most extreme case: it has a child of an entirely different type, `TextSpan`. At the `RenderParagraph` boundary, the `RenderObject` tree transitions into being a `TextSpan` tree. The overall approach of specializing APIs to meet the developer's expectations is applied to more than just child models. Some rather trivial widgets exist specifically so that developers will find them when looking for a solution to a problem. Adding a space to a row or column is easily done once one knows how, using the `Expanded` widget and a zero-sized `SizedBox` child, but discovering that pattern is unnecessary because searching for `space` uncovers the `Spacer` widget, which uses `Expanded` and `SizedBox` directly to achieve the effect. Similarly, hiding a widget subtree is easily done by not including the widget subtree in the build at all. However, developers typically expect there to be a widget to do this, and so the `Visibility` widget exists to wrap this pattern in a trivial reusable widget. ### Explicit arguments UI frameworks tend to have many properties, such that a developer is rarely able to remember the semantic meaning of each constructor argument of each class. As Flutter uses the reactive paradigm, it is common for build methods in Flutter to have many calls to constructors. By leveraging Dart's support for named arguments, Flutter's API is able to keep such build methods clear and understandable. This pattern is extended to any method with multiple arguments, and in particular is extended to any boolean argument, so that isolated `true` or `false` literals in method calls are always self-documenting. Furthermore, to avoid confusion commonly caused by double negatives in APIs, boolean arguments and properties are always named in the positive form (for example, `enabled: true` rather than `disabled: false`). ### Paving over pitfalls A technique used in a number of places in the Flutter framework is to define the API such that error conditions don't exist. This removes entire classes of errors from consideration. For example, interpolation functions allow one or both ends of the interpolation to be null, instead of defining that as an error case: interpolating between two null values is always null, and interpolating from a null value or to a null value is the equivalent of interpolating to the zero analog for the given type. This means that developers who accidentally pass null to an interpolation function will not hit an error case, but will instead get a reasonable result. A more subtle example is in the `Flex` layout algorithm. The concept of this layout is that the space given to the flex render object is divided among its children, so the size of the flex should be the entirety of the available space. In the original design, providing infinite space would fail: it would imply that the flex should be infinitely sized, a useless layout configuration. Instead, the API was adjusted so that when infinite space is allocated to the flex render object, the render object sizes itself to fit the desired size of the children, reducing the possible number of error cases. The approach is also used to avoid having constructors that allow inconsistent data to be created. For instance, the `PointerDownEvent` constructor does not allow the `down` property of `PointerEvent` to be set to `false` (a situation that would be self-contradictory); instead, the constructor does not have a parameter for the `down` field and always sets it to `true`. In general, the approach is to define valid interpretations for all values in the input domain. The simplest example is the `Color` constructor. Instead of taking four integers, one for red, one for green, one for blue, and one for alpha, each of which could be out of range, the default constructor takes a single integer value, and defines the meaning of each bit (for example, the bottom eight bits define the red component), so that any input value is a valid color value. A more elaborate example is the `paintImage()` function. This function takes eleven arguments, some with quite wide input domains, but they have been carefully designed to be mostly orthogonal to each other, such that there are very few invalid combinations. ### Reporting error cases aggressively Not all error conditions can be designed out. For those that remain, in debug builds, Flutter generally attempts to catch the errors very early and immediately reports them. Asserts are widely used. Constructor arguments are sanity checked in detail. Lifecycles are monitored and when inconsistencies are detected they immediately cause an exception to be thrown. In some cases, this is taken to extremes: for example, when running unit tests, regardless of what else the test is doing, every `RenderBox` subclass that is laid out aggressively inspects whether its intrinsic sizing methods fulfill the intrinsic sizing contract. This helps catch errors in APIs that might otherwise not be exercised. When exceptions are thrown, they include as much information as is available. Some of Flutter's error messages proactively probe the associated stack trace to determine the most likely location of the actual bug. Others walk the relevant trees to determine the source of bad data. The most common errors include detailed instructions including in some cases sample code for avoiding the error, or links to further documentation. ### Reactive paradigm Mutable tree-based APIs suffer from a dichotomous access pattern: creating the tree's original state typically uses a very different set of operations than subsequent updates. Flutter's rendering layer uses this paradigm, as it is an effective way to maintain a persistent tree, which is key for efficient layout and painting. However, it means that direct interaction with the rendering layer is awkward at best and bug-prone at worst. Flutter's widget layer introduces a composition mechanism using the reactive paradigm<sup><a href="#a7">7</a></sup> to manipulate the underlying rendering tree. This API abstracts out the tree manipulation by combining the tree creation and tree mutation steps into a single tree description (build) step, where, after each change to the system state, the new configuration of the user interface is described by the developer and the framework computes the series of tree mutations necessary to reflect this new configuration. ### Interpolation Since Flutter's framework encourages developers to describe the interface configuration matching the current application state, a mechanism exists to implicitly animate between these configurations. For example, suppose that in state S<sub>1</sub> the interface consists of a circle, but in state S<sub>2</sub> it consists of a square. Without an animation mechanism, the state change would have a jarring interface change. An implicit animation allows the circle to be smoothly squared over several frames. Each feature that can be implicitly animated has a stateful widget that keeps a record of the current value of the input, and begins an animation sequence whenever the input value changes, transitioning from the current value to the new value over a specified duration. This is implemented using `lerp` (linear interpolation) functions using immutable objects. Each state (circle and square, in this case) is represented as an immutable object that is configured with appropriate settings (color, stroke width, etc) and knows how to paint itself. When it is time to draw the intermediate steps during the animation, the start and end values are passed to the appropriate `lerp` function along with a _t_ value representing the point along the animation, where 0.0 represents the `start` and 1.0 represents the `end`<sup><a href="#a8">8</a></sup>, and the function returns a third immutable object representing the intermediate stage. For the circle-to-square transition, the `lerp` function would return an object representing a "rounded square" with a radius described as a fraction derived from the _t_ value, a color interpolated using the `lerp` function for colors, and a stroke width interpolated using the `lerp` function for doubles. That object, which implements the same interface as circles and squares, would then be able to paint itself when requested to. This technique allows the state machinery, the mapping of states to configurations, the animation machinery, the interpolation machinery, and the specific logic relating to how to paint each frame to be entirely separated from each other. This approach is broadly applicable. In Flutter, basic types like `Color` and `Shape` can be interpolated, but so can much more elaborate types such as `Decoration`, `TextStyle`, or `Theme`. These are typically constructed from components that can themselves be interpolated, and interpolating the more complicated objects is often as simple as recursively interpolating all the values that describe the complicated objects. Some interpolatable objects are defined by class hierarchies. For example, shapes are represented by the `ShapeBorder` interface, and there exists a variety of shapes, including `BeveledRectangleBorder`, `BoxBorder`, `CircleBorder`, `RoundedRectangleBorder`, and `StadiumBorder`. A single `lerp` function can't anticipate all possible types, and therefore the interface instead defines `lerpFrom` and `lerpTo` methods, which the static `lerp` method defers to. When told to interpolate from a shape A to a shape B, first B is asked if it can `lerpFrom` A, then, if it cannot, A is instead asked if it can `lerpTo` B. (If neither is possible, then the function returns A from values of `t` less than 0.5, and returns B otherwise.) This allows the class hierarchy to be arbitrarily extended, with later additions being able to interpolate between previously-known values and themselves. In some cases, the interpolation itself cannot be described by any of the available classes, and a private class is defined to describe the intermediate stage. This is the case, for instance, when interpolating between a `CircleBorder` and a `RoundedRectangleBorder`. This mechanism has one further added advantage: it can handle interpolation from intermediate stages to new values. For example, half-way through a circle-to-square transition, the shape could be changed once more, causing the animation to need to interpolate to a triangle. So long as the triangle class can `lerpFrom` the rounded-square intermediate class, the transition can be seamlessly performed. ## Conclusion Flutter's slogan, "everything is a widget," revolves around building user interfaces by composing widgets that are, in turn, composed of progressively more basic widgets. The result of this aggressive composition is a large number of widgets that require carefully designed algorithms and data structures to process efficiently. With some additional design, these data structures also make it easy for developers to create infinite scrolling lists that build widgets on demand when they become visible. --- **Footnotes:** <sup><a id="a1">1</a></sup> For layout, at least. It might be revisited for painting, for building the accessibility tree if necessary, and for hit testing if necessary. <sup><a id="a2">2</a></sup> Reality, of course, is a bit more complicated. Some layouts involve intrinsic dimensions or baseline measurements, which do involve an additional walk of the relevant subtree (aggressive caching is used to mitigate the potential for quadratic performance in the worst case). These cases, however, are surprisingly rare. In particular, intrinsic dimensions are not required for the common case of shrink-wrapping. <sup><a id="a3">3</a></sup> Technically, the child's position is not part of its RenderBox geometry and therefore need not actually be calculated during layout. Many render objects implicitly position their single child at 0,0 relative to their own origin, which requires no computation or storage at all. Some render objects avoid computing the position of their children until the last possible moment (for example, during the paint phase), to avoid the computation entirely if they are not subsequently painted. <sup><a id="a4">4</a></sup> There exists one exception to this rule. As discussed in the [Building widgets on demand](#building-widgets-on-demand) section, some widgets can be rebuilt as a result of a change in layout constraints. If a widget marked itself dirty for unrelated reasons in the same frame that it also is affected by a change in layout constraints, it will be updated twice. This redundant build is limited to the widget itself and does not impact its descendants. <sup><a id="a5">5</a></sup> A key is an opaque object optionally associated with a widget whose equality operator is used to influence the reconciliation algorithm. <sup><a id="a6">6</a></sup> For accessibility, and to give applications a few extra milliseconds between when a widget is built and when it appears on the screen, the viewport creates (but does not paint) widgets for a few hundred pixels before and after the visible widgets. <sup><a id="a7">7</a></sup> This approach was first made popular by Facebook's React library. <sup><a id="a8">8</a></sup> In practice, the _t_ value is allowed to extend past the 0.0-1.0 range, and does so for some curves. For example, the "elastic" curves overshoot briefly in order to represent a bouncing effect. The interpolation logic typically can extrapolate past the start or end as appropriate. For some types, for example, when interpolating colors, the _t_ value is effectively clamped to the 0.0-1.0 range.
website/src/resources/inside-flutter.md/0
{ "file_path": "website/src/resources/inside-flutter.md", "repo_id": "website", "token_count": 8078 }
1,434
--- title: Testing Flutter apps description: Learn more about the different types of testing and how to write them. --- The more features your app has, the harder it is to test manually. Automated tests help ensure that your app performs correctly before you publish it, while retaining your feature and bug fix velocity. {{site.alert.note}} For hands-on practice of testing Flutter apps, see the [How to test a Flutter app][] codelab. {{site.alert.end}} Automated testing falls into a few categories: * A [_unit test_](#unit-tests) tests a single function, method, or class. * A [_widget test_](#widget-tests) (in other UI frameworks referred to as _component test_) tests a single widget. * An [_integration test_](#integration-tests) tests a complete app or a large part of an app. Generally speaking, a well-tested app has many unit and widget tests, tracked by [code coverage][], plus enough integration tests to cover all the important use cases. This advice is based on the fact that there are trade-offs between different kinds of testing, seen below. | | Unit | Widget | Integration | |----------------------|--------|--------|-------------| | **Confidence** | Low | Higher | Highest | | **Maintenance cost** | Low | Higher | Highest | | **Dependencies** | Few | More | Most | | **Execution speed** | Quick | Quick | Slow | {:.table.table-striped} ## Unit tests A _unit test_ tests a single function, method, or class. The goal of a unit test is to verify the correctness of a unit of logic under a variety of conditions. External dependencies of the unit under test are generally [mocked out](/cookbook/testing/unit/mocking). Unit tests generally don't read from or write to disk, render to screen, or receive user actions from outside the process running the test. For more information regarding unit tests, you can view the following recipes or run `flutter test --help` in your terminal. {{site.alert.note}} If you're writing unit tests for code that uses plugins and you want to avoid crashes, check out [Plugins in Flutter tests][]. If you want to test your Flutter plugin, check out [Testing plugins][]. {{site.alert.end}} [Plugins in Flutter tests]: /testing/plugins-in-tests [Testing plugins]: /testing/testing-plugins ### Recipes {:.no_toc} {% include docs/testing-toc.md type='unit' %} ## Widget tests A _widget test_ (in other UI frameworks referred to as _component test_) tests a single widget. The goal of a widget test is to verify that the widget's UI looks and interacts as expected. Testing a widget involves multiple classes and requires a test environment that provides the appropriate widget lifecycle context. For example, the Widget being tested should be able to receive and respond to user actions and events, perform layout, and instantiate child widgets. A widget test is therefore more comprehensive than a unit test. However, like a unit test, a widget test's environment is replaced with an implementation much simpler than a full-blown UI system. ### Recipes {:.no_toc} {% include docs/testing-toc.md type='widget' %} ## Integration tests An _integration test_ tests a complete app or a large part of an app. The goal of an integration test is to verify that all the widgets and services being tested work together as expected. Furthermore, you can use integration tests to verify your app's performance. Generally, an _integration test_ runs on a real device or an OS emulator, such as iOS Simulator or Android Emulator. The app under test is typically isolated from the test driver code to avoid skewing the results. For more information on how to write integration tests, see the [integration testing page][]. ### Recipes {:.no_toc} {% include docs/testing-toc.md type='integration' %} ## Continuous integration services Continuous integration (CI) services allow you to run your tests automatically when pushing new code changes. This provides timely feedback on whether the code changes work as expected and do not introduce bugs. For information on running tests on various continuous integration services, see the following: * [Continuous delivery using fastlane with Flutter][] * [Test Flutter apps on Appcircle][] * [Test Flutter apps on Travis][] * [Test Flutter apps on Cirrus][] * [Codemagic CI/CD for Flutter][] * [Flutter CI/CD with Bitrise][] [code coverage]: https://en.wikipedia.org/wiki/Code_coverage [Codemagic CI/CD for Flutter]: https://blog.codemagic.io/getting-started-with-codemagic/ [Continuous delivery using fastlane with Flutter]: /deployment/cd#fastlane [Flutter CI/CD with Bitrise]: https://devcenter.bitrise.io/en/getting-started/quick-start-guides/getting-started-with-flutter-apps [How to test a Flutter app]: {{site.codelabs}}/codelabs/flutter-app-testing [Test Flutter apps on Appcircle]: https://blog.appcircle.io/article/flutter-ci-cd-github-ios-android-web# [Test Flutter apps on Cirrus]: https://cirrus-ci.org/examples/#flutter [Test Flutter apps on Travis]: {{site.flutter-medium}}/test-flutter-apps-on-travis-3fd5142ecd8c [integration testing page]: /testing/integration-tests
website/src/testing/overview.md/0
{ "file_path": "website/src/testing/overview.md", "repo_id": "website", "token_count": 1459 }
1,435
--- title: Using the Performance view description: Learn how to use the DevTools performance view. --- {{site.alert.note}} The DevTools performance view works for Flutter mobile and desktop apps. For web apps, Flutter adds timeline events to the performance panel of Chrome DevTools instead. To learn about profiling web apps, check out [Debugging web performance][]. {{site.alert.end}} [Debugging web performance]: /perf/web-performance The performance page can help you diagnose performance problems and UI jank in your application. This page offers timing and performance information for activity in your application. It consists of several tools to help you identify the cause of poor performance in your app: * Flutter frames chart (Flutter apps only) * Frame analysis tab (Flutter apps only) * Raster stats tab (Flutter apps only) * Timeline events trace viewer (all native Dart applications) * Advanced debugging tools (Flutter apps only) {{site.alert.secondary}} **Use a [profile build][] of your application to analyze performance.** Frame rendering times aren't indicative of release performance when running in debug mode. Run your app in profile mode, which still preserves useful debugging information. {{site.alert.end}} [profile build]: /testing/build-modes#profile The performance view also supports importing and exporting of data snapshots. For more information, check out the [Import and export][] section. ### What is a frame in Flutter? Flutter is designed to render its UI at 60 frames per second (fps), or 120 fps on devices capable of 120Hz updates. Each render is called a _frame_. This means that, approximately every 16ms, the UI updates to reflect animations or other changes to the UI. A frame that takes longer than 16ms to render causes jank (jerky motion) on the display device. ## Flutter frames chart This chart contains Flutter frame information for your application. Each bar set in the chart represents a single Flutter frame. The bars are color-coded to highlight the different portions of work that occur when rendering a Flutter frame: work from the UI thread and work from the raster thread. This chart contains Flutter frame timing information for your application. Each pair of bars in the chart represents a single Flutter frame. Selecting a frame from this chart updates the data that is displayed below in the [Frame analysis](#frame-analysis-tab) tab or the [Timeline events](#timeline-events-tab) tab. (As of [DevTools 2.23.1][], the [Raster stats](#raster-stats-tab) is a standalone feature without data per frame). [DevTools 2.23.1]: /tools/devtools/release-notes/release-notes-2.23.1 The flutter frames chart updates when new frames are drawn in your app. To pause updates to this chart, click the pause button to the right of the chart. This chart can be collapsed to provide more viewing space for data below by clicking the **Flutter frames** button above the chart. ![Screenshot of a Flutter frames chart](/assets/images/docs/tools/devtools/flutter-frames-chart.png) The pair of bars representing each Flutter frame are color-coded to highlight the different portions of work that occur when rendering a Flutter frame: work from the UI thread and work from the raster thread. ### UI The UI thread executes Dart code in the Dart VM. This includes code from your application as well as the Flutter framework. When your app creates and displays a scene, the UI thread creates a layer tree, a lightweight object containing device-agnostic painting commands, and sends the layer tree to the raster thread to be rendered on the device. Do **not** block this thread. ### Raster The raster thread executes graphics code from the Flutter Engine. This thread takes the layer tree and displays it by talking to the GPU (graphic processing unit). You can't directly access the raster thread or its data, but if this thread is slow, it's a result of something you've done in the Dart code. Skia, the graphics library, runs on this thread. [Impeller][] also uses this thread. [Impeller]: /perf/impeller Sometimes a scene results in a layer tree that is easy to construct, but expensive to render on the raster thread. In this case, you need to figure out what your code is doing that is causing rendering code to be slow. Specific kinds of workloads are more difficult for the GPU. They might involve unnecessary calls to `saveLayer()`, intersecting opacities with multiple objects, and clips or shadows in specific situations. For more information on profiling, check out [Identifying problems in the GPU graph][GPU graph]. ### Jank (slow frame) The frame rendering chart shows jank with a red overlay. A frame is considered to be janky if it takes more than ~16 ms to complete (for 60 FPS devices). To achieve a frame rendering rate of 60 FPS (frames per second), each frame must render in ~16 ms or less. When this target is missed, you may experience UI jank or dropped frames. For more information on how to analyze your app's performance, check out [Flutter performance profiling][]. ### Shader compilation Shader compilation occurs when a shader is first used in your Flutter app. Frames that perform shader compilation are marked in dark red: ![Screenshot of shader compilation for a frame](/assets/images/docs/tools/devtools/shader-compilation-frames-chart.png) For more information on how to reduce shader compilation jank, check out [Reduce shader compilation jank on mobile][]. ## Frame analysis tab Selecting a janky frame (slow, colored in red) from the Flutter frames chart above shows debugging hints in the Frame analysis tab. These hints help you diagnose jank in your app, and notify you of any expensive operations that we have detected that might have contributed to the slow frame time. ![Screenshot of the frame analysis tab](/assets/images/docs/tools/devtools/frame-analysis-tab.png) ## Raster stats tab {{site.alert.note}} For best results, this tool should be used with the Impeller rendering engine. When using Skia, the raster stats reported might be inconsistent due to the timing of when shaders are compiled. {{site.alert.end}} If you have Flutter frames that are janking with slow raster thread times, this tool might be able to help you diagnose the source of the slow performance. To generate raster stats: 1. Navigate to the screen in your app where you are seeing raster thread jank. 2. Click **Take Snapshot**. 3. View different layers and their respective rendering times. If you see an expensive layer, find the Dart code in your app that is producing this layer and investigate further. You can make changes to your code, hot reload, and take new snapshots to see if the performance of a layer was improved by your change. ![Screenshot of the raster stats tab](/assets/images/docs/tools/devtools/raster-stats-tab.png) ## Timeline events tab The timeline events chart shows all event tracing from your application. The Flutter framework emits timeline events as it works to build frames, draw scenes, and track other activity such as HTTP request timings and garbage collection. These events show up here in the Timeline. You can also send your own Timeline events using the dart:developer [`Timeline`][] and [`TimelineTask`][] APIs. [`Timeline`]: {{site.api}}/flutter/dart-developer/Timeline-class.html [`TimelineTask`]: {{site.api}}/flutter/dart-developer/TimelineTask-class.html ![Screenshot of a timeline events tab](/assets/images/docs/tools/devtools/timeline-events-tab.png) For help with navigating and using the trace viewer, click the **?** button at the top right of the timeline events tab bar. To refresh the timeline with new events from your application, click the refresh button (also in the upper right corner of the tab controls). ## Advanced debugging tools ### Enhance tracing To view more detailed tracing in the timeline events chart, use the options in the enhance tracing dropdown: {{site.alert.note}} Frame times might be negatively affected when these options are enabled. {{site.alert.end}} ![Screenshot of enhanced tracing options](/assets/images/docs/tools/devtools/enhanced-tracing.png) To see the new timeline events, reproduce the activity in your app that you are interested in tracing, and then select a frame to inspect the timeline. ### Track widget builds To see the `build()` method events in the timeline, enable the **Track Widget Builds** option. The name of the widget is shown in the timeline event. ![Screenshot of track widget builds](/assets/images/docs/tools/devtools/track-widget-builds.png) [Watch this video for an example of tracking widget builds][track-widgets] ### Track layouts To see render object layout events in the timeline, enable the **Track Layouts** option: ![Screenshot of track layouts](/assets/images/docs/tools/devtools/track-layouts.png) [Watch this video for an example of tracking layouts][track-layouts] ### Track paints To see render object paint events in the timeline, enable the **Track Paints** option: ![Screenshot of track paints](/assets/images/docs/tools/devtools/track-paints.png) [Watch this video for an example of tracking paints][track-paints] ## More debugging options To diagnose performance problems related to rendering layers, toggle off a rendering layer. These options are enabled by default. To see the effects on your app's performance, reproduce the activity in your app. Then select the new frames in the frames chart to inspect the timeline events with the layers disabled. If Raster time has significantly decreased, excessive use of the effects you disabled might be contributing to the jank you saw in your app. **Render Clip layers** : Disable this option to check whether excessive use of clipping is affecting performance. If performance improves with this option disabled, try to reduce the use of clipping effects in your app. **Render Opacity layers** : Disable this option to check whether excessive use of opacity effects are affecting performance. If performance improves with this option disabled, try to reduce the use of opacity effects in your app. **Render Physical Shape layers** : Disable this option to check whether excessive use of physical modeling effects are affecting performance, such as shadows or elevation. If performance improves with this option disabled, try to reduce the use of physical modeling effects in your app. ![Screenshot of more debugging options](/assets/images/docs/tools/devtools/more-debugging-options.png) ## Import and export DevTools supports importing and exporting performance snapshots. Clicking the export button (upper-right corner above the frame rendering chart) downloads a snapshot of the current data on the performance page. To import a performance snapshot, you can drag and drop the snapshot into DevTools from any page. **Note that DevTools only supports importing files that were originally exported from DevTools.** ## Other resources To learn how to monitor an app's performance and detect jank using DevTools, check out a guided [Performance View tutorial][performance-tutorial]. [GPU graph]: /perf/ui-performance#identifying-problems-in-the-gpu-graph [Flutter performance profiling]: /perf/ui-performance [Reduce shader compilation jank on mobile]: /perf/shader [Import and export]: #import-and-export [performance-tutorial]: {{site.medium}}/@fluttergems/mastering-dart-flutter-devtools-performance-view-part-8-of-8-4ae762f91230 [track-widgets]: {{site.yt.watch}}/_EYk-E29edo?t=623 [track-layouts]: {{site.yt.watch}}/_EYk-E29edo?t=676 [track-paints]: {{site.yt.watch}}/_EYk-E29edo?t=748
website/src/tools/devtools/performance.md/0
{ "file_path": "website/src/tools/devtools/performance.md", "repo_id": "website", "token_count": 2962 }
1,436
--- short-title: 2.11.2 release notes description: Release notes for Dart and Flutter DevTools version 2.11.2. toc: false --- {% include_relative release-notes-2.11.2-src.md %}
website/src/tools/devtools/release-notes/release-notes-2.11.2.md/0
{ "file_path": "website/src/tools/devtools/release-notes/release-notes-2.11.2.md", "repo_id": "website", "token_count": 61 }
1,437
--- short-title: 2.18.0 release notes description: Release notes for Dart and Flutter DevTools version 2.18.0. toc: false --- {% include_relative release-notes-2.18.0-src.md %}
website/src/tools/devtools/release-notes/release-notes-2.18.0.md/0
{ "file_path": "website/src/tools/devtools/release-notes/release-notes-2.18.0.md", "repo_id": "website", "token_count": 61 }
1,438
--- short-title: 2.26.1 release notes description: Release notes for Dart and Flutter DevTools version 2.26.1. toc: false --- {% include_relative release-notes-2.26.1-src.md %}
website/src/tools/devtools/release-notes/release-notes-2.26.1.md/0
{ "file_path": "website/src/tools/devtools/release-notes/release-notes-2.26.1.md", "repo_id": "website", "token_count": 61 }
1,439
--- short-title: 2.30.0 release notes description: Release notes for Dart and Flutter DevTools version 2.30.0. toc: false --- {% include_relative release-notes-2.30.0-src.md %}
website/src/tools/devtools/release-notes/release-notes-2.30.0.md/0
{ "file_path": "website/src/tools/devtools/release-notes/release-notes-2.30.0.md", "repo_id": "website", "token_count": 61 }
1,440
--- title: Install and run DevTools from VS Code description: Learn how to install and use DevTools from VS Code. --- ## Install the VS Code extensions To use the DevTools from VS Code, you need the [Dart extension][]. If you're debugging Flutter applications, you should also install the [Flutter extension][]. ## Start an application to debug Start a debug session for your application by opening the root folder of your project (the one containing `pubspec.yaml`) in VS Code and clicking **Run > Start Debugging** (`F5`). ## Launch DevTools Once the debug session is active and the application has started, the **Open DevTools** commands become available in the VS Code command palette (`F1`): ![Screenshot showing Open DevTools commands](/assets/images/docs/tools/vs-code/vscode_command.png){:width="100%"} The chosen tool will be opened embedded inside VS Code. ![Screenshot showing DevTools embedded in VS Code](/assets/images/docs/tools/vs-code/vscode_embedded.png){:width="100%"} You can choose to have DevTools always opened in a browser with the `dart.embedDevTools` setting, and control whether it opens as a full window or in a new column next to your current editor with the `dart.devToolsLocation` setting. A full list of Dart/Flutter settings are available [here](https://dartcode.org/docs/settings/) or in the [VS Code settings editor](https://code.visualstudio.com/docs/getstarted/settings#_settings-editor). Some recommendation settings for Dart/Flutter in VS Code can be found [here](https://dartcode.org/docs/recommended-settings/). You can also see whether DevTools is running and launch it in a browser from the language status area (the `{}` icon next to **Dart** in the status bar). ![Screenshot showing DevTools in the VS Code language status area](/assets/images/docs/tools/vs-code/vscode_status_bar.png){:width="100%"} [Dart extension]: https://marketplace.visualstudio.com/items?itemName=Dart-Code.dart-code [Flutter extension]: https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
website/src/tools/devtools/vscode.md/0
{ "file_path": "website/src/tools/devtools/vscode.md", "repo_id": "website", "token_count": 574 }
1,441
--- title: Staggered animations description: How to write a staggered animation in Flutter. short-title: Staggered --- {{site.alert.secondary}} <h4>What you'll learn</h4> * A staggered animation consists of sequential or overlapping animations. * To create a staggered animation, use multiple `Animation` objects. * One `AnimationController` controls all of the `Animation`s. * Each `Animation` object specifies the animation during an `Interval`. * For each property being animated, create a `Tween`. {{site.alert.end}} {{site.alert.secondary}} **Terminology:** If the concept of tweens or tweening is new to you, see the [Animations in Flutter tutorial][]. {{site.alert.end}} Staggered animations are a straightforward concept: visual changes happen as a series of operations, rather than all at once. The animation might be purely sequential, with one change occurring after the next, or it might partially or completely overlap. It might also have gaps, where no changes occur. This guide shows how to build a staggered animation in Flutter. {{site.alert.secondary}} <h4>Examples</h4> This guide explains the basic_staggered_animation example. You can also refer to a more complex example, staggered_pic_selection. [basic_staggered_animation][] : Shows a series of sequential and overlapping animations of a single widget. Tapping the screen begins an animation that changes opacity, size, shape, color, and padding. [staggered_pic_selection][] : Shows deleting an image from a list of images displayed in one of three sizes. This example uses two [animation controllers][]: one for image selection/deselection, and one for image deletion. The selection/deselection animation is staggered. (To see this effect, you might need to increase the `timeDilation` value.) Select one of the largest images&mdash;it shrinks as it displays a checkmark inside a blue circle. Next, select one of the smallest images&mdash;the large image expands as the checkmark disappears. Before the large image has finished expanding, the small image shrinks to display its checkmark. This staggered behavior is similar to what you might see in Google Photos. {{site.alert.end}} The following video demonstrates the animation performed by basic_staggered_animation: <iframe width="560" height="315" src="{{site.yt.embed}}/0fFvnZemmh8" title="Watch this example of a staggered animation in Flutter" {{site.yt.set-short}}></iframe> In the video, you see the following animation of a single widget, which begins as a bordered blue square with slightly rounded corners. The square runs through changes in the following order: 1. Fades in 1. Widens 1. Becomes taller while moving upwards 1. Transforms into a bordered circle 1. Changes color to orange After running forward, the animation runs in reverse. {{site.alert.secondary}} **New to Flutter?** This page assumes you know how to create a layout using Flutter's widgets. For more information, see [Building Layouts in Flutter][]. {{site.alert.end}} ## Basic structure of a staggered animation {{site.alert.secondary}} <h4>What's the point?</h4> * All of the animations are driven by the same [`AnimationController`][]. * Regardless of how long the animation lasts in real time, the controller's values must be between 0.0 and 1.0, inclusive. * Each animation has an [`Interval`][] between 0.0 and 1.0, inclusive. * For each property that animates in an interval, create a [`Tween`][]. The `Tween` specifies the start and end values for that property. * The `Tween` produces an [`Animation`][] object that is managed by the controller. {{site.alert.end}} {% comment %} The app is essentially animating a `Container` whose decoration and size are animated. The `Container` is within another `Container` whose padding moves the inner container around and an `Opacity` widget that's used to fade everything in and out. {% endcomment %} The following diagram shows the `Interval`s used in the [basic_staggered_animation][] example. You might notice the following characteristics: * The opacity changes during the first 10% of the timeline. * A tiny gap occurs between the change in opacity, and the change in width. * Nothing animates during the last 25% of the timeline. * Increasing the padding makes the widget appear to rise upward. * Increasing the border radius to 0.5, transforms the square with rounded corners into a circle. * The padding and height changes occur during the same exact interval, but they don't have to. ![Diagram showing the interval specified for each motion](/assets/images/docs/ui/animations/StaggeredAnimationIntervals.png) To set up the animation: * Create an `AnimationController` that manages all of the `Animations`. * Create a `Tween` for each property being animated. * The `Tween` defines a range of values. * The `Tween`'s `animate` method requires the `parent` controller, and produces an `Animation` for that property. * Specify the interval on the `Animation`'s `curve` property. When the controlling animation's value changes, the new animation's value changes, triggering the UI to update. The following code creates a tween for the `width` property. It builds a [`CurvedAnimation`][], specifying an eased curve. See [`Curves`][] for other available pre-defined animation curves. ```dart width = Tween<double>( begin: 50.0, end: 150.0, ).animate( CurvedAnimation( parent: controller, curve: const Interval( 0.125, 0.250, curve: Curves.ease, ), ), ), ``` The `begin` and `end` values don't have to be doubles. The following code builds the tween for the `borderRadius` property (which controls the roundness of the square's corners), using `BorderRadius.circular()`. ```dart borderRadius = BorderRadiusTween( begin: BorderRadius.circular(4), end: BorderRadius.circular(75), ).animate( CurvedAnimation( parent: controller, curve: const Interval( 0.375, 0.500, curve: Curves.ease, ), ), ), ``` ### Complete staggered animation Like all interactive widgets, the complete animation consists of a widget pair: a stateless and a stateful widget. The stateless widget specifies the `Tween`s, defines the `Animation` objects, and provides a `build()` function responsible for building the animating portion of the widget tree. The stateful widget creates the controller, plays the animation, and builds the non-animating portion of the widget tree. The animation begins when a tap is detected anywhere in the screen. [Full code for basic_staggered_animation's main.dart][] ### Stateless widget: StaggerAnimation In the stateless widget, `StaggerAnimation`, the `build()` function instantiates an [`AnimatedBuilder`][]&mdash;a general purpose widget for building animations. The `AnimatedBuilder` builds a widget and configures it using the `Tweens`' current values. The example creates a function named `_buildAnimation()` (which performs the actual UI updates), and assigns it to its `builder` property. AnimatedBuilder listens to notifications from the animation controller, marking the widget tree dirty as values change. For each tick of the animation, the values are updated, resulting in a call to `_buildAnimation()`. {% prettify dart %} [!class StaggerAnimation extends StatelessWidget!] { StaggerAnimation({super.key, required this.controller}) : // Each animation defined here transforms its value during the subset // of the controller's duration defined by the animation's interval. // For example the opacity animation transforms its value during // the first 10% of the controller's duration. [!opacity = Tween<double>!]( begin: 0.0, end: 1.0, ).animate( CurvedAnimation( parent: controller, curve: const Interval( 0.0, 0.100, curve: Curves.ease, ), ), ), // ... Other tween definitions ... ); [!final AnimationController controller;!] [!final Animation<double> opacity;!] [!final Animation<double> width;!] [!final Animation<double> height;!] [!final Animation<EdgeInsets> padding;!] [!final Animation<BorderRadius?> borderRadius;!] [!final Animation<Color?> color;!] // This function is called each time the controller "ticks" a new frame. // When it runs, all of the animation's values will have been // updated to reflect the controller's current value. [!Widget _buildAnimation(BuildContext context, Widget? child)!] { return Container( padding: padding.value, alignment: Alignment.bottomCenter, child: Opacity( opacity: opacity.value, child: Container( width: width.value, height: height.value, decoration: BoxDecoration( color: color.value, border: Border.all( color: Colors.indigo[300]!, width: 3, ), borderRadius: borderRadius.value, ), ), ), ); } @override [!Widget build(BuildContext context)!] { return [!AnimatedBuilder!]( [!builder: _buildAnimation!], animation: controller, ); } } {% endprettify %} ### Stateful widget: StaggerDemo The stateful widget, `StaggerDemo`, creates the `AnimationController` (the one who rules them all), specifying a 2000 ms duration. It plays the animation, and builds the non-animating portion of the widget tree. The animation begins when a tap is detected in the screen. The animation runs forward, then backward. {% prettify dart %} [!class StaggerDemo extends StatefulWidget!] { @override State<StaggerDemo> createState() => _StaggerDemoState(); } class _StaggerDemoState extends State<StaggerDemo> with TickerProviderStateMixin { late AnimationController_controller; @override void initState() { super.initState(); _controller = AnimationController( duration: const Duration(milliseconds: 2000), vsync: this, ); } // ...Boilerplate... [!Future<void> _playAnimation() async!] { try { [!await _controller.forward().orCancel;!] [!await _controller.reverse().orCancel;!] } on TickerCanceled { // The animation got canceled, probably because it was disposed of. } } @override [!Widget build(BuildContext context)!] { timeDilation = 10.0; // 1.0 is normal animation speed. return Scaffold( appBar: AppBar( title: const Text('Staggered Animation'), ), body: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { _playAnimation(); }, child: Center( child: Container( width: 300, height: 300, decoration: BoxDecoration( color: Colors.black.withOpacity(0.1), border: Border.all( color: Colors.black.withOpacity(0.5), ), ), child: StaggerAnimation(controller:_controller.view), ), ), ), ); } } {% endprettify %} [`Animation`]: {{site.api}}/flutter/animation/Animation-class.html [animation controllers]: {{site.api}}/flutter/animation/AnimationController-class.html [`AnimationController`]: {{site.api}}/flutter/animation/AnimationController-class.html [`AnimatedBuilder`]: {{site.api}}/flutter/widgets/AnimatedBuilder-class.html [Animations in Flutter tutorial]: /ui/animations/tutorial [basic_staggered_animation]: {{site.repo.this}}/tree/{{site.branch}}/examples/_animation/basic_staggered_animation [Building Layouts in Flutter]: /ui/layout [staggered_pic_selection]: {{site.repo.this}}/tree/{{site.branch}}/examples/_animation/staggered_pic_selection [`CurvedAnimation`]: {{site.api}}/flutter/animation/CurvedAnimation-class.html [`Curves`]: {{site.api}}/flutter/animation/Curves-class.html [Full code for basic_staggered_animation's main.dart]: {{site.repo.this}}/tree/{{site.branch}}/examples/_animation/basic_staggered_animation/lib/main.dart [`Interval`]: {{site.api}}/flutter/animation/Interval-class.html [`Tween`]: {{site.api}}/flutter/animation/Tween-class.html
website/src/ui/animations/staggered-animations.md/0
{ "file_path": "website/src/ui/animations/staggered-animations.md", "repo_id": "website", "token_count": 3953 }
1,442
--- layout: toc title: Input & forms description: Content covering handling input and adding forms to Flutter apps. sitemap: false ---
website/src/ui/interactivity/input/index.md/0
{ "file_path": "website/src/ui/interactivity/input/index.md", "repo_id": "website", "token_count": 36 }
1,443
--- title: Async widgets short-title: Async description: A catalog of Flutter widgets for handling asynchronous code. --- {% include docs/catalogpage.html category="Async" %}
website/src/ui/widgets/async.md/0
{ "file_path": "website/src/ui/widgets/async.md", "repo_id": "website", "token_count": 49 }
1,444
// Copyright 2024 The Flutter Authors. 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:args/command_runner.dart'; import 'src/commands/analyze_dart.dart'; import 'src/commands/check_all.dart'; import 'src/commands/check_link_references.dart'; import 'src/commands/check_links.dart'; import 'src/commands/format_dart.dart'; import 'src/commands/refresh_excerpts.dart'; import 'src/commands/test_dart.dart'; import 'src/commands/verify_firebase_json.dart'; /// The root command runner of the `flutter_site` command. /// To learn about it and its subcommands, /// run `dart run flutter_site --help`. final class FlutterSiteCommandRunner extends CommandRunner<int> { FlutterSiteCommandRunner() : super( 'flutter_site', 'Infrastructure tooling for the Flutter documentation website.', ) { addCommand(CheckLinksCommand()); addCommand(CheckLinkReferencesCommand()); addCommand(VerifyFirebaseJsonCommand()); addCommand(RefreshExcerptsCommand()); addCommand(FormatDartCommand()); addCommand(AnalyzeDartCommand()); addCommand(TestDartCommand()); addCommand(CheckAllCommand()); } }
website/tool/flutter_site/lib/flutter_site.dart/0
{ "file_path": "website/tool/flutter_site/lib/flutter_site.dart", "repo_id": "website", "token_count": 420 }
1,445
org.gradle.jvmargs=-Xmx4G android.useAndroidX=true android.enableJetifier=true
codelabs/adaptive_app/step_03/android/gradle.properties/0
{ "file_path": "codelabs/adaptive_app/step_03/android/gradle.properties", "repo_id": "codelabs", "token_count": 30 }
0
// Copyright 2022 The Flutter Authors. 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:googleapis/youtube/v3.dart'; import 'package:provider/provider.dart'; import 'app_state.dart'; class Playlists extends StatelessWidget { const Playlists({super.key, required this.playlistSelected}); final PlaylistsListSelected playlistSelected; @override Widget build(BuildContext context) { return Consumer<FlutterDevPlaylists>( builder: (context, flutterDev, child) { final playlists = flutterDev.playlists; if (playlists.isEmpty) { return const Center( child: CircularProgressIndicator(), ); } return _PlaylistsListView( items: playlists, playlistSelected: playlistSelected, ); }, ); } } typedef PlaylistsListSelected = void Function(Playlist playlist); class _PlaylistsListView extends StatefulWidget { const _PlaylistsListView({ required this.items, required this.playlistSelected, }); final List<Playlist> items; final PlaylistsListSelected playlistSelected; @override State<_PlaylistsListView> createState() => _PlaylistsListViewState(); } class _PlaylistsListViewState extends State<_PlaylistsListView> { late ScrollController _scrollController; @override void initState() { super.initState(); _scrollController = ScrollController(); } @override void dispose() { _scrollController.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return ListView.builder( controller: _scrollController, itemCount: widget.items.length, itemBuilder: (context, index) { var playlist = widget.items[index]; return Padding( padding: const EdgeInsets.all(8.0), child: ListTile( leading: Image.network( playlist.snippet!.thumbnails!.default_!.url!, ), title: Text(playlist.snippet!.title!), subtitle: Text( playlist.snippet!.description!, ), onTap: () { widget.playlistSelected(playlist); }, ), ); }, ); } }
codelabs/adaptive_app/step_05/lib/src/playlists.dart/0
{ "file_path": "codelabs/adaptive_app/step_05/lib/src/playlists.dart", "repo_id": "codelabs", "token_count": 919 }
1
#include "../../Flutter/Flutter-Release.xcconfig" #include "Warnings.xcconfig"
codelabs/adaptive_app/step_05/macos/Runner/Configs/Release.xcconfig/0
{ "file_path": "codelabs/adaptive_app/step_05/macos/Runner/Configs/Release.xcconfig", "repo_id": "codelabs", "token_count": 32 }
2
// Copyright 2022 The Flutter Authors. 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'; class AdaptiveText extends StatelessWidget { const AdaptiveText(this.data, {super.key, this.style}); final String data; final TextStyle? style; @override Widget build(BuildContext context) { return switch (Theme.of(context).platform) { TargetPlatform.android || TargetPlatform.iOS => Text(data, style: style), _ => SelectableText(data, style: style) }; } }
codelabs/adaptive_app/step_07/lib/src/adaptive_text.dart/0
{ "file_path": "codelabs/adaptive_app/step_07/lib/src/adaptive_text.dart", "repo_id": "codelabs", "token_count": 184 }
3
// // Generated file. Do not edit. // import FlutterMacOS import Foundation import google_sign_in_ios import url_launcher_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FLTGoogleSignInPlugin.register(with: registry.registrar(forPlugin: "FLTGoogleSignInPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) }
codelabs/adaptive_app/step_07/macos/Flutter/GeneratedPluginRegistrant.swift/0
{ "file_path": "codelabs/adaptive_app/step_07/macos/Flutter/GeneratedPluginRegistrant.swift", "repo_id": "codelabs", "token_count": 122 }
4
org.gradle.jvmargs=-Xmx4G android.useAndroidX=true android.enableJetifier=true
codelabs/animated-responsive-layout/step_03/android/gradle.properties/0
{ "file_path": "codelabs/animated-responsive-layout/step_03/android/gradle.properties", "repo_id": "codelabs", "token_count": 30 }
5
// Copyright 2022 The Flutter Authors. 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 'models/data.dart' as data; import 'models/models.dart'; import 'widgets/email_list_view.dart'; void main() { runApp(const MainApp()); } class MainApp extends StatelessWidget { const MainApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( theme: ThemeData.light(useMaterial3: true), home: Feed(currentUser: data.user_0), ); } } class Feed extends StatefulWidget { const Feed({ super.key, required this.currentUser, }); final User currentUser; @override State<Feed> createState() => _FeedState(); } class _FeedState extends State<Feed> { late final _colorScheme = Theme.of(context).colorScheme; late final _backgroundColor = Color.alphaBlend( _colorScheme.primary.withOpacity(0.14), _colorScheme.surface); @override Widget build(BuildContext context) { return Scaffold( body: Container( color: _backgroundColor, child: EmailListView( currentUser: widget.currentUser, ), ), floatingActionButton: FloatingActionButton( backgroundColor: _colorScheme.tertiaryContainer, foregroundColor: _colorScheme.onTertiaryContainer, onPressed: () {}, child: const Icon(Icons.add), ), ); } }
codelabs/animated-responsive-layout/step_04/lib/main.dart/0
{ "file_path": "codelabs/animated-responsive-layout/step_04/lib/main.dart", "repo_id": "codelabs", "token_count": 543 }
6
#include "../../Flutter/Flutter-Debug.xcconfig" #include "Warnings.xcconfig"
codelabs/animated-responsive-layout/step_06/macos/Runner/Configs/Debug.xcconfig/0
{ "file_path": "codelabs/animated-responsive-layout/step_06/macos/Runner/Configs/Debug.xcconfig", "repo_id": "codelabs", "token_count": 32 }
7
// Copyright 2022 The Flutter Authors. 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 '../animations.dart'; import '../destinations.dart'; import '../transitions/bottom_bar_transition.dart'; class DisappearingBottomNavigationBar extends StatelessWidget { const DisappearingBottomNavigationBar({ super.key, required this.barAnimation, required this.selectedIndex, this.onDestinationSelected, }); final BarAnimation barAnimation; final int selectedIndex; final ValueChanged<int>? onDestinationSelected; @override Widget build(BuildContext context) { return BottomBarTransition( animation: barAnimation, backgroundColor: Colors.white, child: NavigationBar( elevation: 0, backgroundColor: Colors.white, destinations: destinations.map<NavigationDestination>((d) { return NavigationDestination( icon: Icon(d.icon), label: d.label, ); }).toList(), selectedIndex: selectedIndex, onDestinationSelected: onDestinationSelected, ), ); } }
codelabs/animated-responsive-layout/step_07/lib/widgets/disappearing_bottom_navigation_bar.dart/0
{ "file_path": "codelabs/animated-responsive-layout/step_07/lib/widgets/disappearing_bottom_navigation_bar.dart", "repo_id": "codelabs", "token_count": 429 }
8
#include "ephemeral/Flutter-Generated.xcconfig"
codelabs/animated-responsive-layout/step_07/macos/Flutter/Flutter-Debug.xcconfig/0
{ "file_path": "codelabs/animated-responsive-layout/step_07/macos/Flutter/Flutter-Debug.xcconfig", "repo_id": "codelabs", "token_count": 19 }
9
org.gradle.jvmargs=-Xmx4G android.useAndroidX=true android.enableJetifier=true
codelabs/boring_to_beautiful/final/android/gradle.properties/0
{ "file_path": "codelabs/boring_to_beautiful/final/android/gradle.properties", "repo_id": "codelabs", "token_count": 30 }
10
// Copyright 2022 The Flutter Authors. 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'; class OutlinedCard extends StatefulWidget { const OutlinedCard({ super.key, required this.child, this.clickable = true, }); final Widget child; final bool clickable; @override State<OutlinedCard> createState() => _OutlinedCardState(); } class _OutlinedCardState extends State<OutlinedCard> { bool _hovered = false; @override Widget build(BuildContext context) { final borderRadius = BorderRadius.circular(_hovered ? 20 : 8); const animationCurve = Curves.easeInOut; return MouseRegion( onEnter: (_) { if (!widget.clickable) return; setState(() { _hovered = true; }); }, onExit: (_) { if (!widget.clickable) return; setState(() { _hovered = false; }); }, cursor: widget.clickable ? SystemMouseCursors.click : SystemMouseCursors.basic, child: AnimatedContainer( duration: kThemeAnimationDuration, curve: animationCurve, decoration: BoxDecoration( border: Border.all( color: Theme.of(context).colorScheme.outline, width: 1, ), borderRadius: borderRadius, ), foregroundDecoration: BoxDecoration( color: Theme.of(context).colorScheme.onSurface.withOpacity( _hovered ? 0.12 : 0, ), borderRadius: borderRadius, ), child: TweenAnimationBuilder<BorderRadius>( duration: kThemeAnimationDuration, curve: animationCurve, tween: Tween(begin: BorderRadius.zero, end: borderRadius), builder: (context, borderRadius, child) => ClipRRect( clipBehavior: Clip.antiAlias, borderRadius: borderRadius, child: child, ), child: widget.child, ), ), ); } }
codelabs/boring_to_beautiful/final/lib/src/shared/views/outlined_card.dart/0
{ "file_path": "codelabs/boring_to_beautiful/final/lib/src/shared/views/outlined_card.dart", "repo_id": "codelabs", "token_count": 912 }
11
org.gradle.jvmargs=-Xmx4G android.useAndroidX=true android.enableJetifier=true
codelabs/boring_to_beautiful/step_02/android/gradle.properties/0
{ "file_path": "codelabs/boring_to_beautiful/step_02/android/gradle.properties", "repo_id": "codelabs", "token_count": 30 }
12
org.gradle.jvmargs=-Xmx4G android.useAndroidX=true android.enableJetifier=true
codelabs/boring_to_beautiful/step_04/android/gradle.properties/0
{ "file_path": "codelabs/boring_to_beautiful/step_04/android/gradle.properties", "repo_id": "codelabs", "token_count": 30 }
13
org.gradle.jvmargs=-Xmx4G android.useAndroidX=true android.enableJetifier=true
codelabs/boring_to_beautiful/step_06/android/gradle.properties/0
{ "file_path": "codelabs/boring_to_beautiful/step_06/android/gradle.properties", "repo_id": "codelabs", "token_count": 30 }
14
include: ../../analysis_options.yaml
codelabs/brick_breaker/step_04/analysis_options.yaml/0
{ "file_path": "codelabs/brick_breaker/step_04/analysis_options.yaml", "repo_id": "codelabs", "token_count": 12 }
15
const gameWidth = 820.0; const gameHeight = 1600.0;
codelabs/brick_breaker/step_04/lib/src/config.dart/0
{ "file_path": "codelabs/brick_breaker/step_04/lib/src/config.dart", "repo_id": "codelabs", "token_count": 18 }
16
#include "../../Flutter/Flutter-Release.xcconfig" #include "Warnings.xcconfig"
codelabs/brick_breaker/step_04/macos/Runner/Configs/Release.xcconfig/0
{ "file_path": "codelabs/brick_breaker/step_04/macos/Runner/Configs/Release.xcconfig", "repo_id": "codelabs", "token_count": 32 }
17
import 'dart:async'; import 'dart:math' as math; import 'package:flame/components.dart'; import 'package:flame/game.dart'; import 'components/components.dart'; import 'config.dart'; class BrickBreaker extends FlameGame { BrickBreaker() : super( camera: CameraComponent.withFixedResolution( width: gameWidth, height: gameHeight, ), ); final rand = math.Random(); double get width => size.x; double get height => size.y; @override FutureOr<void> onLoad() async { super.onLoad(); camera.viewfinder.anchor = Anchor.topLeft; world.add(PlayArea()); world.add(Ball( radius: ballRadius, position: size / 2, velocity: Vector2((rand.nextDouble() - 0.5) * width, height * 0.2) .normalized() ..scale(height / 4))); debugMode = true; } }
codelabs/brick_breaker/step_05/lib/src/brick_breaker.dart/0
{ "file_path": "codelabs/brick_breaker/step_05/lib/src/brick_breaker.dart", "repo_id": "codelabs", "token_count": 368 }
18
include: ../../analysis_options.yaml
codelabs/brick_breaker/step_08/analysis_options.yaml/0
{ "file_path": "codelabs/brick_breaker/step_08/analysis_options.yaml", "repo_id": "codelabs", "token_count": 12 }
19
#import "GeneratedPluginRegistrant.h"
codelabs/brick_breaker/step_09/ios/Runner/Runner-Bridging-Header.h/0
{ "file_path": "codelabs/brick_breaker/step_09/ios/Runner/Runner-Bridging-Header.h", "repo_id": "codelabs", "token_count": 13 }
20
#import "GeneratedPluginRegistrant.h"
codelabs/dart-patterns-and-records/step_03/ios/Runner/Runner-Bridging-Header.h/0
{ "file_path": "codelabs/dart-patterns-and-records/step_03/ios/Runner/Runner-Bridging-Header.h", "repo_id": "codelabs", "token_count": 13 }
21
#include "../../Flutter/Flutter-Debug.xcconfig" #include "Warnings.xcconfig"
codelabs/dart-patterns-and-records/step_03/macos/Runner/Configs/Debug.xcconfig/0
{ "file_path": "codelabs/dart-patterns-and-records/step_03/macos/Runner/Configs/Debug.xcconfig", "repo_id": "codelabs", "token_count": 32 }
22
#include "Generated.xcconfig"
codelabs/dart-patterns-and-records/step_07_b/ios/Flutter/Debug.xcconfig/0
{ "file_path": "codelabs/dart-patterns-and-records/step_07_b/ios/Flutter/Debug.xcconfig", "repo_id": "codelabs", "token_count": 12 }
23
#include "ephemeral/Flutter-Generated.xcconfig"
codelabs/dart-patterns-and-records/step_08/macos/Flutter/Flutter-Release.xcconfig/0
{ "file_path": "codelabs/dart-patterns-and-records/step_08/macos/Flutter/Flutter-Release.xcconfig", "repo_id": "codelabs", "token_count": 19 }
24