Files
Erick b76673946e Adding a proposal for new tutorials (#1006)
* Adding a proposal for new tutorials

* fixing and improving the text a little bit

* formating and lints

* copy button and few improvements

* adding super.render on position component

* fixing dashbook dependency

* Apply suggestions from code review

Co-authored-by: Luan Nico <luanpotter27@gmail.com>

* pr suggestions

* Apply suggestions from code review

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>

* suggestions

* fixing wrong merge

* reverting analysis options

* Update tutorials/space_shooter/lib/steps/1_getting_started/1_flame_game/code.dart

Co-authored-by: Luan Nico <luanpotter27@gmail.com>

* Update tutorials/space_shooter/lib/steps/1_getting_started/1_flame_game/step.dart

* Update tutorials/space_shooter/README.md

* Update tutorials/space_shooter/lib/steps/1_getting_started/2_input_and_graphics/tutorial.dart

* Update tutorials/space_shooter/lib/steps/1_getting_started/2_input_and_graphics/tutorial.dart

* Update tutorials/space_shooter/lib/steps/1_getting_started/2_input_and_graphics/tutorial.dart

* Update tutorials/space_shooter/lib/widgets/step_scaffold.dart

Co-authored-by: Luan Nico <luanpotter27@gmail.com>

* Update tutorials/space_shooter/lib/steps/1_getting_started/1_flame_game/step.dart

* Fix formatting

* Update to 0.1.5 dashbook

* Fix wrong class name RunningFlameStep

* Use magic flame_lint

* Fix paint and rect in player class description

Co-authored-by: Luan Nico <luanpotter27@gmail.com>
Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
Co-authored-by: Lukas Klingsbo (spydon) <me@lukas.fyi>
2021-10-28 16:46:19 +02:00

55 lines
1.5 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_highlight/flutter_highlight.dart';
import 'package:flutter_highlight/themes/dark.dart';
import 'package:flutter_highlight/themes/github.dart';
class CodeBlock extends StatelessWidget {
final String value;
const CodeBlock({Key? key, required this.value}) : super(key: key);
@override
Widget build(BuildContext context) {
final code = value.replaceAll('```', '');
return Padding(
padding: const EdgeInsets.all(22.0),
child: Stack(
children: [
Align(
alignment: Alignment.topLeft,
child: HighlightView(
code,
padding: const EdgeInsets.symmetric(
horizontal: 22,
),
language: 'dart',
theme: Theme.of(context).brightness == Brightness.light
? githubTheme
: darkTheme,
),
),
Positioned(
top: 10,
right: 10,
child: IconButton(
onPressed: () {
Clipboard.setData(
ClipboardData(text: code),
);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Code copied!'),
),
);
},
tooltip: 'Copy code',
icon: const Icon(Icons.copy),
),
)
],
),
);
}
}