build method
- BuildContext context,
- WidgetRef ref
Describes the part of the user interface represented by this widget.
The framework calls this method when this widget is inserted into the tree in a given BuildContext and when the dependencies of this widget change (e.g., an InheritedWidget referenced by this widget changes). This method can potentially be called in every frame and should not have any side effects beyond building a widget.
The framework replaces the subtree below this widget with the widget returned by this method, either by updating the existing subtree or by removing the subtree and inflating a new subtree, depending on whether the widget returned by this method can update the root of the existing subtree, as determined by calling Widget.canUpdate.
Typically implementations return a newly created constellation of widgets that are configured with information from this widget's constructor and from the given BuildContext.
The given BuildContext contains information about the location in the tree at which this widget is being built. For example, the context provides the set of inherited widgets for this location in the tree. A given widget might be built with multiple different BuildContext arguments over time if the widget is moved around the tree or if the widget is inserted into the tree in multiple places at once.
The implementation of this method must only depend on:
- the fields of the widget, which themselves must not change over time, and
- any ambient state obtained from the
contextusing BuildContext.dependOnInheritedWidgetOfExactType.
If a widget's build method is to depend on anything else, use a StatefulWidget instead.
See also:
- StatelessWidget, which contains the discussion on performance considerations.
Implementation
@override
Widget build(BuildContext context, WidgetRef ref) {
final isRehabilitationRest = useState(false);
return Stack(
children: [
Scaffold(
appBar: AppBar(
title: const Text('Debug'),
actions: [
IconButton(
onPressed: () async {
await Amplify.Auth.signOut();
},
icon: const Icon(Icons.login),
),
],
),
body: Center(
child: SingleChildScrollView(
child: Column(
children: [
const RehaculResponsiveWidget(
mobile: Text('mobile'),
tablet: Text('tablet'),
),
ElevatedButton(
onPressed: () {
const RehabilitationStartPageTabletRoute().go(context);
},
child: const Text('リハビリスタート'),
),
ElevatedButton(
onPressed: () {
const RehabilitationEndPageTabletRoute().go(context);
},
child: const Text('リハビリ終了'),
),
ElevatedButton(
onPressed: () {
const RehabilitationExerciseRoute().go(context);
},
child: const Text('Camera'),
),
ElevatedButton(
onPressed: () {
const RehabilitationWarmUpExercisePageTabletRoute()
.go(context);
},
child: const Text('準備体操'),
),
ElevatedButton(
onPressed: () {
const RehabilitationCoolDownExercisePageTabletRoute()
.go(context);
},
child: const Text('整理体操'),
),
ElevatedButton(
onPressed: () {
const RehabilitationCameraSettingPageTabletRoute()
.go(context);
},
child: const Text('カメラスタンド設定画面'),
),
TextButton(
onPressed: () async {
final data = ref.read(getDailyMeasurementRecordProvider(
date: Date(2023, 1, 1))
.future);
if (kDebugMode) {
print(data);
}
},
child: const Text('test'),
),
ElevatedButton(
onPressed: () {
const SettingRoute().go(context);
},
child: const Text('設定画面'),
),
ElevatedButton(
onPressed: () {
const LessonMovieRoute().go(context);
},
child: const Text('リハビリテスト'),
),
ElevatedButton(
onPressed: () {
const DebugPolarRoute().go(context);
},
child: const Text('Polarテスト'),
),
ElevatedButton(
onPressed: () {
const RehabilitationCoolDownExerciseStartPageTabletRoute()
.go(context);
},
child: const Text('整理運動開始'),
),
ElevatedButton(
onPressed: () async {
if (Platform.isAndroid) {
// Androidの場合、外部ストレージに保存するための許可を求める
final permission =
await Permission.manageExternalStorage.request();
if (permission.isDenied) {
if (context.mounted) {
await showDialog(
context: context,
builder: (_) =>
const ExternalStoragePermissionDeniedDialog(),
);
return;
}
}
}
if (context.mounted) {
const InstructorRecodingRoute().go(context);
}
},
child: const Text('講師録画'),
),
ElevatedButton(
onPressed: () {
const VideoCallRoute().go(context);
},
child: const Text('LiveKitビデオ通話Debug'),
),
ElevatedButton(
onPressed: () {
showDialog(
context: context,
barrierDismissible: false,
builder: (_) => PreSelectDialog(
onPressedDecision: () {},
),
);
},
child: const Text('PreSelectDialog'),
),
ElevatedButton(
onPressed: () {
showDialog(
context: context,
builder: (context) {
return RehabilitationPauseDialog(
onPressedEndButton: () {},
);
},
);
},
child: const Text('リハビリ中断ダイアログ'),
),
ElevatedButton(
onPressed: () async {
isRehabilitationRest.value = !isRehabilitationRest.value;
await Future.delayed(const Duration(seconds: 5));
isRehabilitationRest.value = !isRehabilitationRest.value;
},
child: const Text('休憩中コンポーネント表示切り替え'),
),
ElevatedButton(
onPressed: () {
const RehabilitationExerciseStartPageTabletRoute()
.go(context);
},
child: const Text('リハビリ運動開始画面'),
),
ElevatedButton(
onPressed: () {
const RehabilitationExercisePageTabletRoute().go(context);
},
child: const Text('リハビリ運動画面'),
),
],
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: () async {
try {
final _ = await Amplify.Auth.getCurrentUser();
} catch (e) {
if (kDebugMode) {
print(e);
}
}
},
child: const Icon(Icons.add),
),
),
if (isRehabilitationRest.value) const RehabilitationRestWidget(),
],
);
}