mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

As of https://github.com/flutter/engine/pull/47727 the web engine is able to find a default widget to focus on when a new route it pushed. The mobile engine already did that for some time. So `autofocus` is no longer necessary.
54 lines
1.2 KiB
Dart
54 lines
1.2 KiB
Dart
// Copyright 2014 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 'use_cases.dart';
|
|
|
|
class SliderUseCase extends UseCase {
|
|
|
|
@override
|
|
String get name => 'Slider';
|
|
|
|
@override
|
|
String get route => '/slider';
|
|
|
|
@override
|
|
Widget build(BuildContext context) => const MainWidget();
|
|
}
|
|
|
|
class MainWidget extends StatefulWidget {
|
|
const MainWidget({super.key});
|
|
|
|
@override
|
|
State<MainWidget> createState() => MainWidgetState();
|
|
}
|
|
|
|
class MainWidgetState extends State<MainWidget> {
|
|
double currentSliderValue = 20;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
|
title: const Text('Slider'),
|
|
),
|
|
body: Center(
|
|
child: Slider(
|
|
value: currentSliderValue,
|
|
max: 100,
|
|
divisions: 5,
|
|
label: currentSliderValue.round().toString(),
|
|
onChanged: (double value) {
|
|
setState(() {
|
|
currentSliderValue = value;
|
|
});
|
|
},
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|