snapshot of https://github.com/flutter/samples.git (main, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Main Branch CI / Test Flutter beta on ubuntu-latest (push) Has been skipped
Main Branch CI / Test Flutter stable on ubuntu-latest (push) Has been skipped
Main Branch CI / Test Flutter beta on macos-latest (push) Has been cancelled
Main Branch CI / Test Flutter stable on macos-latest (push) Has been cancelled
Some checks failed
Main Branch CI / Test Flutter beta on ubuntu-latest (push) Has been skipped
Main Branch CI / Test Flutter stable on ubuntu-latest (push) Has been skipped
Main Branch CI / Test Flutter beta on macos-latest (push) Has been cancelled
Main Branch CI / Test Flutter stable on macos-latest (push) Has been cancelled
This commit is contained in:
113
platform_design/lib/settings_tab.dart
Normal file
113
platform_design/lib/settings_tab.dart
Normal file
@@ -0,0 +1,113 @@
|
||||
// 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/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'widgets.dart';
|
||||
|
||||
class SettingsTab extends StatefulWidget {
|
||||
static const title = 'Settings';
|
||||
static const androidIcon = Icon(Icons.settings);
|
||||
static const iosIcon = Icon(CupertinoIcons.gear);
|
||||
|
||||
const SettingsTab({super.key});
|
||||
|
||||
@override
|
||||
State<SettingsTab> createState() => _SettingsTabState();
|
||||
}
|
||||
|
||||
class _SettingsTabState extends State<SettingsTab> {
|
||||
var switch1 = false;
|
||||
var switch2 = true;
|
||||
var switch3 = true;
|
||||
var switch4 = true;
|
||||
var switch5 = true;
|
||||
var switch6 = false;
|
||||
var switch7 = true;
|
||||
|
||||
Widget _buildList() {
|
||||
return ListView(
|
||||
children: [
|
||||
const Padding(padding: EdgeInsets.only(top: 24)),
|
||||
ListTile(
|
||||
title: const Text('Send me marketing emails'),
|
||||
// The Material switch has a platform adaptive constructor.
|
||||
trailing: Switch.adaptive(
|
||||
value: switch1,
|
||||
onChanged: (value) => setState(() => switch1 = value),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: const Text('Enable notifications'),
|
||||
trailing: Switch.adaptive(
|
||||
value: switch2,
|
||||
onChanged: (value) => setState(() => switch2 = value),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: const Text('Remind me to rate this app'),
|
||||
trailing: Switch.adaptive(
|
||||
value: switch3,
|
||||
onChanged: (value) => setState(() => switch3 = value),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: const Text('Background song refresh'),
|
||||
trailing: Switch.adaptive(
|
||||
value: switch4,
|
||||
onChanged: (value) => setState(() => switch4 = value),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: const Text('Recommend me songs based on my location'),
|
||||
trailing: Switch.adaptive(
|
||||
value: switch5,
|
||||
onChanged: (value) => setState(() => switch5 = value),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: const Text('Auto-transition playback to cast devices'),
|
||||
trailing: Switch.adaptive(
|
||||
value: switch6,
|
||||
onChanged: (value) => setState(() => switch6 = value),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: const Text('Find friends from my contact list'),
|
||||
trailing: Switch.adaptive(
|
||||
value: switch7,
|
||||
onChanged: (value) => setState(() => switch7 = value),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// Non-shared code below because this tab uses different scaffolds.
|
||||
// ===========================================================================
|
||||
|
||||
Widget _buildAndroid(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text(SettingsTab.title)),
|
||||
body: _buildList(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildIos(BuildContext context) {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: const CupertinoNavigationBar(),
|
||||
child: _buildList(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(context) {
|
||||
return PlatformWidget(
|
||||
androidBuilder: _buildAndroid,
|
||||
iosBuilder: _buildIos,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user