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

* changed controlsBuilder signature combined all parameters into ControlsDetails class * sample fixes * updates to docstrings * switched to positional argument for stepper.controlsbuilder * Merge branch 'master' into stepper-builder-fix
89 lines
2.7 KiB
Dart
89 lines
2.7 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.
|
|
|
|
// Template: dev/snippets/config/templates/stateless_widget_scaffold.tmpl
|
|
//
|
|
// Comment lines marked with "▼▼▼" and "▲▲▲" are used for authoring
|
|
// of samples, and may be ignored if you are just exploring the sample.
|
|
|
|
// Flutter code sample for Stepper.controlsBuilder
|
|
//
|
|
//***************************************************************************
|
|
//* ▼▼▼▼▼▼▼▼ description ▼▼▼▼▼▼▼▼ (do not modify or remove section marker)
|
|
|
|
// Creates a stepper control with custom buttons.
|
|
|
|
//* ▲▲▲▲▲▲▲▲ description ▲▲▲▲▲▲▲▲ (do not modify or remove section marker)
|
|
//***************************************************************************
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
void main() => runApp(const MyApp());
|
|
|
|
/// This is the main application widget.
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({Key? key}) : super(key: key);
|
|
|
|
static const String _title = 'Flutter Code Sample';
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
title: _title,
|
|
home: Scaffold(
|
|
appBar: AppBar(title: const Text(_title)),
|
|
body: const MyStatelessWidget(),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// This is the stateless widget that the main application instantiates.
|
|
class MyStatelessWidget extends StatelessWidget {
|
|
const MyStatelessWidget({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
//********************************************************************
|
|
//* ▼▼▼▼▼▼▼▼ code ▼▼▼▼▼▼▼▼ (do not modify or remove section marker)
|
|
|
|
Widget build(BuildContext context) {
|
|
return Stepper(
|
|
controlsBuilder: (BuildContext context, ControlsDetails details) {
|
|
return Row(
|
|
children: <Widget>[
|
|
TextButton(
|
|
onPressed: details.onStepContinue,
|
|
child: const Text('NEXT'),
|
|
),
|
|
TextButton(
|
|
onPressed: details.onStepCancel,
|
|
child: const Text('CANCEL'),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
steps: const <Step>[
|
|
Step(
|
|
title: Text('A'),
|
|
content: SizedBox(
|
|
width: 100.0,
|
|
height: 100.0,
|
|
),
|
|
),
|
|
Step(
|
|
title: Text('B'),
|
|
content: SizedBox(
|
|
width: 100.0,
|
|
height: 100.0,
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
//* ▲▲▲▲▲▲▲▲ code ▲▲▲▲▲▲▲▲ (do not modify or remove section marker)
|
|
//********************************************************************
|
|
|
|
}
|