1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-12 07:48:55 +00:00
Files
samples/platform_channels/lib/src/add_pet_details.dart
Miguel Beltran 329c531dfc Migrate platform_channels to go_router (#1533)
* Migrate platform_channels to go_router

* code format

* move addPetDetails into a subroute of petListScreen

* code format

* refactor router and fix tests

* removed unused import

* Elide `web_dashboard` from Master CI (#1535)

* Bump ossf/scorecard-action from 2.1.0 to 2.1.1 (#1536)

Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.1.0 to 2.1.1.
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](937ffa90d7...15c10fcf1c)

---
updated-dependencies:
- dependency-name: ossf/scorecard-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* go_router 6.0.0

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Brett Morgan <brett.morgan@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-20 19:03:26 +10:00

90 lines
2.5 KiB
Dart

// 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';
import 'package:go_router/go_router.dart';
import 'package:platform_channels/src/pet_list_message_channel.dart';
/// Demonstrates how to use [BasicMessageChannel] to send a message to platform.
///
/// The widget uses [TextField] and [RadioListTile] to take the [PetDetails.breed] and
/// [PetDetails.petType] from the user respectively.
class AddPetDetails extends StatefulWidget {
const AddPetDetails({super.key});
@override
State<AddPetDetails> createState() => _AddPetDetailsState();
}
class _AddPetDetailsState extends State<AddPetDetails> {
final breedTextController = TextEditingController();
String petType = 'Dog';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Add Pet Details'),
actions: [
IconButton(
icon: const Icon(Icons.add),
onPressed: () {
PetListMessageChannel.addPetDetails(
PetDetails(
petType: petType,
breed: breedTextController.text,
),
);
context.pop();
},
)
],
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
const SizedBox(
height: 8,
),
TextField(
controller: breedTextController,
decoration: const InputDecoration(
border: OutlineInputBorder(),
filled: true,
hintText: 'Breed of pet',
labelText: 'Breed',
),
),
const SizedBox(
height: 8,
),
RadioListTile<String>(
title: const Text('Dog'),
value: 'Dog',
groupValue: petType,
onChanged: (value) {
setState(() {
petType = value!;
});
},
),
RadioListTile<String>(
title: const Text('Cat'),
value: 'Cat',
groupValue: petType,
onChanged: (value) {
setState(() {
petType = value!;
});
},
),
],
),
),
);
}
}