Skip to content

Instantly share code, notes, and snippets.

@brianegan
Created March 4, 2019 16:27
Show Gist options
  • Save brianegan/d86ed20adf635e80a0e1f668cf55587e to your computer and use it in GitHub Desktop.
Save brianegan/d86ed20adf635e80a0e1f668cf55587e to your computer and use it in GitHub Desktop.
Simple SVG implementation + Test
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'SVG + Test',
home: SvgTest(),
);
}
}
class SvgTest extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("SVG + Test"),
),
body: Center(
child: SvgPicture.asset(
'assets/tiger.svg',
semanticsLabel: 'A red up arrow',
),
),
);
}
}
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:asset_bundle_test/main.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('throws an error with no mock', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: SvgTest()));
expect(find.byType(SvgTest), findsOneWidget);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment