mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
I got carried away with Gemini and basically rewrote CI and the release process for the new LLM reality. This work was largely completed by Gemini. - Bump all SDK versions to the current beta (3.9.0-0) - Run `flutter channel beta` - Wrote `ci_script.dart` to replace the bash scripts - Converted repository to pub workspace #2499 - Added llm.md and release.md - Added redirect for deprecated Samples Index ## Pre-launch Checklist - [x] I read the [Flutter Style Guide] _recently_, and have followed its advice. - [x] I signed the [CLA]. - [x] I read the [Contributors Guide]. - [x] I have added sample code updates to the [changelog]. - [x] I updated/added relevant documentation (doc comments with `///`).
56 lines
1.6 KiB
Dart
56 lines
1.6 KiB
Dart
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
typedef PlatformCallback = void Function(TargetPlatform platform);
|
|
|
|
class PlatformSelector extends StatefulWidget {
|
|
const PlatformSelector({super.key, required this.onChangedPlatform});
|
|
|
|
final PlatformCallback onChangedPlatform;
|
|
|
|
@override
|
|
State<PlatformSelector> createState() => _PlatformSelectorState();
|
|
}
|
|
|
|
class _PlatformSelectorState extends State<PlatformSelector> {
|
|
static const int targetPlatformStringLength = 15; // 'TargetPlatform.'.length
|
|
|
|
static String _platformToString(TargetPlatform platform) {
|
|
return platform.toString().substring(targetPlatformStringLength);
|
|
}
|
|
|
|
final TargetPlatform originaPlatform = defaultTargetPlatform;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SizedBox(
|
|
width: 170.0,
|
|
child: DropdownButton<TargetPlatform>(
|
|
value: defaultTargetPlatform,
|
|
icon: const Icon(Icons.arrow_downward),
|
|
elevation: 16,
|
|
onChanged: (value) {
|
|
if (value == null) {
|
|
return;
|
|
}
|
|
|
|
widget.onChangedPlatform(value);
|
|
setState(() {});
|
|
},
|
|
items: TargetPlatform.values.map((platform) {
|
|
return DropdownMenuItem<TargetPlatform>(
|
|
value: platform,
|
|
child: Row(
|
|
children: <Widget>[
|
|
if (platform == originaPlatform)
|
|
const Icon(Icons.home, color: Color(0xff616161)),
|
|
Text(_platformToString(platform)),
|
|
],
|
|
),
|
|
);
|
|
}).toList(),
|
|
),
|
|
);
|
|
}
|
|
}
|