Skip to content

Instantly share code, notes, and snippets.

View isacjunior's full-sized avatar

Isac isacjunior

View GitHub Profile
class Counter {
Counter({this.count});
int count;
void increment() {
count++;
}
void decrement() {
import 'package:example/src/widgets/button.dart';
import 'package:example/src/widgets/button.doc_widget.dart';
import 'package:flutter/material.dart';
import 'package:doc_widget/doc_widget.dart';
void main() {
final button = ElementPreview(
document: ButtonDocWidget(), // From generated file
previews: [
WidgetPreview( // This will show your widget and a description about.
import 'package:flutter/cupertino.dart';
import 'package:doc_widget/doc_widget.dart';
/// ```dart
/// final button = Button(
/// 'Button',
/// onPressed: () => print('Doc Widget'),
/// );
/// ```
@docWidget
import 'package:flutter/cupertino.dart';
class Button extends StatelessWidget {
Button(
this.text, {
@required this.onPressed,
this.color = const Color(0xff007aff),
});
final String text;
dependencies:
flutter:
sdk: flutter
another_package:
path: ../another_package
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:widget_test/heart.dart';
// Função auxiliar para envolver os widgets a serem testados.
Widget makeTestable(Widget widget) => MaterialApp(home: widget);
void main() {
testWidgets('Heart smoke test', (WidgetTester tester) async {
// pumpWidget() renderiza a UI dado um widget.
import 'package:flutter/widgets.dart';
void main() => runApp(TopWidget());
class CounterInherited extends InheritedWidget {
CounterInherited({
Key key,
@required this.state,
@required Widget child,
}) : super(key: key, child: child);
import 'package:flutter/widgets.dart';
void main() => runApp(TopWidget());
class TopWidget extends StatefulWidget {
@override
_TopWidgetState createState() => _TopWidgetState();
}
class _TopWidgetState extends State<TopWidget> {
// .vscode/settings.json
{
"dart.analysisExcludedFolders": [
"lib/generated"
]
}
# analysis_options.yaml
analyzer:
exclude:
- lib/generated/**