Closed SuzukiDaishi closed 2 years ago
InteractiveViewerとStackを活用し、マップ画像&スポット画像(4枚)を1回のレンダリングで済むようにする。
InteractiveViewer
Stack
https://user-images.githubusercontent.com/40818362/149429323-3dfdb17e-f568-4850-80c3-5e0dc0bcffac.mp4
import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: const MyHomePage(title: 'Flutter Demo Home Page'), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({Key? key, required this.title}) : super(key: key); final String title; @override State<MyHomePage> createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text(widget.title)), body: InteractiveViewer( constrained: false, child: Stack( children: <Widget>[ Container( color: Colors.red, width: 600, height: 500, ), Positioned( left: 100, child: Container( color: Colors.blue, width: 100, height: 100, ), ), Positioned( top: 300, left: 200, child: Container( color: Colors.blue, width: 100, height: 100, ), ), Positioned( left: 300, child: Container( color: Colors.blue, width: 100, height: 100, ), ), Positioned( top: 300, left: 400, child: Container( color: Colors.blue, width: 100, height: 100, ), ), ], ), ), ); } }
CustomPaintからの脱却
InteractiveViewer
とStack
を活用し、マップ画像&スポット画像(4枚)を1回のレンダリングで済むようにする。デモ動画
https://user-images.githubusercontent.com/40818362/149429323-3dfdb17e-f568-4850-80c3-5e0dc0bcffac.mp4
コード